org.python.core

Class Py


public final class Py
extends java.lang.Object

Field Summary

static PyObject
ArithmeticError
static PyObject
AssertionError
static PyObject
AttributeError
static int
COMMENT
static int
DEBUG
static PyObject
DeprecationWarning
static PyObject
EOFError
static int
ERROR
static PyObject
Ellipsis
The singleton Ellipsis Python object - written as ... when indexing
static PyObject[]
EmptyObjects
A zero-length array of PyObject's to pass to functions that expect zero-arguments *
static PyString
EmptyString
A zero-length Python string *
static PyTuple
EmptyTuple
A tuple with zero elements *
static PyObject
EnvironmentError
static PyObject
Exception
static PyObject
FloatingPointError
static PyObject
IOError
static PyObject
ImportError
static PyObject
IndentationError
static PyObject
IndexError
static PyObject
JavaError
static PyObject
KeyError
static PyObject
KeyboardInterrupt
static PyObject
LookupError
static int
MESSAGE
static PyObject
MemoryError
static PyObject
NameError
static PyString
Newline
A Python string containing '\n' *
static Object
NoConversion
A unique object to indicate no conversion is possible in __tojava__ methods *
static String[]
NoKeywords
A zero-length array of Strings to pass to functions that don't have any keyword arguments *
static PyObject
None
The singleton None Python object *
static PyObject
NotImplemented
The singleton NotImplemented Python object.
static PyObject
NotImplementedError
static PyObject
OSError
static PyInteger
One
The Python integer 1 - also used as true *
static PyObject
OverflowError
static PyObject
OverflowWarning
static PyObject
ReferenceError
static PyObject
RuntimeError
static PyObject
RuntimeWarning
static PyString
Space
A Python string containing ' ' *
static PyObject
StandardError
static PyObject
StopIteration
static PyObject
SyntaxError
static PyObject
SyntaxWarning
static PyObject
SystemError
static PyObject
SystemExit
static PyObject
TabError
static PyObject
TypeError
static PyObject
UnboundLocalError
static PyObject
UnicodeError
static PyObject
UserWarning
static PyObject
ValueError
static int
WARNING
static PyObject
Warning
static PyInteger
Zero
The Python integer 0 - also used as false *
static PyObject
ZeroDivisionError
static PySystemState
defaultSystemState
static StdoutWrapper
stderr

Method Summary

static PyException
AssertionError(String message)
static PyException
AttributeError(String message)
static void
DeprecationWarning(String message)
static PyException
EOFError(String message)
static PyException
FloatingPointError(String message)
static PyException
IOError(String message)
static PyException
IOError(java.io.IOException ioe)
static PyException
ImportError(String message)
static PyException
IndexError(String message)
static PyException
JavaError(Throwable t)
static PyException
KeyError(String message)
static PyException
MemoryError(String message)
static PyException
NameError(String message)
static PyException
OverflowError(String message)
static void
OverflowWarning(String message)
static PyException
ReferenceError(String message)
static PyException
RuntimeError(String message)
static void
RuntimeWarning(String message)
static PyException
StopIteration(String message)
static PyException
SyntaxError(String message)
static void
SyntaxWarning(String message)
static PyException
SystemError(String message)
static PyException
TypeError(String message)
static PyException
UnboundLocalError(String message)
static PyException
UnicodeError(String message)
static void
UserWarning(String message)
static PyException
ValueError(String message)
static void
Warning(String message)
static PyException
ZeroDivisionError(String message)
static void
addTraceback(Throwable t, PyFrame frame)
static void
assert_(PyObject test)
static void
assert_(PyObject test, PyObject message)
static PyCode
compile(InputStream istream, String filename, String type)
static PyCode
compile(org.python.parser.ast.modType node, String filename)
static PyCode
compile(org.python.parser.ast.modType node, String name, String filename)
static PyCode
compile(org.python.parser.ast.modType node, String name, String filename, boolean linenumbers, boolean printResults)
static PyObject
compile_command_flags(String string, String filename, String kind, CompilerFlags cflags, boolean stdprompt)
static PyCode
compile_flags(InputStream istream, String filename, String type, CompilerFlags cflags)
static PyCode
compile_flags(String data, String filename, String type, CompilerFlags cflags)
static PyCode
compile_flags(org.python.parser.ast.modType node, String name, String filename, boolean linenumbers, boolean printResults, CompilerFlags cflags)
static void
displayException(PyObject type, PyObject value, PyObject tb, PyObject file)
static void
exec(PyObject o, PyObject globals, PyObject locals)
static Class
findClass(String name)
static Class
findClassEx(String name, String reason)
static CompilerFlags
getCompilerFlags()
static CompilerFlags
getCompilerFlags(int flags, boolean dont_inherit)
static PyFrame
getFrame()
static String
getName()
static PySystemState
getSystemState()
static ThreadState
getThreadState()
static ThreadState
getThreadState(PySystemState newSystemState)
static long
id(PyObject o)
static String
idstr(PyObject o)
static void
initProxy(PyProxy proxy, String module, String pyclass, Object[] args, String[] packages, String[] props, String frozenPackage, String[] modules)
static void
initProxy(PyProxy proxy, String module, String pyclass, Object[] args, String[] packages, String[] props, boolean frozen)
static boolean
initPython()
static void
initRunnable(String module, PyObject dict)
static boolean
isInstance(PyObject obj, PyObject cls)
static boolean
isSubClass(PyObject derived, PyObject cls)
static PyObject
iter(PyObject seq, String message)
static PyObject
java2py(Object o)
static long
java_obj_id(Object o)
static PyObject
jfindattr(PyProxy proxy, String name)
Deprecated.
static PyObject
jgetattr(PyProxy proxy, String name)
Deprecated.
static PyObject
makeClass(String name, PyObject[] bases, PyCode code, PyObject doc)
static PyObject
makeClass(String name, PyObject[] bases, PyCode code, PyObject doc, Class proxyClass)
static PyObject
makeClass(String name, PyObject[] bases, PyCode code, PyObject doc, Class proxyClass, PyObject[] closure_cells)
static PyObject
makeClass(String name, PyObject[] bases, PyCode code, PyObject doc, PyObject[] closure_cells)
static PyException
makeException()
static PyException
makeException(PyObject type)
static PyException
makeException(PyObject type, PyObject value)
static PyException
makeException(PyObject type, PyObject value, PyObject traceback)
static boolean
matchException(PyException pye, PyObject e)
static void
maybeWrite(String type, String msg, int level)
static void
memory_error(OutOfMemoryError t)
static PyInteger
newBoolean(boolean t)
static PyCode
newCode(int argcount, varnames[] , String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)
static PyCode
newCode(int argcount, varnames[] , String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags)
static PyCode
newCode(int argcount, varnames[] , String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)
static PyCode
newCode(int argcount, varnames[] , String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags)
static PyFloat
newFloat(double v)
static PyFloat
newFloat(float v)
static PyComplex
newImaginary(double v)
static PyInteger
newInteger(int i)
static PyObject
newInteger(long i)
static PyCode
newJavaCode(Class cls, String name)
static PyObject
newJavaFunc(Class cls, String name)
static PyLong
newLong(String s)
static PyLong
newLong(int i)
static PyLong
newLong(java.math.BigInteger i)
static PyString
newString(String s)
static PyString
newString(char c)
static PyUnicode
newUnicode(String s)
static PyUnicode
newUnicode(char c)
static void
print(PyObject o)
static void
print(PyObject file, PyObject o)
static void
printComma(PyObject o)
static void
printComma(PyObject file, PyObject o)
static void
printException(Throwable t)
static void
printException(Throwable t, PyFrame f)
static void
printException(Throwable t, PyFrame f, PyObject file)
static void
printResult(PyObject ret)
static void
println()
static void
println(PyObject o)
static void
println(PyObject file, PyObject o)
static void
printlnv(PyObject file)
static boolean
py2boolean(PyObject o)
static byte
py2byte(PyObject o)
static char
py2char(PyObject o)
static char
py2char(PyObject o, String msg)
static double
py2double(PyObject o)
static float
py2float(PyObject o)
static int
py2int(PyObject o)
static int
py2int(PyObject o, String msg)
static long
py2long(PyObject o)
static short
py2short(PyObject o)
static void
py2void(PyObject o)
static Class
relFindClass(Class home, String name)
static PyObject
runCode(PyCode code, PyObject locals, PyObject globals)
static void
runMain(Class mainClass, String[] args, String[] packages, String[] props, String frozenPackage, String[] modules)
static String
safeRepr(PyObject o)
static void
saveClassFile(String name, ByteArrayOutputStream bytestream)
static PyException
setException(Throwable t, PyFrame frame)
static void
setFrame(PyFrame f)
static PySystemState
setSystemState(PySystemState newSystemState)
static Object
tojava(PyObject o, Class c)
Convert a given PyObject to an instance of a Java class.
static Object
tojava(PyObject o, String s)
static PyObject[]
unpackSequence(PyObject o, int length)
static void
warning(PyObject category, String message)
static void
warning(PyObject category, String message, String filename, int lineno, String module, PyObject registry)
static void
writeComment(String type, String msg)
static void
writeDebug(String type, String msg)
static void
writeError(String type, String msg)
static void
writeMessage(String type, String msg)
static void
writeWarning(String type, String msg)

Field Details

ArithmeticError

public static PyObject ArithmeticError

AssertionError

public static PyObject AssertionError

AttributeError

public static PyObject AttributeError

COMMENT

public static final int COMMENT
Field Value:
2

DEBUG

public static final int DEBUG
Field Value:
3

DeprecationWarning

public static PyObject DeprecationWarning

EOFError

public static PyObject EOFError

ERROR

public static final int ERROR
Field Value:
-1

Ellipsis

public static PyObject Ellipsis
The singleton Ellipsis Python object - written as ... when indexing

EmptyObjects

public static PyObject[] EmptyObjects
A zero-length array of PyObject's to pass to functions that expect zero-arguments *

EmptyString

public static PyString EmptyString
A zero-length Python string *

EmptyTuple

public static PyTuple EmptyTuple
A tuple with zero elements *

EnvironmentError

public static PyObject EnvironmentError

Exception

public static PyObject Exception

FloatingPointError

public static PyObject FloatingPointError

IOError

public static PyObject IOError

ImportError

public static PyObject ImportError

IndentationError

public static PyObject IndentationError

IndexError

public static PyObject IndexError

JavaError

public static PyObject JavaError

KeyError

public static PyObject KeyError

KeyboardInterrupt

public static PyObject KeyboardInterrupt

LookupError

public static PyObject LookupError

MESSAGE

public static final int MESSAGE
Field Value:
1

MemoryError

public static PyObject MemoryError

NameError

public static PyObject NameError

Newline

public static PyString Newline
A Python string containing '\n' *

NoConversion

public static Object NoConversion
A unique object to indicate no conversion is possible in __tojava__ methods *

NoKeywords

public static String[] NoKeywords
A zero-length array of Strings to pass to functions that don't have any keyword arguments *

None

public static PyObject None
The singleton None Python object *

NotImplemented

public static PyObject NotImplemented
The singleton NotImplemented Python object. Used in rich comparison

NotImplementedError

public static PyObject NotImplementedError

OSError

public static PyObject OSError

One

public static PyInteger One
The Python integer 1 - also used as true *

OverflowError

public static PyObject OverflowError

OverflowWarning

public static PyObject OverflowWarning

ReferenceError

public static PyObject ReferenceError

RuntimeError

public static PyObject RuntimeError

RuntimeWarning

public static PyObject RuntimeWarning

Space

public static PyString Space
A Python string containing ' ' *

StandardError

public static PyObject StandardError

StopIteration

public static PyObject StopIteration

SyntaxError

public static PyObject SyntaxError

SyntaxWarning

public static PyObject SyntaxWarning

SystemError

public static PyObject SystemError

SystemExit

public static PyObject SystemExit

TabError

public static PyObject TabError

TypeError

public static PyObject TypeError

UnboundLocalError

public static PyObject UnboundLocalError

UnicodeError

public static PyObject UnicodeError

UserWarning

public static PyObject UserWarning

ValueError

public static PyObject ValueError

WARNING

public static final int WARNING
Field Value:
0

Warning

public static PyObject Warning

Zero

public static PyInteger Zero
The Python integer 0 - also used as false *

ZeroDivisionError

public static PyObject ZeroDivisionError

defaultSystemState

public static PySystemState defaultSystemState

stderr

public static StdoutWrapper stderr

Method Details

AssertionError

public static PyException AssertionError(String message)

AttributeError

public static PyException AttributeError(String message)

DeprecationWarning

public static void DeprecationWarning(String message)

EOFError

public static PyException EOFError(String message)

FloatingPointError

public static PyException FloatingPointError(String message)

IOError

public static PyException IOError(String message)

IOError

public static PyException IOError(java.io.IOException ioe)

ImportError

public static PyException ImportError(String message)

IndexError

public static PyException IndexError(String message)

JavaError

public static PyException JavaError(Throwable t)

KeyError

public static PyException KeyError(String message)

MemoryError

public static PyException MemoryError(String message)

NameError

public static PyException NameError(String message)

OverflowError

public static PyException OverflowError(String message)

OverflowWarning

public static void OverflowWarning(String message)

ReferenceError

public static PyException ReferenceError(String message)

RuntimeError

public static PyException RuntimeError(String message)

RuntimeWarning

public static void RuntimeWarning(String message)

StopIteration

public static PyException StopIteration(String message)

SyntaxError

public static PyException SyntaxError(String message)

SyntaxWarning

public static void SyntaxWarning(String message)

SystemError

public static PyException SystemError(String message)

TypeError

public static PyException TypeError(String message)

UnboundLocalError

public static PyException UnboundLocalError(String message)

UnicodeError

public static PyException UnicodeError(String message)

UserWarning

public static void UserWarning(String message)

ValueError

public static PyException ValueError(String message)

Warning

public static void Warning(String message)

ZeroDivisionError

public static PyException ZeroDivisionError(String message)

addTraceback

public static void addTraceback(Throwable t,
                                PyFrame frame)

assert_

public static void assert_(PyObject test)

assert_

public static void assert_(PyObject test,
                           PyObject message)

compile

public static PyCode compile(InputStream istream,
                             String filename,
                             String type)

compile

public static PyCode compile(org.python.parser.ast.modType node,
                             String filename)

compile

public static PyCode compile(org.python.parser.ast.modType node,
                             String name,
                             String filename)

compile

public static PyCode compile(org.python.parser.ast.modType node,
                             String name,
                             String filename,
                             boolean linenumbers,
                             boolean printResults)

compile_command_flags

public static PyObject compile_command_flags(String string,
                                             String filename,
                                             String kind,
                                             CompilerFlags cflags,
                                             boolean stdprompt)

compile_flags

public static PyCode compile_flags(InputStream istream,
                                   String filename,
                                   String type,
                                   CompilerFlags cflags)

compile_flags

public static PyCode compile_flags(String data,
                                   String filename,
                                   String type,
                                   CompilerFlags cflags)

compile_flags

public static PyCode compile_flags(org.python.parser.ast.modType node,
                                   String name,
                                   String filename,
                                   boolean linenumbers,
                                   boolean printResults,
                                   CompilerFlags cflags)

displayException

public static void displayException(PyObject type,
                                    PyObject value,
                                    PyObject tb,
                                    PyObject file)

exec

public static void exec(PyObject o,
                        PyObject globals,
                        PyObject locals)

findClass

public static Class findClass(String name)

findClassEx

public static Class findClassEx(String name,
                                String reason)

getCompilerFlags

public static CompilerFlags getCompilerFlags()

getCompilerFlags

public static CompilerFlags getCompilerFlags(int flags,
                                             boolean dont_inherit)

getFrame

public static PyFrame getFrame()

getName

public static String getName()

getSystemState

public static final PySystemState getSystemState()

getThreadState

public static final ThreadState getThreadState()

getThreadState

public static final ThreadState getThreadState(PySystemState newSystemState)

id

public static long id(PyObject o)

idstr

public static String idstr(PyObject o)

initProxy

public static void initProxy(PyProxy proxy,
                             String module,
                             String pyclass,
                             Object[] args,
                             String[] packages,
                             String[] props,
                             String frozenPackage,
                             String[] modules)

initProxy

public static void initProxy(PyProxy proxy,
                             String module,
                             String pyclass,
                             Object[] args,
                             String[] packages,
                             String[] props,
                             boolean frozen)

initPython

public static boolean initPython()

initRunnable

public static void initRunnable(String module,
                                PyObject dict)

isInstance

public static boolean isInstance(PyObject obj,
                                 PyObject cls)

isSubClass

public static boolean isSubClass(PyObject derived,
                                 PyObject cls)

iter

public static PyObject iter(PyObject seq,
                            String message)

java2py

public static PyObject java2py(Object o)

java_obj_id

public static long java_obj_id(Object o)

jfindattr

public static PyObject jfindattr(PyProxy proxy,
                                 String name)

Deprecated.


jgetattr

public static PyObject jgetattr(PyProxy proxy,
                                String name)

Deprecated.


makeClass

public static PyObject makeClass(String name,
                                 PyObject[] bases,
                                 PyCode code,
                                 PyObject doc)

makeClass

public static PyObject makeClass(String name,
                                 PyObject[] bases,
                                 PyCode code,
                                 PyObject doc,
                                 Class proxyClass)

makeClass

public static PyObject makeClass(String name,
                                 PyObject[] bases,
                                 PyCode code,
                                 PyObject doc,
                                 Class proxyClass,
                                 PyObject[] closure_cells)

makeClass

public static PyObject makeClass(String name,
                                 PyObject[] bases,
                                 PyCode code,
                                 PyObject doc,
                                 PyObject[] closure_cells)

makeException

public static PyException makeException()

makeException

public static PyException makeException(PyObject type)

makeException

public static PyException makeException(PyObject type,
                                        PyObject value)

makeException

public static PyException makeException(PyObject type,
                                        PyObject value,
                                        PyObject traceback)

matchException

public static boolean matchException(PyException pye,
                                     PyObject e)

maybeWrite

public static void maybeWrite(String type,
                              String msg,
                              int level)

memory_error

public static void memory_error(OutOfMemoryError t)

newBoolean

public static PyInteger newBoolean(boolean t)

newCode

public static PyCode newCode(int argcount,
                             varnames[] ,
                             String filename,
                             String name,
                             boolean args,
                             boolean keywords,
                             PyFunctionTable funcs,
                             int func_id)

newCode

public static PyCode newCode(int argcount,
                             varnames[] ,
                             String filename,
                             String name,
                             boolean args,
                             boolean keywords,
                             PyFunctionTable funcs,
                             int func_id,
                             String[] cellvars,
                             String[] freevars,
                             int npurecell,
                             int moreflags)

newCode

public static PyCode newCode(int argcount,
                             varnames[] ,
                             String filename,
                             String name,
                             int firstlineno,
                             boolean args,
                             boolean keywords,
                             PyFunctionTable funcs,
                             int func_id)

newCode

public static PyCode newCode(int argcount,
                             varnames[] ,
                             String filename,
                             String name,
                             int firstlineno,
                             boolean args,
                             boolean keywords,
                             PyFunctionTable funcs,
                             int func_id,
                             String[] cellvars,
                             String[] freevars,
                             int npurecell,
                             int moreflags)

newFloat

public static PyFloat newFloat(double v)

newFloat

public static PyFloat newFloat(float v)

newImaginary

public static PyComplex newImaginary(double v)

newInteger

public static final PyInteger newInteger(int i)

newInteger

public static PyObject newInteger(long i)

newJavaCode

public static PyCode newJavaCode(Class cls,
                                 String name)

newJavaFunc

public static PyObject newJavaFunc(Class cls,
                                   String name)

newLong

public static PyLong newLong(String s)

newLong

public static PyLong newLong(int i)

newLong

public static PyLong newLong(java.math.BigInteger i)

newString

public static PyString newString(String s)

newString

public static PyString newString(char c)

newUnicode

public static PyUnicode newUnicode(String s)

newUnicode

public static PyUnicode newUnicode(char c)

print

public static void print(PyObject o)

print

public static void print(PyObject file,
                         PyObject o)

printComma

public static void printComma(PyObject o)

printComma

public static void printComma(PyObject file,
                              PyObject o)

printException

public static void printException(Throwable t)

printException

public static void printException(Throwable t,
                                  PyFrame f)

printException

public static void printException(Throwable t,
                                  PyFrame f,
                                  PyObject file)

printResult

public static void printResult(PyObject ret)

println

public static void println()

println

public static void println(PyObject o)

println

public static void println(PyObject file,
                           PyObject o)

printlnv

public static void printlnv(PyObject file)

py2boolean

public static boolean py2boolean(PyObject o)

py2byte

public static byte py2byte(PyObject o)

py2char

public static char py2char(PyObject o)

py2char

public static char py2char(PyObject o,
                           String msg)

py2double

public static double py2double(PyObject o)

py2float

public static float py2float(PyObject o)

py2int

public static int py2int(PyObject o)

py2int

public static int py2int(PyObject o,
                         String msg)

py2long

public static long py2long(PyObject o)

py2short

public static short py2short(PyObject o)

py2void

public static void py2void(PyObject o)

relFindClass

public static Class relFindClass(Class home,
                                 String name)

runCode

public static PyObject runCode(PyCode code,
                               PyObject locals,
                               PyObject globals)

runMain

public static void runMain(Class mainClass,
                           String[] args,
                           String[] packages,
                           String[] props,
                           String frozenPackage,
                           String[] modules)
            throws Exception

safeRepr

public static String safeRepr(PyObject o)

saveClassFile

public static void saveClassFile(String name,
                                 ByteArrayOutputStream bytestream)

setException

public static PyException setException(Throwable t,
                                       PyFrame frame)

setFrame

public static void setFrame(PyFrame f)

setSystemState

public static final PySystemState setSystemState(PySystemState newSystemState)

tojava

public static Object tojava(PyObject o,
                            Class c)
Convert a given PyObject to an instance of a Java class. Identical to o.__tojava__(c) except that it will raise a TypeError if the conversion fails.
Parameters:
o - the PyObject to convert.
c - the class to convert it to.

tojava

public static Object tojava(PyObject o,
                            String s)

unpackSequence

public static PyObject[] unpackSequence(PyObject o,
                                        int length)

warning

public static void warning(PyObject category,
                           String message)

warning

public static void warning(PyObject category,
                           String message,
                           String filename,
                           int lineno,
                           String module,
                           PyObject registry)

writeComment

public static void writeComment(String type,
                                String msg)

writeDebug

public static void writeDebug(String type,
                              String msg)

writeError

public static void writeError(String type,
                              String msg)

writeMessage

public static void writeMessage(String type,
                                String msg)

writeWarning

public static void writeWarning(String type,
                                String msg)

Jython homepage