Top Inners Fields Constructors Methods
org.python.modules

public Class _imp

extends Object
Class Inheritance
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, java.util.logging.Level, .Logger, org.python.core.Py, .PyFile, .PyList, .PyModule, .PyObject, .PyString, .PySystemState, .PyTuple, .__builtin__, .imp

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static PyString
public static final int
public static final int
public static final int
private static Logger
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
_imp()

Method Summary

Modifier and TypeMethod and Description
private static PyObject
_load_compiled(String name, String pathname, PyObject file)

public static void
acquire_lock()

Acquires the interpreter's import lock for the current thread.

private static boolean
caseok(File file, String filename)

public static PyObject
public static PyObject
pack-priv static _imp.ModuleInfo

Returns:

null if no module found otherwise module information
findFromSource
(String
module name
name
,
String
a path String (Unicode file or directory name)
entry
,
boolean
if looking for a package only try to locate __init__
findingPackage
,
boolean preferSource)

This needs to be consolidated with the code in org.python.core.imp.

public static PyObject
public static PyObject
public static boolean
public static boolean
public static PyObject

Returns:

the module called name
load_compiled
(String
the module name
name
,
PyString
to the compiled module (becomes __file__)
pathname
)

Return a module with the given name, the result of executing the compiled code at the given pathname.

public static PyObject

Returns:

the module called name
load_compiled
(String
the module name
name
,
PyString
a file path that is not null (becomes __file__)
pathname
,
PyObject
stream from which the compiled code is taken
file
)

Return a module with the given name, the result of executing the compiled code in the given file stream.

public static PyObject
load_dynamic(String name, String pathname)

public static PyObject
load_dynamic(String name, String pathname, PyObject file)

public static PyObject
load_module(String name, PyObject file, PyObject filename, PyTuple data)

public static PyObject
load_source(String modname, String filename)

public static PyObject
load_source(String modname, String filename, PyObject file)

public static boolean

Returns:

true if the import lock is currently held, else false.
lock_held
()

Return true if the import lock is currently held, else false.

public static PyString
makeCompiledFilename(PyString filename)

Variant of imp#makeCompiledFilename(String) dealing with encoded bytes.

public static PyModule
private static PyObject
newFile(File file)

public static void
release_lock()

Release the interpreter's import lock.

public static PyObject
reload(PyObject module)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__doc__back to summary
public static PyString __doc__
C_BUILTINback to summary
public static final int C_BUILTIN
C_EXTENSIONback to summary
public static final int C_EXTENSION
IMP_HOOKback to summary
public static final int IMP_HOOK
loggerback to summary
private static Logger logger
PKG_DIRECTORYback to summary
public static final int PKG_DIRECTORY
PY_COMPILEDback to summary
public static final int PY_COMPILED
PY_FROZENback to summary
public static final int PY_FROZEN
PY_SOURCEback to summary
public static final int PY_SOURCE

Constructor Detail

_impback to summary
public _imp()

Method Detail

_load_compiledback to summary
private static PyObject _load_compiled(String name, String pathname, PyObject file)
acquire_lockback to summary
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.

caseokback to summary
private static boolean caseok(File file, String filename)
find_moduleback to summary
public static PyObject find_module(String name)
find_moduleback to summary
public static PyObject find_module(String name, PyObject path)
findFromSourceback to summary
pack-priv static _imp.ModuleInfo findFromSource(String name, String entry, boolean findingPackage, boolean preferSource)

This needs to be consolidated with the code in org.python.core.imp.

Parameters
name:String

module name

entry:String

a path String (Unicode file or directory name)

findingPackage:boolean

if looking for a package only try to locate __init__

Returns:_imp.ModuleInfo

null if no module found otherwise module information

get_magicback to summary
public static PyObject get_magic()
get_suffixesback to summary
public static PyObject get_suffixes()
is_builtinback to summary
public static boolean is_builtin(String name)
is_frozenback to summary
public static boolean is_frozen(String name)
load_compiledback to summary
public static PyObject load_compiled(String name, PyString pathname)

Return a module with the given name, the result of executing the compiled code at the given pathname. If this path is a PyUnicode, it is used exactly; if it is a PyString it is taken to be file-system encoded.

Parameters
name:String

the module name

pathname:PyString

to the compiled module (becomes __file__)

Returns:PyObject

the module called name

load_compiledback to summary
public static PyObject load_compiled(String name, PyString pathname, PyObject file)

Return a module with the given name, the result of executing the compiled code in the given file stream.

Parameters
name:String

the module name

pathname:PyString

a file path that is not null (becomes __file__)

file:PyObject

stream from which the compiled code is taken

Returns:PyObject

the module called name

load_dynamicback to summary
public static PyObject load_dynamic(String name, String pathname)
load_dynamicback to summary
public static PyObject load_dynamic(String name, String pathname, PyObject file)
load_moduleback to summary
public static PyObject load_module(String name, PyObject file, PyObject filename, PyTuple data)
load_sourceback to summary
public static PyObject load_source(String modname, String filename)
load_sourceback to summary
public static PyObject load_source(String modname, String filename, PyObject file)
lock_heldback to summary
public static boolean lock_held()

Return true if the import lock is currently held, else false.

Returns:boolean

true if the import lock is currently held, else false.

makeCompiledFilenameback to summary
public static PyString makeCompiledFilename(PyString filename)

Variant of imp#makeCompiledFilename(String) dealing with encoded bytes. In the context where this is used from Python, a result in encoded bytes is preferable.

new_moduleback to summary
public static PyModule new_module(String name)
newFileback to summary
private static PyObject newFile(File file)
release_lockback to summary
public static void release_lock()

Release the interpreter's import lock.

reloadback to summary
public static PyObject reload(PyObject module)
org.python.modules back to summary

private Class _imp.ModuleInfo

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv PyObject
pack-priv String
pack-priv String
pack-priv String
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv
ModuleInfo(PyObject file, String filename, String suffix, String mode, int type)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
pack-priv PyObject file
filenameback to summary
pack-priv String filename
modeback to summary
pack-priv String mode
suffixback to summary
pack-priv String suffix
typeback to summary
pack-priv int type

Constructor Detail

ModuleInfoback to summary
pack-priv ModuleInfo(PyObject file, String filename, String suffix, String mode, int type)