public final class Py extends Object
Modifier and Type | Field and Description |
---|---|
static PyObject |
ArithmeticError |
static PyObject |
AssertionError |
static PyObject |
AttributeError |
static PyObject |
BaseException |
static PyObject |
BufferError |
static PyObject |
BytesWarning |
static int |
COMMENT |
static int |
DEBUG |
static PySystemState |
defaultSystemState |
static PyObject |
DeprecationWarning |
static PyObject |
Ellipsis
The singleton Ellipsis Python object - written as ... when indexing
|
static PyFrozenSet |
EmptyFrozenSet
A frozenset with zero elements
|
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 byte string
|
static PyTuple |
EmptyTuple
A tuple with zero elements
|
static PyUnicode |
EmptyUnicode
A zero-length Python Unicode string
|
static PyObject |
EnvironmentError |
static PyObject |
EOFError |
static int |
ERROR |
static PyObject |
Exception |
static PyBoolean |
False
The Python boolean False
|
static PyObject |
FloatingPointError |
static PyObject |
FutureWarning |
static PyObject |
GeneratorExit |
static PyObject |
ImportError |
static PyObject |
ImportWarning |
static PyObject |
IndentationError |
static PyObject |
IndexError |
static PyObject |
IOError |
static PyObject |
JavaError |
static PyObject |
KeyboardInterrupt |
static PyObject |
KeyError |
static PyObject |
LookupError |
static PyObject |
MemoryError |
static int |
MESSAGE |
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 PyInteger |
One
The Python integer 1
|
static PyObject |
OSError |
static PyObject |
OverflowError |
static PyObject |
PendingDeprecationWarning |
static PyObject |
ReferenceError |
static PyObject |
RuntimeError |
static PyObject |
RuntimeWarning |
static PyString |
Space
A Python string containing ' '
|
static PyObject |
StandardError |
static StdoutWrapper |
stderr |
static PyObject |
StopIteration |
static PyObject |
SyntaxError |
static PyObject |
SyntaxWarning |
static PyObject |
SystemError |
static PyObject |
SystemExit |
static PyObject |
TabError |
static long |
TPFLAGS_BASETYPE
Set if the type allows subclassing
|
static long |
TPFLAGS_HEAPTYPE
Set if the type object is dynamically allocated
|
static long |
TPFLAGS_IS_ABSTRACT
Type is abstract and cannot be instantiated
|
static PyBoolean |
True
The Python boolean True
|
static PyObject |
TypeError |
static PyObject |
UnboundLocalError |
static PyObject |
UnicodeDecodeError |
static PyObject |
UnicodeEncodeError |
static PyObject |
UnicodeError |
static PyUnicode |
UnicodeNewline
A Python unicode string containing '\n'
|
static PyUnicode |
UnicodeSpace
A Python unicode string containing ' '
|
static PyObject |
UnicodeTranslateError |
static PyObject |
UnicodeWarning |
static PyObject |
UserWarning |
static PyObject |
ValueError |
static PyObject |
Warning |
static int |
WARNING |
static PyInteger |
Zero
The Python integer 0
|
static PyObject |
ZeroDivisionError |
Modifier and Type | Method and Description |
---|---|
static String |
_getJarFileName()
Utility-method to obtain the name (including absolute path) of the currently used
jython-jar-file.
|
static void |
addTraceback(Throwable t,
PyFrame frame) |
static void |
assert_(PyObject test) |
static void |
assert_(PyObject test,
PyObject message) |
static PyException |
AssertionError(String message) |
static PyException |
AttributeError(String message) |
static PyException |
BufferError(String message) |
static void |
BytesWarning(String message) |
static PyObject |
compile_command_flags(String string,
String filename,
CompileMode kind,
CompilerFlags cflags,
boolean stdprompt) |
static PyCode |
compile_flags(InputStream istream,
String filename,
CompileMode kind,
CompilerFlags cflags)
Compiles python source code coming from a file or another external stream
|
static PyCode |
compile_flags(org.python.antlr.base.mod node,
String filename,
CompileMode kind,
CompilerFlags cflags) |
static PyCode |
compile_flags(org.python.antlr.base.mod node,
String name,
String filename,
boolean linenumbers,
boolean printResults,
CompilerFlags cflags)
Entry point for compiling modules.
|
static PyCode |
compile_flags(String data,
String filename,
CompileMode kind,
CompilerFlags cflags)
Compiles python source code coming from String (raw bytes) data.
|
static PyCode |
compile(InputStream istream,
String filename,
CompileMode kind) |
static void |
DeprecationWarning(String message) |
static void |
displayException(PyObject type,
PyObject value,
PyObject tb,
PyObject file) |
static PyException |
EnvironmentError(String message) |
static PyException |
EOFError(String message) |
static void |
exec(PyObject o,
PyObject globals,
PyObject locals) |
static Class<?> |
findClass(String name)
Tries to find a Java class.
|
static Class<?> |
findClassEx(String name,
String reason)
Tries to find a Java class.
|
static PyException |
FloatingPointError(String message) |
static void |
flushLine() |
static String |
formatException(PyObject type,
PyObject value) |
static String |
formatException(PyObject type,
PyObject value,
boolean useRepr) |
static void |
FutureWarning(String message) |
static PyException |
GeneratorExit(String message) |
static ExtensiblePyObjectAdapter |
getAdapter() |
static CompilerFlags |
getCompilerFlags() |
static CompilerFlags |
getCompilerFlags(CompilerFlags flags,
boolean dont_inherit) |
static CompilerFlags |
getCompilerFlags(int flags,
boolean dont_inherit) |
static Console |
getConsole()
Get the Jython Console (used for
input() , raw_input() , etc.) as
constructed and set by PySystemState initialization. |
static String |
getDefaultBinDir()
Infers the usual Jython bin-dir from the position of the jar-file
returned by
getJarFileName() byr replacing the file name
with "bin". |
static String |
getDefaultExecutableName()
Infers the usual Jython executable name from the position of the
jar-file returned by
getJarFileName() by replacing the
file name with "bin/jython". |
static PyFrame |
getFrame() |
static String |
getJarFileName()
Utility-method to obtain the name (including absolute path) of the currently used
jython-jar-file.
|
static String |
getJarFileNameFromURL(URL url)
Converts a url that points to a jar-file to the actual jar-file name.
|
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 PyException |
ImportError(String message) |
static boolean |
importSiteIfSelected() |
static void |
ImportWarning(String message) |
static PyException |
IndexError(String message) |
static void |
initProxy(PyProxy proxy,
String module,
String pyclass,
Object[] args) |
static boolean |
initPython() |
static void |
installConsole(Console console)
Install the provided Console, first uninstalling any current one.
|
static PyException |
IOError(jnr.constants.Constant errno) |
static PyException |
IOError(jnr.constants.Constant errno,
PyObject filename) |
static PyException |
IOError(IOException ioe) |
static PyException |
IOError(String message) |
static boolean |
isInstance(PyObject inst,
PyObject cls) |
static boolean |
isInteractive()
Check (using the
POSIX library and jnr-posix library) whether we are in
an interactive environment. |
static boolean |
isSubClass(PyObject derived,
PyObject cls) |
static PyObject |
iter(PyObject seq,
String message) |
static long |
java_obj_id(Object o) |
static PyObject |
java2py(Object o)
Uses the PyObjectAdapter passed to
PySystemState.initialize() to turn o into a PyObject. |
static PyException |
JavaError(Throwable t) |
static PyObject |
javaPyClass(PyObject cls,
Class<?> interfce)
Returns a Python-class that extends
cls and interfce . |
static PyObject[] |
javas2pys(Object... objects)
Uses the PyObjectAdapter passed to
PySystemState.initialize() to turn
objects into an array of PyObjects. |
static PyException |
KeyboardInterrupt(String message) |
static PyException |
KeyError(PyObject key) |
static PyException |
KeyError(String message) |
static PyString |
makeCharacter(char c) |
static PyString |
makeCharacter(Character o) |
static PyObject |
makeClass(String name,
PyObject[] bases,
PyCode code) |
static PyObject |
makeClass(String name,
PyObject[] bases,
PyCode code,
PyObject[] closure_cells) |
static PyObject |
makeClass(String name,
PyObject[] bases,
PyObject dict)
Create a new Python class.
|
static PyObject |
makeClass(String name,
PyObject base,
PyObject dict) |
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 exc)
Deprecated.
As of Jython 2.5, use
PyException.match(org.python.core.PyObject) instead. |
static void |
maybeWrite(String type,
String msg,
int level) |
static void |
memory_error(OutOfMemoryError t) |
static PyException |
MemoryError(String message) |
static PyException |
NameError(String message) |
static PyBoolean |
newBoolean(boolean t) |
static PyCode |
newCode(int argcount,
String[] varnames,
String filename,
String name,
boolean args,
boolean keywords,
PyFunctionTable funcs,
int func_id) |
static PyCode |
newCode(int argcount,
String[] 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,
String[] varnames,
String filename,
String name,
int firstlineno,
boolean args,
boolean keywords,
PyFunctionTable funcs,
int func_id) |
static PyCode |
newCode(int argcount,
String[] 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 PyObject |
newDate(Date date) |
static PyObject |
newDatetime(Timestamp timestamp) |
static PyObject |
newDecimal(String decimal) |
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 <T> T |
newJavaObject(PyModule module,
Class<T> jcls,
Object... args)
Works like
newJavaObject(PyObject, Class, Object...) , but looks
up the Python-class in the module-dict using the interface-name, i.e. |
static <T> T |
newJavaObject(PyModule module,
Class<T> jcls,
String[] keywords,
Object... args)
Works like
newJavaObject(PyObject, Class, String[], Object...) , but looks
up the Python-class in the module-dict using the interface-name, i.e. |
static <T> T |
newJavaObject(PyObject cls,
Class<T> jcls,
Object... args)
This method is a compact helper to access Python-constructors from Java.
|
static <T> T |
newJavaObject(PyObject cls,
Class<T> jcls,
PyObject[] args,
String[] keywords)
This method is a compact helper to access Python-constructors from Java.
|
static <T> T |
newJavaObject(PyObject cls,
Class<T> jcls,
String[] keywords,
Object... args)
This method is a compact helper to access Python-constructors from Java.
|
static PyLong |
newLong(BigInteger i) |
static PyLong |
newLong(int i) |
static PyLong |
newLong(long l) |
static PyLong |
newLong(String s) |
static PyString |
newString(char c) |
static PyString |
newString(String s) |
static PyStringMap |
newStringMap() |
static PyString |
newStringOrUnicode(PyObject kind,
String s) |
static PyString |
newStringOrUnicode(String s) |
static PyString |
newStringUTF8(String s) |
static PyObject |
newTime(Time time) |
static PyUnicode |
newUnicode(char c) |
static PyUnicode |
newUnicode(String s) |
static PyUnicode |
newUnicode(String s,
boolean isBasic) |
static PyException |
NotImplementedError(String message) |
static PyException |
OSError(jnr.constants.Constant errno) |
static PyException |
OSError(jnr.constants.Constant errno,
PyObject filename) |
static PyException |
OSError(IOException ioe) |
static PyException |
OSError(String message) |
static PyException |
OverflowError(String message) |
static void |
PendingDeprecationWarning(String message) |
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 |
println() |
static void |
println(PyObject o) |
static void |
println(PyObject file,
PyObject o) |
static void |
printlnv(PyObject file) |
static void |
printResult(PyObject ret) |
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 PyException |
ReferenceError(String message) |
static PyObject |
runCode(PyCode code,
PyObject locals,
PyObject globals) |
static void |
runMain(CodeBootstrap main,
String[] args)
Initializes a default PythonInterpreter and runs the code loaded from the
CodeBootstrap as __main__ Called by the code generated in
Module.addMain() |
static void |
runMain(PyRunnable main,
String[] args)
Initializes a default PythonInterpreter and runs the code from
PyRunnable.getMain() as __main__
Called by the code generated in Module.addMain() |
static PyException |
RuntimeError(String message) |
static void |
RuntimeWarning(String message) |
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 PyException |
StopIteration(String message) |
static PyException |
SyntaxError(String message) |
static void |
SyntaxWarning(String message) |
static PyException |
SystemError(String message) |
static <T> T |
tojava(PyObject o,
Class<T> c)
Convert a given
PyObject to an instance of a Java class. |
static Object |
tojava(PyObject o,
String s) |
static PyException |
TypeError(String message) |
static PyException |
UnboundLocalError(String message) |
static PyException |
UnicodeDecodeError(String encoding,
String object,
int start,
int end,
String reason) |
static PyException |
UnicodeEncodeError(String encoding,
String object,
int start,
int end,
String reason) |
static PyException |
UnicodeError(String message) |
static PyException |
UnicodeTranslateError(String object,
int start,
int end,
String reason) |
static void |
UnicodeWarning(String message) |
static PyObject[] |
unpackSequence(PyObject obj,
int length) |
static void |
UserWarning(String message) |
static PyException |
ValueError(String message) |
static void |
warning(PyObject category,
String message) |
static void |
warning(PyObject category,
String message,
int stacklevel) |
static void |
warning(PyObject category,
String message,
String filename,
int lineno,
String module,
PyObject registry) |
static void |
Warning(String message) |
static void |
warnPy3k(String message) |
static void |
warnPy3k(String message,
int stacklevel) |
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 |
writeUnraisable(Throwable unraisable,
PyObject obj) |
static void |
writeWarning(String type,
String msg) |
static PyException |
ZeroDivisionError(String message) |
public static final PyObject None
public static final PyObject Ellipsis
public static final PyObject NotImplemented
public static final String[] NoKeywords
public static final PyObject[] EmptyObjects
public static final PyFrozenSet EmptyFrozenSet
public static final PyTuple EmptyTuple
public static final PyInteger Zero
public static final PyInteger One
public static final PyBoolean False
public static final PyBoolean True
public static final PyString EmptyString
public static final PyUnicode EmptyUnicode
public static final PyString Newline
public static final PyUnicode UnicodeNewline
public static final PyString Space
public static final PyUnicode UnicodeSpace
public static final long TPFLAGS_HEAPTYPE
public static final long TPFLAGS_BASETYPE
public static final long TPFLAGS_IS_ABSTRACT
public static final Object NoConversion
public static PyObject OSError
public static PyObject NotImplementedError
public static PyObject EnvironmentError
public static PyObject OverflowError
public static PyObject RuntimeError
public static PyObject KeyboardInterrupt
public static PyObject FloatingPointError
public static PyObject SyntaxError
public static PyObject IndentationError
public static PyObject TabError
public static PyObject AttributeError
public static PyObject IOError
public static PyObject KeyError
public static PyObject AssertionError
public static PyObject TypeError
public static PyObject ReferenceError
public static PyObject SystemError
public static PyObject IndexError
public static PyObject ZeroDivisionError
public static PyObject NameError
public static PyObject UnboundLocalError
public static PyObject SystemExit
public static PyObject StopIteration
public static PyObject GeneratorExit
public static PyObject ImportError
public static PyObject ValueError
public static PyObject UnicodeError
public static PyObject UnicodeTranslateError
public static PyObject UnicodeDecodeError
public static PyObject UnicodeEncodeError
public static PyObject EOFError
public static PyObject MemoryError
public static PyObject BufferError
public static PyObject ArithmeticError
public static PyObject LookupError
public static PyObject StandardError
public static PyObject Exception
public static PyObject BaseException
public static PyObject Warning
public static PyObject UserWarning
public static PyObject DeprecationWarning
public static PyObject PendingDeprecationWarning
public static PyObject SyntaxWarning
public static PyObject RuntimeWarning
public static PyObject FutureWarning
public static PyObject ImportWarning
public static PyObject UnicodeWarning
public static PyObject BytesWarning
public static PyObject JavaError
public static volatile PySystemState defaultSystemState
public static StdoutWrapper stderr
public static final int ERROR
public static final int WARNING
public static final int MESSAGE
public static final int COMMENT
public static final int DEBUG
public static PyException OSError(String message)
public static PyException OSError(IOException ioe)
public static PyException OSError(jnr.constants.Constant errno)
public static PyException OSError(jnr.constants.Constant errno, PyObject filename)
public static PyException NotImplementedError(String message)
public static PyException EnvironmentError(String message)
public static PyException OverflowError(String message)
public static PyException RuntimeError(String message)
public static PyException KeyboardInterrupt(String message)
public static PyException FloatingPointError(String message)
public static PyException SyntaxError(String message)
public static PyException AttributeError(String message)
public static PyException IOError(IOException ioe)
public static PyException IOError(String message)
public static PyException IOError(jnr.constants.Constant errno)
public static PyException IOError(jnr.constants.Constant errno, PyObject filename)
public static PyException KeyError(String message)
public static PyException KeyError(PyObject key)
public static PyException AssertionError(String message)
public static PyException TypeError(String message)
public static PyException ReferenceError(String message)
public static PyException SystemError(String message)
public static PyException IndexError(String message)
public static PyException ZeroDivisionError(String message)
public static PyException NameError(String message)
public static PyException UnboundLocalError(String message)
public static PyException StopIteration(String message)
public static PyException GeneratorExit(String message)
public static PyException ImportError(String message)
public static PyException ValueError(String message)
public static PyException UnicodeError(String message)
public static PyException UnicodeTranslateError(String object, int start, int end, String reason)
public static PyException UnicodeDecodeError(String encoding, String object, int start, int end, String reason)
public static PyException UnicodeEncodeError(String encoding, String object, int start, int end, String reason)
public static PyException EOFError(String message)
public static void memory_error(OutOfMemoryError t)
public static PyException MemoryError(String message)
public static PyException BufferError(String message)
public static void Warning(String message)
public static void UserWarning(String message)
public static void DeprecationWarning(String message)
public static void PendingDeprecationWarning(String message)
public static void SyntaxWarning(String message)
public static void RuntimeWarning(String message)
public static void FutureWarning(String message)
public static void ImportWarning(String message)
public static void UnicodeWarning(String message)
public static void BytesWarning(String message)
public static void warnPy3k(String message)
public static void warnPy3k(String message, int stacklevel)
public static void warning(PyObject category, String message, String filename, int lineno, String module, PyObject registry)
public static PyException JavaError(Throwable t)
public static <T> T tojava(PyObject o, Class<T> c)
PyObject
to an instance of a Java class.
Identical to o.__tojava__(c)
except that it will
raise a TypeError
if the conversion fails.o
- the PyObject
to convert.c
- the class to convert it to.public static final PyInteger newInteger(int i)
public static PyObject newInteger(long i)
public static PyLong newLong(BigInteger i)
public static PyLong newLong(int i)
public static PyLong newLong(long l)
public static PyComplex newImaginary(double v)
public static PyFloat newFloat(float v)
public static PyFloat newFloat(double v)
public static PyString newString(char c)
public static PyStringMap newStringMap()
public static PyUnicode newUnicode(char c)
public static PyBoolean newBoolean(boolean t)
public static PyCode newCode(int argcount, String[] varnames, String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags)
public static PyCode newCode(int argcount, String[] varnames, String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id, String[] cellvars, String[] freevars, int npurecell, int moreflags)
public static PyCode newCode(int argcount, String[] varnames, String filename, String name, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)
public static PyCode newCode(int argcount, String[] varnames, String filename, String name, int firstlineno, boolean args, boolean keywords, PyFunctionTable funcs, int func_id)
public static boolean initPython()
public static Class<?> findClass(String name)
name
- Name of the Java class.public static Class<?> findClassEx(String name, String reason)
findClass(String)
, it raises a JavaError
if the class was found but there were problems loading it.name
- Name of the Java class.reason
- Reason for finding the class. Used for debugging messages.JavaError
- wrapping LinkageErrors/IllegalArgumentExceptions
occurred when the class is found but can't be loaded.public static void runMain(PyRunnable main, String[] args) throws Exception
PyRunnable.getMain()
as __main__
Called by the code generated in Module.addMain()
Exception
public static void runMain(CodeBootstrap main, String[] args) throws Exception
CodeBootstrap
as __main__ Called by the code generated in
Module.addMain()
Exception
public static void printException(Throwable t)
public static void displayException(PyObject type, PyObject value, PyObject tb, PyObject file)
public static String formatException(PyObject type, PyObject value, boolean useRepr)
public static void assert_(PyObject test)
public static PyException setException(Throwable t, PyFrame frame)
@Deprecated public static boolean matchException(PyException pye, PyObject exc)
PyException.match(org.python.core.PyObject)
instead.public static PyException makeException(PyObject type, PyObject value, PyObject traceback)
public static PyException makeException(PyObject type, PyObject value)
public static PyException makeException(PyObject type)
public static PyException makeException()
public static final ThreadState getThreadState()
public static final ThreadState getThreadState(PySystemState newSystemState)
public static final PySystemState setSystemState(PySystemState newSystemState)
public static final PySystemState getSystemState()
public static PyFrame getFrame()
public static void setFrame(PyFrame f)
public static Console getConsole()
input()
, raw_input()
, etc.) as
constructed and set by PySystemState
initialization.public static void installConsole(Console console) throws UnsupportedOperationException, IOException
raw_input()
etc., and may provide line-editing and history recall at the
prompt. A Console may replace System.in
with its line-editing input method.console
- The new Console objectUnsupportedOperationException
- if some prior Console refuses to uninstallIOException
- if Console.install()
raises itpublic static boolean isInteractive()
POSIX
library and jnr-posix
library) whether we are in
an interactive environment. Amongst other things, this affects the type of console that may
be legitimately installed during system initialisation. Note that the result may vary
according to whether a jnr-posix
native library is found along
java.library.path
, or the pure Java fall-back is used.public static boolean importSiteIfSelected()
public static void printlnv(PyObject file)
public static void print(PyObject o)
public static void printComma(PyObject o)
public static void println(PyObject o)
public static void println()
public static void flushLine()
public static boolean py2boolean(PyObject o)
public static byte py2byte(PyObject o)
public static short py2short(PyObject o)
public static int py2int(PyObject o)
public static long py2long(PyObject o)
public static float py2float(PyObject o)
public static double py2double(PyObject o)
public static char py2char(PyObject o)
public static void py2void(PyObject o)
public static final PyString makeCharacter(char c)
public static PyObject java2py(Object o)
PySystemState.initialize()
to turn o into a PyObject.- default PyObjectAdapter type
public static PyObject[] javas2pys(Object... objects)
PySystemState.initialize()
to turn
objects
into an array of PyObjects.- default PyObjectAdapter type
public static ExtensiblePyObjectAdapter getAdapter()
public static PyObject makeClass(String name, PyObject[] bases, PyCode code, PyObject[] closure_cells)
public static PyObject makeClass(String name, PyObject[] bases, PyObject dict)
name
- the String name of the classbases
- an array of PyObject base classesdict
- the class's namespace, containing the class body
definitionpublic static String getName()
public static CompilerFlags getCompilerFlags()
public static CompilerFlags getCompilerFlags(int flags, boolean dont_inherit)
public static CompilerFlags getCompilerFlags(CompilerFlags flags, boolean dont_inherit)
public static PyCode compile(InputStream istream, String filename, CompileMode kind)
public static PyCode compile_flags(org.python.antlr.base.mod node, String name, String filename, boolean linenumbers, boolean printResults, CompilerFlags cflags)
node
- Module node, coming from the parsing processname
- Internal name for the compiled code. Typically generated by
calling getName()
.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 flagspublic static PyCode compile_flags(org.python.antlr.base.mod node, String filename, CompileMode kind, CompilerFlags cflags)
public static PyCode compile_flags(InputStream istream, String filename, CompileMode kind, CompilerFlags cflags)
public static PyCode compile_flags(String data, String filename, CompileMode kind, CompilerFlags cflags)
public static PyObject compile_command_flags(String string, String filename, CompileMode kind, CompilerFlags cflags, boolean stdprompt)
public static long id(PyObject o)
public static long java_obj_id(Object o)
public static void printResult(PyObject ret)
public static void saveClassFile(String name, ByteArrayOutputStream bytestream)
public static String getDefaultExecutableName()
getJarFileName()
by replacing the
file name with "bin/jython". This is intended as an easy fallback
for cases where sys.executable
is None
due to
direct launching via the java executable.sys.executable
to get the actual executable (may be
None
.
In contrast to getJarFileName()
and
getJarFileNameFromURL(java.net.URL)
this method returns
the path using system-specific separator characters.public static String getDefaultBinDir()
getJarFileName()
byr replacing the file name
with "bin". This is intended as an easy fallback for cases where
sys.executable
is null
due to direct launching via
the java executable.getJarFileName()
and
getJarFileNameFromURL(java.net.URL)
this method returns
the path using system-specific separator characters.public static String getJarFileName()
null
if not available.public static String _getJarFileName()
null
if not available.public static String getJarFileNameFromURL(URL url)
public static PyObject javaPyClass(PyObject cls, Class<?> interfce)
cls
and interfce
.
If cls
already extends interfce
, simply cls
is 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.cls
and interfce
public static <T> T newJavaObject(PyObject cls, Class<T> jcls, Object... args)
cls
and retruns it in form of
jcls
, which must be an interface. This method even works if
cls
does not extend jcls
in Python-code. In that case,
it uses javaPyClass(PyObject, Class)
to create an appropriate
class on the fly.args
to PyObject
s.newJavaObject(PyObject, Class, String[], Object...)
.
newJavaObject(PyObject, Class, PyObject[], String[])
newJavaObject(PyObject, Class, String[], Object...)
newJavaObject(PyModule, Class, Object...)
newJavaObject(PyModule, Class, String[], Object...)
cls
- - the class to be instanciatedjcls
- - the Java-type to be returnedargs
- are automatically converted to Jython-PyObjectspublic static <T> T newJavaObject(PyObject cls, Class<T> jcls, PyObject[] args, String[] keywords)
cls
and retruns it in form of
jcls
, which must be an interface. This method even works if
cls
does not extend jcls
in Python-code. In that case,
it uses javaPyClass(PyObject, Class)
to create an appropriate
class on the fly.keywordss
are applied to the last args
in the list.
newJavaObject(PyObject, Class, Object...)
newJavaObject(PyObject, Class, String[], Object...)
newJavaObject(PyModule, Class, Object...)
newJavaObject(PyModule, Class, String[], Object...)
cls
- - the class to be instanciatedjcls
- - the Java-type to be returnedkeywords
- are applied to the last argsargs
- for the Python-class constructorpublic static <T> T newJavaObject(PyObject cls, Class<T> jcls, String[] keywords, Object... args)
cls
and retruns it in form of
jcls
, which must be an interface. This method even works if
cls
does not extend jcls
in Python-code. In that case,
it uses javaPyClass(PyObject, Class)
to create an appropriate
class on the fly.args
to PyObject
s.keywordss
are applied to the last args
in the list.
newJavaObject(PyObject, Class, PyObject[], String[])
newJavaObject(PyObject, Class, Object...)
newJavaObject(PyModule, Class, Object...)
newJavaObject(PyModule, Class, String[], Object...)
cls
- - the class to be instanciatedjcls
- - the Java-type to be returnedkeywords
- are applied to the last argsargs
- are automatically converted to Jython-PyObjectspublic static <T> T newJavaObject(PyModule module, Class<T> jcls, Object... args)
newJavaObject(PyObject, Class, Object...)
, but looks
up the Python-class in the module-dict using the interface-name, i.e.
jcls.getSimpleName()
.newJavaObject(PyModule, Class, String[], Object...)
.
newJavaObject(PyModule, Class, String[], Object...)
newJavaObject(PyObject, Class, PyObject[], String[])
newJavaObject(PyObject, Class, Object...)
newJavaObject(PyObject, Class, String[], Object...)
module
- the module containing the desired classjcls
- Java-type of the desired clas, must have the same nameargs
- constructor-argumentspublic static <T> T newJavaObject(PyModule module, Class<T> jcls, String[] keywords, Object... args)
newJavaObject(PyObject, Class, String[], Object...)
, but looks
up the Python-class in the module-dict using the interface-name, i.e.
jcls.getSimpleName()
.keywordss
are applied to the last args
in the list.
newJavaObject(PyModule, Class, Object...)
newJavaObject(PyObject, Class, PyObject[], String[])
newJavaObject(PyObject, Class, Object...)
newJavaObject(PyObject, Class, String[], Object...)
module
- the module containing the desired classjcls
- Java-type of the desired class, must have the same namekeywords
- are applied to the last args
in the listargs
- constructor-arguments