Package org.python.modules
Class _imp
- java.lang.Object
-
- org.python.modules._imp
-
public class _imp extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static PyString
__doc__
static int
C_BUILTIN
static int
C_EXTENSION
static int
IMP_HOOK
static int
PKG_DIRECTORY
static int
PY_COMPILED
static int
PY_FROZEN
static int
PY_SOURCE
-
Constructor Summary
Constructors Constructor Description _imp()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
acquire_lock()
Acquires the interpreter's import lock for the current thread.static PyObject
find_module(java.lang.String name)
static PyObject
find_module(java.lang.String name, PyObject path)
static PyObject
get_magic()
static PyObject
get_suffixes()
static boolean
is_builtin(java.lang.String name)
static boolean
is_frozen(java.lang.String name)
static PyObject
load_compiled(java.lang.String name, PyString pathname)
Return a module with the givenname
, the result of executing the compiled code at the givenpathname
.static PyObject
load_compiled(java.lang.String name, PyString pathname, PyObject file)
Return a module with the givenname
, the result of executing the compiled code in the givenfile
stream.static PyObject
load_dynamic(java.lang.String name, java.lang.String pathname)
static PyObject
load_dynamic(java.lang.String name, java.lang.String pathname, PyObject file)
static PyObject
load_module(java.lang.String name, PyObject file, PyObject filename, PyTuple data)
static PyObject
load_source(java.lang.String modname, java.lang.String filename)
static PyObject
load_source(java.lang.String modname, java.lang.String filename, PyObject file)
static boolean
lock_held()
Return true if the import lock is currently held, else false.static PyString
makeCompiledFilename(PyString filename)
Variant ofimp.makeCompiledFilename(String)
dealing with encoded bytes.static PyModule
new_module(java.lang.String name)
static void
release_lock()
Release the interpreter's import lock.static PyObject
reload(PyObject module)
-
-
-
Field Detail
-
__doc__
public static PyString __doc__
-
PY_SOURCE
public static final int PY_SOURCE
- See Also:
- Constant Field Values
-
PY_COMPILED
public static final int PY_COMPILED
- See Also:
- Constant Field Values
-
C_EXTENSION
public static final int C_EXTENSION
- See Also:
- Constant Field Values
-
PKG_DIRECTORY
public static final int PKG_DIRECTORY
- See Also:
- Constant Field Values
-
C_BUILTIN
public static final int C_BUILTIN
- See Also:
- Constant Field Values
-
PY_FROZEN
public static final int PY_FROZEN
- See Also:
- Constant Field Values
-
IMP_HOOK
public static final int IMP_HOOK
- See Also:
- Constant Field Values
-
-
Method Detail
-
load_dynamic
public static PyObject load_dynamic(java.lang.String name, java.lang.String pathname)
-
load_dynamic
public static PyObject load_dynamic(java.lang.String name, java.lang.String pathname, PyObject file)
-
load_source
public static PyObject load_source(java.lang.String modname, java.lang.String filename)
-
load_source
public static PyObject load_source(java.lang.String modname, java.lang.String filename, PyObject file)
-
load_compiled
public static PyObject load_compiled(java.lang.String name, PyString pathname)
Return a module with the givenname
, the result of executing the compiled code at the givenpathname
. If this path is aPyUnicode
, it is used exactly; if it is aPyString
it is taken to be file-system encoded.- Parameters:
name
- the module namepathname
- to the compiled module (becomes__file__
)- Returns:
- the module called
name
-
load_compiled
public static PyObject load_compiled(java.lang.String name, PyString pathname, PyObject file)
Return a module with the givenname
, the result of executing the compiled code in the givenfile
stream.- Parameters:
name
- the module namepathname
- a file path that is not null (becomes__file__
)file
- stream from which the compiled code is taken- Returns:
- the module called
name
-
find_module
public static PyObject find_module(java.lang.String name)
-
load_module
public static PyObject load_module(java.lang.String name, PyObject file, PyObject filename, PyTuple data)
-
makeCompiledFilename
public static PyString makeCompiledFilename(PyString filename)
Variant ofimp.makeCompiledFilename(String)
dealing with encoded bytes. In the context where this is used from Python, a result in encoded bytes is preferable.
-
get_magic
public static PyObject get_magic()
-
get_suffixes
public static PyObject get_suffixes()
-
new_module
public static PyModule new_module(java.lang.String name)
-
is_builtin
public static boolean is_builtin(java.lang.String name)
-
is_frozen
public static boolean is_frozen(java.lang.String name)
-
acquire_lock
public static void acquire_lock()
Acquires the interpreter's import lock for the current thread. This lock should be used by import hooks to ensure thread-safety when importing modules.
-
release_lock
public static void release_lock()
Release the interpreter's import lock.
-
lock_held
public static boolean lock_held()
Return true if the import lock is currently held, else false.- Returns:
- true if the import lock is currently held, else false.
-
-