Class Py
- java.lang.Object
-
- org.python.core.PrePy
-
- org.python.core.Py
-
public final class Py extends PrePy
-
-
Field Summary
Fields Modifier and Type Field Description static PyObjectArithmeticErrorstatic PyObjectAssertionErrorstatic PyObjectAttributeErrorstatic PyObjectBaseExceptionstatic PyObjectBufferErrorstatic PyObjectBytesWarningstatic PySystemStatedefaultSystemStatestatic PyObjectDeprecationWarningstatic PyObjectEllipsisThe singleton Ellipsis Python object - written as ... when indexingstatic PyFrozenSetEmptyFrozenSetA frozenset with zero elementsstatic PyObject[]EmptyObjectsA zero-length array of PyObject's to pass to functions when we have no argumentsstatic PyStringEmptyStringA zero-length Python byte stringstatic PyTupleEmptyTupleA tuple with zero elementsstatic PyUnicodeEmptyUnicodeA zero-length Python Unicode stringstatic PyObjectEnvironmentErrorstatic PyObjectEOFErrorstatic PyObjectExceptionstatic PyBooleanFalseThe Python boolean Falsestatic PyObjectFloatingPointErrorstatic PyObjectFutureWarningstatic PyObjectGeneratorExitstatic PyObjectImportErrorstatic PyObjectImportWarningstatic PyObjectIndentationErrorstatic PyObjectIndexErrorstatic PyObjectIOErrorstatic PyObjectJavaErrorstatic PyObjectKeyboardInterruptstatic PyObjectKeyErrorstatic PyObjectLookupErrorstatic PyObjectMemoryErrorstatic PyObjectNameErrorstatic PyStringNewlineA Python string containing '\n'static java.lang.ObjectNoConversionA unique object to indicate no conversion is possible in __tojava__ methodsstatic java.lang.String[]NoKeywordsA zero-length array of Strings to pass to functions that don't have any keyword argumentsstatic PyObjectNoneThe singleton None Python objectstatic PyObjectNotImplementedThe singleton NotImplemented Python object.static PyObjectNotImplementedErrorstatic PyIntegerOneThe Python integer 1static PyObjectOSErrorstatic PyObjectOverflowErrorstatic PyObjectPendingDeprecationWarningstatic PyObjectReferenceErrorstatic PyObjectRuntimeErrorstatic PyObjectRuntimeWarningstatic PyStringSpaceA Python string containing ' 'static PyObjectStandardErrorstatic StdoutWrapperstderrstatic PyObjectStopIterationstatic PyObjectSyntaxErrorstatic PyObjectSyntaxWarningstatic PyObjectSystemErrorstatic PyObjectSystemExitstatic PyObjectTabErrorstatic longTPFLAGS_BASETYPESet if the type allows subclassingstatic longTPFLAGS_HEAPTYPESet if the type object is dynamically allocatedstatic longTPFLAGS_IS_ABSTRACTType is abstract and cannot be instantiatedstatic PyBooleanTrueThe Python boolean Truestatic PyObjectTypeErrorstatic PyObjectUnboundLocalErrorstatic PyObjectUnicodeDecodeErrorstatic PyObjectUnicodeEncodeErrorstatic PyObjectUnicodeErrorstatic PyUnicodeUnicodeNewlineA Python unicode string containing '\n'static PyUnicodeUnicodeSpaceA Python unicode string containing ' 'static PyObjectUnicodeTranslateErrorstatic PyObjectUnicodeWarningstatic PyObjectUserWarningstatic PyObjectValueErrorstatic PyObjectWarningstatic PyIntegerZeroThe Python integer 0static PyObjectZeroDivisionError
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddTraceback(java.lang.Throwable t, PyFrame frame)static voidassert_(PyObject test)static voidassert_(PyObject test, PyObject message)static PyExceptionAssertionError(java.lang.String message)static PyExceptionAttributeError(java.lang.String message)static PyExceptionBufferError(java.lang.String message)static voidBytesWarning(java.lang.String message)static PyCodecompile(java.io.InputStream istream, java.lang.String filename, CompileMode kind)static PyObjectcompile_command_flags(java.lang.String string, java.lang.String filename, CompileMode kind, CompilerFlags cflags, boolean stdprompt)static PyCodecompile_flags(java.io.InputStream istream, java.lang.String filename, CompileMode kind, CompilerFlags cflags)Compiles python source code coming from a file or another external streamstatic PyCodecompile_flags(java.lang.String data, java.lang.String filename, CompileMode kind, CompilerFlags cflags)Compiles python source code coming from String (raw bytes) data.static PyCodecompile_flags(org.python.antlr.base.mod node, java.lang.String name, java.lang.String filename, boolean linenumbers, boolean printResults, CompilerFlags cflags)Entry point for compiling modules.static PyCodecompile_flags(org.python.antlr.base.mod node, java.lang.String filename, CompileMode kind, CompilerFlags cflags)static voidDeprecationWarning(java.lang.String message)static voiddisplayException(PyObject type, PyObject value, PyObject tb, PyObject file)Print the description of an exception as a big string.static PyExceptionEnvironmentError(java.lang.String message)static PyExceptionEOFError(java.lang.String message)static voidexec(PyObject o, PyObject globals, PyObject locals)static java.lang.StringfileSystemDecode(PyObject filename)static java.lang.StringfileSystemDecode(PyString filename)Return a file name or path as Unicode (Java UTF-16String), decoded if necessary from a Pythonbytesobject, using the file system encoding.static PyStringfileSystemEncode(java.lang.String filename)Return a PyString object we can use as a file name or file path in places where Python expects abytes(that is astr) object in the file system encoding.static PyStringfileSystemEncode(PyString filename)Return a PyString object we can use as a file name or file path in places where Python expects abytes(that is,str) object in the file system encoding.static java.lang.Class<?>findClass(java.lang.String name)Find and load a Java class by name.static java.lang.Class<?>findClassEx(java.lang.String name, java.lang.String reason)Find and load a Java class by name.static PyExceptionFloatingPointError(java.lang.String message)static voidflushLine()static java.lang.StringformatException(PyObject type, PyObject value)static java.lang.StringformatException(PyObject type, PyObject value, boolean useRepr)static voidFutureWarning(java.lang.String message)static PyExceptionGeneratorExit(java.lang.String message)static ExtensiblePyObjectAdaptergetAdapter()static CompilerFlagsgetCompilerFlags()static CompilerFlagsgetCompilerFlags(int flags, boolean dont_inherit)static CompilerFlagsgetCompilerFlags(CompilerFlags flags, boolean dont_inherit)static ConsolegetConsole()Get the Jython Console (used forinput(),raw_input(), etc.) as constructed and set byPySystemStateinitialization.static java.lang.Stringgetenv(java.lang.String name)The same asgetenv(name, null).static java.lang.Stringgetenv(java.lang.String name, java.lang.String defaultValue)Get the value of the environment variable named fromos.environor return the given default value.static PyStringgetenv(PyString name)The same asgetenv(name, null).static PyStringgetenv(PyString name, PyString defaultValue)Get the value of the environment variable named fromos.environor return the given default value.static PyFramegetFrame()static java.lang.StringgetName()static PySystemStategetSystemState()static ThreadStategetThreadState()static ThreadStategetThreadState(PySystemState newSystemState)static longid(PyObject o)static java.lang.Stringidstr(PyObject o)static PyExceptionImportError(java.lang.String message)static booleanimportSiteIfSelected()static voidImportWarning(java.lang.String message)static PyExceptionIndexError(java.lang.String message)static voidinitProxy(PyProxy proxy, java.lang.String module, java.lang.String pyclass, java.lang.Object[] args)static booleaninitPython()static voidinstallConsole(Console console)Install the provided Console, first uninstalling any current one.static PyExceptionIOError(java.io.IOException ioe)static PyExceptionIOError(java.lang.String message)static PyExceptionIOError(jnr.constants.Constant errno)static PyExceptionIOError(jnr.constants.Constant errno, java.lang.String filename)static PyExceptionIOError(jnr.constants.Constant errno, PyObject filename)static booleanisInstance(PyObject inst, PyObject cls)static booleanisSubClass(PyObject derived, PyObject cls)static PyObjectiter(PyObject seq, java.lang.String message)static longjava_obj_id(java.lang.Object o)static PyObjectjava2py(java.lang.Object o)Uses the PyObjectAdapter passed toPySystemState.initialize()to turn o into a PyObject.static PyExceptionJavaError(java.lang.Throwable t)static PyObjectjavaPyClass(PyObject cls, java.lang.Class<?> interfce)Returns a Python-class that extendsclsandinterfce.static PyObject[]javas2pys(java.lang.Object... objects)Uses the PyObjectAdapter passed toPySystemState.initialize()to turnobjectsinto an array of PyObjects.static PyExceptionKeyboardInterrupt(java.lang.String message)static PyExceptionKeyError(java.lang.String message)static PyExceptionKeyError(PyObject key)static PyStringmakeCharacter(char c)static PyStringmakeCharacter(java.lang.Character o)static PyObjectmakeClass(java.lang.String name, PyObject[] bases, PyCode code)static PyObjectmakeClass(java.lang.String name, PyObject[] bases, PyCode code, PyObject[] closure_cells)static PyObjectmakeClass(java.lang.String name, PyObject[] bases, PyObject dict)Create a new Python class.static PyObjectmakeClass(java.lang.String name, PyObject base, PyObject dict)static PyExceptionmakeException()static PyExceptionmakeException(PyObject type)static PyExceptionmakeException(PyObject type, PyObject value)static PyExceptionmakeException(PyObject type, PyObject value, PyObject traceback)static booleanmatchException(PyException pye, PyObject exc)Deprecated.As of Jython 2.5, usePyException.match(org.python.core.PyObject)instead.static voidmemory_error(java.lang.OutOfMemoryError t)static PyExceptionMemoryError(java.lang.String message)static PyExceptionNameError(java.lang.String message)static PyBooleannewBoolean(boolean t)static PyCodenewCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)static PyCodenewCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, java.lang.String[] cellvars, java.lang.String[] freevars, int npurecell, int moreflags)static PyCodenewCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)static PyCodenewCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, java.lang.String[] cellvars, java.lang.String[] freevars, int npurecell, int moreflags)static PyObjectnewDate(java.sql.Date date)static PyObjectnewDatetime(java.sql.Timestamp timestamp)static PyObjectnewDecimal(java.lang.String decimal)static PyFloatnewFloat(double v)static PyFloatnewFloat(float v)static PyComplexnewImaginary(double v)static PyIntegernewInteger(int i)static PyObjectnewInteger(long i)static <T> TnewJ(PyModule module, java.lang.Class<T> jcls, java.lang.Object... args)Works likenewJ(PyObject, Class, Object...), but looks up the Python-class in the module-dict using the interface-name, i.e.static <T> TnewJ(PyModule module, java.lang.Class<T> jcls, java.lang.String[] keywords, java.lang.Object... args)Works likenewJ(PyObject, Class, String[], Object...), but looks up the Python-class in the module-dict using the interface-name, i.e.static <T> TnewJ(PyObject cls, java.lang.Class<T> jcls, java.lang.Object... args)This method is a compact helper to access Python-constructors from Java.static <T> TnewJ(PyObject cls, java.lang.Class<T> jcls, java.lang.String[] keywords, java.lang.Object... args)This method is a compact helper to access Python-constructors from Java.static <T> TnewJ(PyObject cls, java.lang.Class<T> jcls, PyObject[] args, java.lang.String[] keywords)This method is a compact helper to access Python-constructors from Java.static PyCodenewJavaCode(java.lang.Class<?> cls, java.lang.String name)static PyObjectnewJavaFunc(java.lang.Class<?> cls, java.lang.String name)static PyLongnewLong(int i)static PyLongnewLong(long l)static PyLongnewLong(java.lang.String s)static PyLongnewLong(java.math.BigInteger i)static PyStringnewString(char c)static PyStringnewString(java.lang.String s)static PyStringMapnewStringMap()static PyStringnewStringOrUnicode(java.lang.String s)static PyStringnewStringOrUnicode(PyObject precedent, java.lang.String s)static PyStringnewStringUTF8(java.lang.String s)static PyObjectnewTime(java.sql.Time time)static PyUnicodenewUnicode(char c)static PyUnicodenewUnicode(java.lang.String s)static PyUnicodenewUnicode(java.lang.String s, boolean isBasic)static PyExceptionNotImplementedError(java.lang.String message)static PyExceptionOSError(java.io.IOException ioe)static PyExceptionOSError(java.lang.String message)static PyExceptionOSError(jnr.constants.Constant errno)static PyExceptionOSError(jnr.constants.Constant errno, PyObject filename)static PyExceptionOverflowError(java.lang.String message)static voidPendingDeprecationWarning(java.lang.String message)static voidprint(PyObject o)static voidprint(PyObject file, PyObject o)static voidprintComma(PyObject o)static voidprintComma(PyObject file, PyObject o)static voidprintException(java.lang.Throwable t)Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject).static voidprintException(java.lang.Throwable t, PyFrame f)Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject).static voidprintException(java.lang.Throwable t, PyFrame f, PyObject file)Display an exception and stack trace.static voidprintln()static voidprintln(PyObject o)static voidprintln(PyObject file, PyObject o)static voidprintlnv(PyObject file)static voidprintResult(PyObject ret)static booleanpy2boolean(PyObject o)static bytepy2byte(PyObject o)static charpy2char(PyObject o)static charpy2char(PyObject o, java.lang.String msg)static doublepy2double(PyObject o)static floatpy2float(PyObject o)static intpy2int(PyObject o)static intpy2int(PyObject o, java.lang.String msg)static longpy2long(PyObject o)static shortpy2short(PyObject o)static voidpy2void(PyObject o)static PyExceptionReferenceError(java.lang.String message)static PyObjectrunCode(PyCode code, PyObject locals, PyObject globals)static voidrunMain(CodeBootstrap main, java.lang.String[] args)Initializes a default PythonInterpreter and runs the code loaded from theCodeBootstrapas __main__ Called by the code generated inModule.addMain()static voidrunMain(PyRunnable main, java.lang.String[] args)Initializes a default PythonInterpreter and runs the code fromPyRunnable.getMain()as __main__ Called by the code generated inModule.addMain()static PyExceptionRuntimeError(java.lang.String message)static voidRuntimeWarning(java.lang.String message)static voidsaveClassFile(java.lang.String name, java.io.ByteArrayOutputStream bytestream)static PyExceptionsetException(java.lang.Throwable t, PyFrame frame)static voidsetFrame(PyFrame f)static PySystemStatesetSystemState(PySystemState newSystemState)static PyExceptionStopIteration(java.lang.String message)static PyExceptionSyntaxError(java.lang.String message)static voidSyntaxWarning(java.lang.String message)static PyExceptionSystemError(java.lang.String message)static <T> Ttojava(PyObject o, java.lang.Class<T> c)Convert a givenPyObjectto an instance of a Java class.static java.lang.Objecttojava(PyObject o, java.lang.String s)static PyExceptionTypeError(java.lang.String message)static PyExceptionUnboundLocalError(java.lang.String message)static PyExceptionUnicodeDecodeError(java.lang.String encoding, java.lang.String object, int start, int end, java.lang.String reason)static PyExceptionUnicodeEncodeError(java.lang.String encoding, java.lang.String object, int start, int end, java.lang.String reason)static PyExceptionUnicodeError(java.lang.String message)static PyExceptionUnicodeTranslateError(java.lang.String object, int start, int end, java.lang.String reason)static voidUnicodeWarning(java.lang.String message)static PyObject[]unpackSequence(PyObject obj, int length)static voidUserWarning(java.lang.String message)static PyExceptionValueError(java.lang.String message)static voidwarning(PyObject category, java.lang.String message)static voidwarning(PyObject category, java.lang.String message, int stacklevel)static voidwarning(PyObject category, java.lang.String message, java.lang.String filename, int lineno, java.lang.String module, PyObject registry)static voidWarning(java.lang.String message)static voidwarnPy3k(java.lang.String message)static voidwarnPy3k(java.lang.String message, int stacklevel)static voidwriteUnraisable(java.lang.Throwable unraisable, PyObject obj)static PyExceptionZeroDivisionError(java.lang.String message)-
Methods inherited from class org.python.core.PrePy
getCommandResult, getDefaultBinDir, getDefaultExecutableName, getJarFileName, getJarFileNameFromURL, getLoggingLevel, getSystemProperties, getSystemProperty, haveConsole, increaseLoggingLevel, isInteractive, isInteractive, levelFromVerbosity, maybeWrite, setLoggingLevel, verbosityFromLevel, writeComment, writeDebug, writeError, writeMessage, writeWarning
-
-
-
-
Field Detail
-
None
public static final PyObject None
The singleton None Python object
-
Ellipsis
public static final PyObject Ellipsis
The singleton Ellipsis Python object - written as ... when indexing
-
NotImplemented
public static final PyObject NotImplemented
The singleton NotImplemented Python object. Used in rich comparison
-
NoKeywords
public static final java.lang.String[] NoKeywords
A zero-length array of Strings to pass to functions that don't have any keyword arguments
-
EmptyObjects
public static final PyObject[] EmptyObjects
A zero-length array of PyObject's to pass to functions when we have no arguments
-
EmptyFrozenSet
public static final PyFrozenSet EmptyFrozenSet
A frozenset with zero elements
-
EmptyTuple
public static final PyTuple EmptyTuple
A tuple with zero elements
-
Zero
public static final PyInteger Zero
The Python integer 0
-
One
public static final PyInteger One
The Python integer 1
-
False
public static final PyBoolean False
The Python boolean False
-
True
public static final PyBoolean True
The Python boolean True
-
EmptyString
public static final PyString EmptyString
A zero-length Python byte string
-
EmptyUnicode
public static final PyUnicode EmptyUnicode
A zero-length Python Unicode string
-
Newline
public static final PyString Newline
A Python string containing '\n'
-
UnicodeNewline
public static final PyUnicode UnicodeNewline
A Python unicode string containing '\n'
-
Space
public static final PyString Space
A Python string containing ' '
-
UnicodeSpace
public static final PyUnicode UnicodeSpace
A Python unicode string containing ' '
-
TPFLAGS_HEAPTYPE
public static final long TPFLAGS_HEAPTYPE
Set if the type object is dynamically allocated- See Also:
- Constant Field Values
-
TPFLAGS_BASETYPE
public static final long TPFLAGS_BASETYPE
Set if the type allows subclassing- See Also:
- Constant Field Values
-
TPFLAGS_IS_ABSTRACT
public static final long TPFLAGS_IS_ABSTRACT
Type is abstract and cannot be instantiated- See Also:
- Constant Field Values
-
NoConversion
public static final java.lang.Object NoConversion
A unique object to indicate no conversion is possible in __tojava__ methods
-
OSError
public static PyObject OSError
-
NotImplementedError
public static PyObject NotImplementedError
-
EnvironmentError
public static PyObject EnvironmentError
-
OverflowError
public static PyObject OverflowError
-
RuntimeError
public static PyObject RuntimeError
-
KeyboardInterrupt
public static PyObject KeyboardInterrupt
-
FloatingPointError
public static PyObject FloatingPointError
-
SyntaxError
public static PyObject SyntaxError
-
IndentationError
public static PyObject IndentationError
-
TabError
public static PyObject TabError
-
AttributeError
public static PyObject AttributeError
-
IOError
public static PyObject IOError
-
KeyError
public static PyObject KeyError
-
AssertionError
public static PyObject AssertionError
-
TypeError
public static PyObject TypeError
-
ReferenceError
public static PyObject ReferenceError
-
SystemError
public static PyObject SystemError
-
IndexError
public static PyObject IndexError
-
ZeroDivisionError
public static PyObject ZeroDivisionError
-
NameError
public static PyObject NameError
-
UnboundLocalError
public static PyObject UnboundLocalError
-
SystemExit
public static PyObject SystemExit
-
StopIteration
public static PyObject StopIteration
-
GeneratorExit
public static PyObject GeneratorExit
-
ImportError
public static PyObject ImportError
-
ValueError
public static PyObject ValueError
-
UnicodeError
public static PyObject UnicodeError
-
UnicodeTranslateError
public static PyObject UnicodeTranslateError
-
UnicodeDecodeError
public static PyObject UnicodeDecodeError
-
UnicodeEncodeError
public static PyObject UnicodeEncodeError
-
EOFError
public static PyObject EOFError
-
MemoryError
public static PyObject MemoryError
-
BufferError
public static PyObject BufferError
-
ArithmeticError
public static PyObject ArithmeticError
-
LookupError
public static PyObject LookupError
-
StandardError
public static PyObject StandardError
-
Exception
public static PyObject Exception
-
BaseException
public static PyObject BaseException
-
Warning
public static PyObject Warning
-
UserWarning
public static PyObject UserWarning
-
DeprecationWarning
public static PyObject DeprecationWarning
-
PendingDeprecationWarning
public static PyObject PendingDeprecationWarning
-
SyntaxWarning
public static PyObject SyntaxWarning
-
RuntimeWarning
public static PyObject RuntimeWarning
-
FutureWarning
public static PyObject FutureWarning
-
ImportWarning
public static PyObject ImportWarning
-
UnicodeWarning
public static PyObject UnicodeWarning
-
BytesWarning
public static PyObject BytesWarning
-
JavaError
public static PyObject JavaError
-
defaultSystemState
public static volatile PySystemState defaultSystemState
-
stderr
public static StdoutWrapper stderr
-
-
Method Detail
-
OSError
public static PyException OSError(java.lang.String message)
-
OSError
public static PyException OSError(java.io.IOException ioe)
-
OSError
public static PyException OSError(jnr.constants.Constant errno)
-
OSError
public static PyException OSError(jnr.constants.Constant errno, PyObject filename)
-
NotImplementedError
public static PyException NotImplementedError(java.lang.String message)
-
EnvironmentError
public static PyException EnvironmentError(java.lang.String message)
-
OverflowError
public static PyException OverflowError(java.lang.String message)
-
RuntimeError
public static PyException RuntimeError(java.lang.String message)
-
KeyboardInterrupt
public static PyException KeyboardInterrupt(java.lang.String message)
-
FloatingPointError
public static PyException FloatingPointError(java.lang.String message)
-
SyntaxError
public static PyException SyntaxError(java.lang.String message)
-
AttributeError
public static PyException AttributeError(java.lang.String message)
-
IOError
public static PyException IOError(java.io.IOException ioe)
-
IOError
public static PyException IOError(java.lang.String message)
-
IOError
public static PyException IOError(jnr.constants.Constant errno)
-
IOError
public static PyException IOError(jnr.constants.Constant errno, java.lang.String filename)
-
IOError
public static PyException IOError(jnr.constants.Constant errno, PyObject filename)
-
KeyError
public static PyException KeyError(java.lang.String message)
-
KeyError
public static PyException KeyError(PyObject key)
-
AssertionError
public static PyException AssertionError(java.lang.String message)
-
TypeError
public static PyException TypeError(java.lang.String message)
-
ReferenceError
public static PyException ReferenceError(java.lang.String message)
-
SystemError
public static PyException SystemError(java.lang.String message)
-
IndexError
public static PyException IndexError(java.lang.String message)
-
ZeroDivisionError
public static PyException ZeroDivisionError(java.lang.String message)
-
NameError
public static PyException NameError(java.lang.String message)
-
UnboundLocalError
public static PyException UnboundLocalError(java.lang.String message)
-
StopIteration
public static PyException StopIteration(java.lang.String message)
-
GeneratorExit
public static PyException GeneratorExit(java.lang.String message)
-
ImportError
public static PyException ImportError(java.lang.String message)
-
ValueError
public static PyException ValueError(java.lang.String message)
-
UnicodeError
public static PyException UnicodeError(java.lang.String message)
-
UnicodeTranslateError
public static PyException UnicodeTranslateError(java.lang.String object, int start, int end, java.lang.String reason)
-
UnicodeDecodeError
public static PyException UnicodeDecodeError(java.lang.String encoding, java.lang.String object, int start, int end, java.lang.String reason)
-
UnicodeEncodeError
public static PyException UnicodeEncodeError(java.lang.String encoding, java.lang.String object, int start, int end, java.lang.String reason)
-
EOFError
public static PyException EOFError(java.lang.String message)
-
memory_error
public static void memory_error(java.lang.OutOfMemoryError t)
-
MemoryError
public static PyException MemoryError(java.lang.String message)
-
BufferError
public static PyException BufferError(java.lang.String message)
-
Warning
public static void Warning(java.lang.String message)
-
UserWarning
public static void UserWarning(java.lang.String message)
-
DeprecationWarning
public static void DeprecationWarning(java.lang.String message)
-
PendingDeprecationWarning
public static void PendingDeprecationWarning(java.lang.String message)
-
SyntaxWarning
public static void SyntaxWarning(java.lang.String message)
-
RuntimeWarning
public static void RuntimeWarning(java.lang.String message)
-
FutureWarning
public static void FutureWarning(java.lang.String message)
-
ImportWarning
public static void ImportWarning(java.lang.String message)
-
UnicodeWarning
public static void UnicodeWarning(java.lang.String message)
-
BytesWarning
public static void BytesWarning(java.lang.String message)
-
warnPy3k
public static void warnPy3k(java.lang.String message)
-
warnPy3k
public static void warnPy3k(java.lang.String message, int stacklevel)
-
warning
public static void warning(PyObject category, java.lang.String message)
-
warning
public static void warning(PyObject category, java.lang.String message, int stacklevel)
-
warning
public static void warning(PyObject category, java.lang.String message, java.lang.String filename, int lineno, java.lang.String module, PyObject registry)
-
JavaError
public static PyException JavaError(java.lang.Throwable t)
-
tojava
public static <T> T tojava(PyObject o, java.lang.Class<T> c)
Convert a givenPyObjectto an instance of a Java class. Identical too.__tojava__(c)except that it will raise aTypeErrorif the conversion fails.- Parameters:
o- thePyObjectto convert.c- the class to convert it to.
-
tojava
public static java.lang.Object tojava(PyObject o, java.lang.String s)
-
newInteger
public static final PyInteger newInteger(int i)
-
newInteger
public static PyObject newInteger(long i)
-
newLong
public static PyLong newLong(java.lang.String s)
-
newLong
public static PyLong newLong(java.math.BigInteger i)
-
newLong
public static PyLong newLong(int i)
-
newLong
public static PyLong newLong(long l)
-
newImaginary
public static PyComplex newImaginary(double v)
-
newFloat
public static PyFloat newFloat(float v)
-
newFloat
public static PyFloat newFloat(double v)
-
newString
public static PyString newString(char c)
-
newString
public static PyString newString(java.lang.String s)
-
newStringOrUnicode
public static PyString newStringOrUnicode(java.lang.String s)
Return aPyStringfor the given JavaString, if it can be represented as US-ASCII, and aPyUnicodeotherwise.- Parameters:
s- string content- Returns:
PyStringorPyUnicodeaccording to content ofs.
-
newStringOrUnicode
public static PyString newStringOrUnicode(PyObject precedent, java.lang.String s)
Return aPyStringfor the given JavaString, if it can be represented as US-ASCII and if a preceding object is not aPyUnicode, and aPyUnicodeotherwise. In some contexts, we want the result to be aPyUnicodeif some preceding result is aPyUnicode.- Parameters:
precedent- string of which the type sets a precedents- string content- Returns:
PyStringorPyUnicodeaccording to content ofs.
-
newStringUTF8
public static PyString newStringUTF8(java.lang.String s)
-
fileSystemDecode
public static java.lang.String fileSystemDecode(PyString filename)
Return a file name or path as Unicode (Java UTF-16String), decoded if necessary from a Pythonbytesobject, using the file system encoding. In Jython, this encoding is UTF-8, irrespective of the OS platform. This method is comparable with Python 3os.fsdecode, but for Java use, in places such as theosmodule. If the argument is not aPyUnicode, it will be decoded using the nominal Jython file system encoding. If the argument is aPyUnicode, itsStringis returned.- Parameters:
filename- asbytesto decode, or already asunicode- Returns:
- unicode version of path
-
fileSystemDecode
public static java.lang.String fileSystemDecode(PyObject filename)
- Parameters:
filename- asbytesto decode, or already asunicode- Returns:
- unicode version of the file name
-
fileSystemEncode
public static PyString fileSystemEncode(java.lang.String filename)
Return a PyString object we can use as a file name or file path in places where Python expects abytes(that is astr) object in the file system encoding. In Jython, this encoding is UTF-8, irrespective of the OS platform.This is subtly different from CPython's use of "file system encoding", which tracks the platform's choice so that OS services may be called that have a bytes interface. Jython's interaction with the OS occurs via Java using String arguments representing Unicode values, so we have no need to match the encoding actually chosen by the platform (e.g. 'mbcs' on Windows). Rather we need a nominal Jython file system encoding, for use where the standard library forces byte paths on us (in Python 2). There is no reason for this choice to vary with OS platform. Methods receiving paths as
byteswillfileSystemDecode(PyString)them again for Java.- Parameters:
filename- asunicodeto encode, or already asbytes- Returns:
- encoded bytes version of path
-
fileSystemEncode
public static PyString fileSystemEncode(PyString filename)
Return a PyString object we can use as a file name or file path in places where Python expects abytes(that is,str) object in the file system encoding. In Jython, this encoding is UTF-8, irrespective of the OS platform. This method is comparable with Python 3os.fsencode. If the argument is a PyString, it is returned unchanged. If the argument is a PyUnicode, it is converted to abytesusing the nominal Jython file system encoding.- Parameters:
filename- asunicodeto encode, or already asbytes- Returns:
- encoded bytes version of path
-
getenv
public static PyString getenv(PyString name)
The same asgetenv(name, null). Seegetenv(PyString, PyString).
-
getenv
public static PyString getenv(PyString name, PyString defaultValue)
Get the value of the environment variable named fromos.environor return the given default value. Empty string values are treated as undefined for this purpose.- Parameters:
name- of the environment variable.defaultValue- to return ifkeyis not defined (may benull.- Returns:
- the corresponding value or
defaultValue.
-
getenv
public static java.lang.String getenv(java.lang.String name)
The same asgetenv(name, null). Seegetenv(String, String).
-
getenv
public static java.lang.String getenv(java.lang.String name, java.lang.String defaultValue)Get the value of the environment variable named fromos.environor return the given default value. This is a convenience wrapper ongetenv(PyString, PyString)which takes care of the fact that environment variables are FS-encoded.- Parameters:
name- to access in the environment.defaultValue- to return ifkeyis not defined.- Returns:
- the corresponding value or
defaultValue.
-
newStringMap
public static PyStringMap newStringMap()
-
newUnicode
public static PyUnicode newUnicode(char c)
-
newUnicode
public static PyUnicode newUnicode(java.lang.String s)
-
newUnicode
public static PyUnicode newUnicode(java.lang.String s, boolean isBasic)
-
newBoolean
public static PyBoolean newBoolean(boolean t)
-
newDate
public static PyObject newDate(java.sql.Date date)
-
newTime
public static PyObject newTime(java.sql.Time time)
-
newDatetime
public static PyObject newDatetime(java.sql.Timestamp timestamp)
-
newDecimal
public static PyObject newDecimal(java.lang.String decimal)
-
newCode
public static PyCode newCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, java.lang.String[] cellvars, java.lang.String[] freevars, int npurecell, int moreflags)
-
newCode
public static PyCode newCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, java.lang.String[] cellvars, java.lang.String[] freevars, int npurecell, int moreflags)
-
newCode
public static PyCode newCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)
-
newCode
public static PyCode newCode(int argcount, java.lang.String[] varnames, java.lang.String filename, java.lang.String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)
-
newJavaCode
public static PyCode newJavaCode(java.lang.Class<?> cls, java.lang.String name)
-
newJavaFunc
public static PyObject newJavaFunc(java.lang.Class<?> cls, java.lang.String name)
-
initPython
public static boolean initPython()
-
findClass
public static java.lang.Class<?> findClass(java.lang.String name)
Find and load a Java class by name.- Parameters:
name- of the Java class.- Returns:
- the class, or
nullif it wasn't found or something went wrong
-
findClassEx
public static java.lang.Class<?> findClassEx(java.lang.String name, java.lang.String reason) throws PyExceptionFind and load a Java class by name.- Parameters:
name- Name of the Java class.reason- for finding the class. Used in debugging messages.- Returns:
- the class, or
nullif it simply wasn't found - Throws:
PyException-JavaErrorwrapping errors occurring when the class is found but cannot be loaded.
-
initProxy
public static void initProxy(PyProxy proxy, java.lang.String module, java.lang.String pyclass, java.lang.Object[] args)
-
runMain
public static void runMain(PyRunnable main, java.lang.String[] args) throws java.lang.Exception
Initializes a default PythonInterpreter and runs the code fromPyRunnable.getMain()as __main__ Called by the code generated inModule.addMain()- Throws:
java.lang.Exception
-
runMain
public static void runMain(CodeBootstrap main, java.lang.String[] args) throws java.lang.Exception
Initializes a default PythonInterpreter and runs the code loaded from theCodeBootstrapas __main__ Called by the code generated inModule.addMain()- Throws:
java.lang.Exception
-
printException
public static void printException(java.lang.Throwable t)
Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject).- Parameters:
t- to display
-
printException
public static void printException(java.lang.Throwable t, PyFrame f)Display an exception and stack trace throughprintException(Throwable, PyFrame, PyObject).- Parameters:
t- to displayf- frame at which to start the stack trace
-
printException
public static void printException(java.lang.Throwable t, PyFrame f, PyObject file)Display an exception and stack trace. If the exception wasSystemExitandOptions.inspect==false, this will exit the JVM.- Parameters:
t- to displayf- frame at which to start the stack tracefile- output onto this stream orstderrifnull
-
displayException
public static void displayException(PyObject type, PyObject value, PyObject tb, PyObject file)
Print the description of an exception as a big string. The arguments are closely equivalent to the tuple returned by Pythonsys.exc_info, on standard error or a given byte-oriented file. Compare with Pythontraceback.print_exception.- Parameters:
type- of exceptionvalue- the exception parameter (second argument toraise)tb- traceback of the call stack where the exception originally occurredfile- to print encoded string to, or null meaning standard error
-
formatException
public static java.lang.String formatException(PyObject type, PyObject value, boolean useRepr)
-
writeUnraisable
public static void writeUnraisable(java.lang.Throwable unraisable, PyObject obj)
-
assert_
public static void assert_(PyObject test)
-
addTraceback
public static void addTraceback(java.lang.Throwable t, PyFrame frame)
-
setException
public static PyException setException(java.lang.Throwable t, PyFrame frame)
-
matchException
@Deprecated public static boolean matchException(PyException pye, PyObject exc)
Deprecated.As of Jython 2.5, usePyException.match(org.python.core.PyObject)instead.
-
makeException
public static PyException makeException(PyObject type, PyObject value, PyObject traceback)
-
makeException
public static PyException makeException(PyObject type, PyObject value)
-
makeException
public static PyException makeException(PyObject type)
-
makeException
public static PyException makeException()
-
getThreadState
public static final ThreadState getThreadState()
-
getThreadState
public static final ThreadState getThreadState(PySystemState newSystemState)
-
setSystemState
public static final PySystemState setSystemState(PySystemState newSystemState)
-
getSystemState
public static final PySystemState getSystemState()
-
getFrame
public static PyFrame getFrame()
-
setFrame
public static void setFrame(PyFrame f)
-
getConsole
public static Console getConsole()
Get the Jython Console (used forinput(),raw_input(), etc.) as constructed and set byPySystemStateinitialization.- Returns:
- the Jython Console
-
installConsole
public static void installConsole(Console console) throws java.lang.UnsupportedOperationException, java.io.IOException
Install the provided Console, first uninstalling any current one. The Jython Console is used forraw_input()etc., and may provide line-editing and history recall at the prompt. A Console may replaceSystem.inwith its line-editing input method.- Parameters:
console- The new Console object- Throws:
java.lang.UnsupportedOperationException- if some prior Console refuses to uninstalljava.io.IOException- ifConsole.install()raises it
-
importSiteIfSelected
public static boolean importSiteIfSelected()
-
printlnv
public static void printlnv(PyObject file)
-
print
public static void print(PyObject o)
-
printComma
public static void printComma(PyObject o)
-
println
public static void println(PyObject o)
-
println
public static void println()
-
flushLine
public static void flushLine()
-
py2boolean
public static boolean py2boolean(PyObject o)
-
py2byte
public static byte py2byte(PyObject o)
-
py2short
public static short py2short(PyObject o)
-
py2int
public static int py2int(PyObject o)
-
py2int
public static int py2int(PyObject o, java.lang.String msg)
-
py2long
public static long py2long(PyObject o)
-
py2float
public static float py2float(PyObject o)
-
py2double
public static double py2double(PyObject o)
-
py2char
public static char py2char(PyObject o)
-
py2char
public static char py2char(PyObject o, java.lang.String msg)
-
py2void
public static void py2void(PyObject o)
-
makeCharacter
public static final PyString makeCharacter(java.lang.Character o)
-
makeCharacter
public static final PyString makeCharacter(char c)
-
java2py
public static PyObject java2py(java.lang.Object o)
Uses the PyObjectAdapter passed toPySystemState.initialize()to turn o into a PyObject.- See Also:
- default PyObjectAdapter type
-
javas2pys
public static PyObject[] javas2pys(java.lang.Object... objects)
Uses the PyObjectAdapter passed toPySystemState.initialize()to turnobjectsinto an array of PyObjects.- See Also:
- default PyObjectAdapter type
-
getAdapter
public static ExtensiblePyObjectAdapter getAdapter()
- Returns:
- the ExtensiblePyObjectAdapter used by java2py.
-
makeClass
public static PyObject makeClass(java.lang.String name, PyObject[] bases, PyCode code, PyObject[] closure_cells)
-
makeClass
public static PyObject makeClass(java.lang.String name, PyObject[] bases, PyObject dict)
Create a new Python class.- Parameters:
name- the String name of the classbases- an array of PyObject base classesdict- the class's namespace, containing the class body definition- Returns:
- a new Python Class PyObject
-
getName
public static java.lang.String getName()
-
getCompilerFlags
public static CompilerFlags getCompilerFlags()
-
getCompilerFlags
public static CompilerFlags getCompilerFlags(int flags, boolean dont_inherit)
-
getCompilerFlags
public static CompilerFlags getCompilerFlags(CompilerFlags flags, boolean dont_inherit)
-
compile
public static PyCode compile(java.io.InputStream istream, java.lang.String filename, CompileMode kind)
-
compile_flags
public static PyCode compile_flags(org.python.antlr.base.mod node, java.lang.String name, java.lang.String filename, boolean linenumbers, boolean printResults, CompilerFlags cflags)
Entry point for compiling modules.- Parameters:
node- Module node, coming from the parsing processname- Internal name for the compiled code. Typically generated by callinggetName().filename- Source file namelinenumbers- True to track source line numbers on the generated codeprintResults- True to call the sys.displayhook on the result of the codecflags- Compiler flags- Returns:
- Code object for the compiled module
-
compile_flags
public static PyCode compile_flags(org.python.antlr.base.mod node, java.lang.String filename, CompileMode kind, CompilerFlags cflags)
-
compile_flags
public static PyCode compile_flags(java.io.InputStream istream, java.lang.String filename, CompileMode kind, CompilerFlags cflags)
Compiles python source code coming from a file or another external stream
-
compile_flags
public static PyCode compile_flags(java.lang.String data, java.lang.String filename, CompileMode kind, CompilerFlags cflags)
Compiles python source code coming from String (raw bytes) data. If the String is properly decoded (from PyUnicode) the PyCF_SOURCE_IS_UTF8 flag should be specified.
-
compile_command_flags
public static PyObject compile_command_flags(java.lang.String string, java.lang.String filename, CompileMode kind, CompilerFlags cflags, boolean stdprompt)
-
id
public static long id(PyObject o)
-
idstr
public static java.lang.String idstr(PyObject o)
-
java_obj_id
public static long java_obj_id(java.lang.Object o)
-
printResult
public static void printResult(PyObject ret)
-
saveClassFile
public static void saveClassFile(java.lang.String name, java.io.ByteArrayOutputStream bytestream)
-
javaPyClass
public static PyObject javaPyClass(PyObject cls, java.lang.Class<?> interfce)
Returns a Python-class that extendsclsandinterfce. Ifclsalready extendsinterfce, simplyclsis returned. Otherwise a new class is created (if not yet cached). It caches such classes and only creates a new one if no appropriate class was cached yet.- Returns:
- a Python-class that extends
clsandinterfce
-
newJ
public static <T> T newJ(PyObject cls, java.lang.Class<T> jcls, java.lang.Object... args)
This method is a compact helper to access Python-constructors from Java. It creates an instance ofclsand retruns it in form ofjcls, which must be an interface. This method even works ifclsdoes not extendjclsin Python-code. In that case, it usesjavaPyClass(PyObject, Class)to create an appropriate class on the fly.It automatically converts
argstoPyObjects.
For keyword-support usenewJ(PyObject, Class, String[], Object...).- Parameters:
cls- - the class to be instanciatedjcls- - the Java-type to be returnedargs- are automatically converted to Jython-PyObjects- Returns:
- an instance of cls in form of the interface jcls
- See Also:
newJ(PyObject, Class, PyObject[], String[]),newJ(PyObject, Class, String[], Object...),newJ(PyModule, Class, Object...),newJ(PyModule, Class, String[], Object...),PyModule.newJ(Class, Object...),PyModule.newJ(Class, String[], Object...)
-
newJ
public static <T> T newJ(PyObject cls, java.lang.Class<T> jcls, PyObject[] args, java.lang.String[] keywords)
This method is a compact helper to access Python-constructors from Java. It creates an instance ofclsand retruns it in form ofjcls, which must be an interface. This method even works ifclsdoes not extendjclsin Python-code. In that case, it usesjavaPyClass(PyObject, Class)to create an appropriate class on the fly.keywordssare applied to the lastargsin the list.- Parameters:
cls- - the class to be instanciatedjcls- - the Java-type to be returnedkeywords- are applied to the last argsargs- for the Python-class constructor- Returns:
- an instance of cls in form of the interface jcls
- See Also:
newJ(PyObject, Class, Object...),newJ(PyObject, Class, String[], Object...),newJ(PyModule, Class, Object...),newJ(PyModule, Class, String[], Object...),PyModule.newJ(Class, Object...),PyModule.newJ(Class, String[], Object...)
-
newJ
public static <T> T newJ(PyObject cls, java.lang.Class<T> jcls, java.lang.String[] keywords, java.lang.Object... args)
This method is a compact helper to access Python-constructors from Java. It creates an instance ofclsand retruns it in form ofjcls, which must be an interface. This method even works ifclsdoes not extendjclsin Python-code. In that case, it usesjavaPyClass(PyObject, Class)to create an appropriate class on the fly.It automatically converts
argstoPyObjects.
keywordssare applied to the lastargsin the list.- Parameters:
cls- - the class to be instanciatedjcls- - the Java-type to be returnedkeywords- are applied to the last argsargs- are automatically converted to Jython-PyObjects- Returns:
- an instance of cls in form of the interface jcls
- See Also:
newJ(PyObject, Class, PyObject[], String[]),newJ(PyObject, Class, Object...),newJ(PyModule, Class, Object...),newJ(PyModule, Class, String[], Object...),PyModule.newJ(Class, Object...),PyModule.newJ(Class, String[], Object...)
-
newJ
public static <T> T newJ(PyModule module, java.lang.Class<T> jcls, java.lang.Object... args)
Works likenewJ(PyObject, Class, Object...), but looks up the Python-class in the module-dict using the interface-name, i.e.jcls.getSimpleName().For keywords-support use
newJ(PyModule, Class, String[], Object...).- Parameters:
module- the module containing the desired classjcls- Java-type of the desired clas, must have the same nameargs- constructor-arguments- Returns:
- a new instance of the desired class
- See Also:
newJ(PyModule, Class, String[], Object...),newJ(PyObject, Class, PyObject[], String[]),newJ(PyObject, Class, Object...),newJ(PyObject, Class, String[], Object...),PyModule.newJ(Class, Object...),PyModule.newJ(Class, String[], Object...)
-
newJ
public static <T> T newJ(PyModule module, java.lang.Class<T> jcls, java.lang.String[] keywords, java.lang.Object... args)
Works likenewJ(PyObject, Class, String[], Object...), but looks up the Python-class in the module-dict using the interface-name, i.e.jcls.getSimpleName().keywordssare applied to the lastargsin the list.- Parameters:
module- the module containing the desired classjcls- Java-type of the desired class, must have the same namekeywords- are applied to the lastargsin the listargs- constructor-arguments- Returns:
- a new instance of the desired class
- See Also:
newJ(PyModule, Class, Object...),newJ(PyObject, Class, PyObject[], String[]),newJ(PyObject, Class, Object...),newJ(PyObject, Class, String[], Object...),PyModule.newJ(Class, Object...),PyModule.newJ(Class, String[], Object...)
-
-