|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.python.core.imp
public class imp
Utility functions for "import" support. Note that this class tries to match the names of the corresponding functions from CPython's Python/import.c. In these cases we use CPython's function naming style (underscores and all lowercase) instead of Java's typical camelCase style so that it's easier to compare with import.c.
Field Summary | |
---|---|
static int |
DEFAULT_LEVEL
|
static ReentrantLock |
importLock
Synchronizes import operations |
static int |
NO_MTIME
|
Method Summary | |
---|---|
static PyModule |
addModule(String name)
If the given name is found in sys.modules, the entry from there is returned. |
static String |
cacheCompiledSource(String sourceFilename,
String compiledFilename,
byte[] compiledSource)
Stores the bytes in compiledSource in compiledFilename. |
static boolean |
caseok(File file,
String filename)
|
static byte[] |
compileSource(String name,
File file)
|
static byte[] |
compileSource(String name,
File file,
String sourceFilename)
|
static byte[] |
compileSource(String name,
File file,
String sourceFilename,
String compiledFilename)
|
static byte[] |
compileSource(String name,
InputStream fp,
String filename)
|
static byte[] |
compileSource(String name,
InputStream fp,
String filename,
long mtime)
|
static PyObject |
createFromCode(String name,
PyCode c)
Returns a module with the given name whose contents are the results of running c. |
static PyObject |
createFromCode(String name,
PyCode c,
String moduleLocation)
Returns a module with the given name whose contents are the results of running c. |
static PyObject |
createFromSource(String name,
InputStream fp,
String filename)
|
static PyObject |
createFromSource(String name,
InputStream fp,
String filename,
String outFilename)
|
static PyObject |
createFromSource(String name,
InputStream fp,
String filename,
String outFilename,
long mtime)
|
static int |
getAPIVersion()
|
static ClassLoader |
getParentClassLoader()
Selects the parent class loader for Jython, to be used for dynamically loaded classes and resources. |
static ClassLoader |
getSyspathJavaLoader()
|
static void |
importAll(PyObject module,
PyFrame frame)
|
static void |
importAll(String mod,
PyFrame frame)
Deprecated. |
static void |
importAll(String mod,
PyFrame frame,
int level)
Called from jython generated code when a statement like "from spam.eggs import *" is executed. |
static PyObject[] |
importFrom(String mod,
String[] names,
PyFrame frame)
Deprecated. use importFrom with level param. |
static PyObject[] |
importFrom(String mod,
String[] names,
PyFrame frame,
int level)
Called from jython generated code when a statement like "from spam.eggs import foo, bar" is executed. |
static PyObject[] |
importFromAs(String mod,
String[] names,
PyFrame frame)
Deprecated. use importFromAs with level param. |
static PyObject[] |
importFromAs(String mod,
String[] names,
String[] asnames,
PyFrame frame,
int level)
Called from jython generated code when a statement like "from spam.eggs import foo as spam" is executed. |
static PyObject |
importName(String name,
boolean top)
Import a module by name. |
static PyObject |
importName(String name,
boolean top,
PyObject modDict,
PyObject fromlist,
int level)
Import a module by name. |
static PyObject |
importOne(String mod,
PyFrame frame)
Deprecated. |
static PyObject |
importOne(String mod,
PyFrame frame,
int level)
Called from jython generated code when a statement like "import spam" is executed. |
static PyObject |
importOneAs(String mod,
PyFrame frame)
Deprecated. |
static PyObject |
importOneAs(String mod,
PyFrame frame,
int level)
Called from jython generated code when a statement like "import spam as foo" is executed. |
static PyObject |
load(String name)
Load the module by name. |
static PyObject |
loadFromCompiled(String name,
InputStream stream,
String sourceName,
String compiledName)
|
static String |
makeCompiledFilename(String filename)
|
static byte[] |
readCode(String name,
InputStream fp,
boolean testing)
|
static byte[] |
readCode(String name,
InputStream fp,
boolean testing,
long mtime)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_MTIME
public static final int DEFAULT_LEVEL
public static final ReentrantLock importLock
Method Detail |
---|
public static ClassLoader getSyspathJavaLoader()
public static ClassLoader getParentClassLoader()
public static PyModule addModule(String name)
public static byte[] readCode(String name, InputStream fp, boolean testing) throws IOException
IOException
public static byte[] readCode(String name, InputStream fp, boolean testing, long mtime) throws IOException
IOException
public static byte[] compileSource(String name, File file)
public static byte[] compileSource(String name, File file, String sourceFilename)
public static byte[] compileSource(String name, File file, String sourceFilename, String compiledFilename)
public static String makeCompiledFilename(String filename)
public static String cacheCompiledSource(String sourceFilename, String compiledFilename, byte[] compiledSource)
public static byte[] compileSource(String name, InputStream fp, String filename)
public static byte[] compileSource(String name, InputStream fp, String filename, long mtime)
public static PyObject createFromSource(String name, InputStream fp, String filename)
public static PyObject createFromSource(String name, InputStream fp, String filename, String outFilename)
public static PyObject createFromSource(String name, InputStream fp, String filename, String outFilename, long mtime)
public static PyObject createFromCode(String name, PyCode c)
public static PyObject createFromCode(String name, PyCode c, String moduleLocation)
public static PyObject loadFromCompiled(String name, InputStream stream, String sourceName, String compiledName)
public static boolean caseok(File file, String filename)
public static PyObject load(String name)
name
- the name of the module to load
public static PyObject importName(String name, boolean top)
name
- the name of the package to importtop
- if true, return the top module in the name, otherwise the last
public static PyObject importName(String name, boolean top, PyObject modDict, PyObject fromlist, int level)
name
- the name of the package to importtop
- if true, return the top module in the name, otherwise the lastmodDict
- the __dict__ of an already imported module
@Deprecated public static PyObject importOne(String mod, PyFrame frame)
public static PyObject importOne(String mod, PyFrame frame, int level)
@Deprecated public static PyObject importOneAs(String mod, PyFrame frame)
public static PyObject importOneAs(String mod, PyFrame frame, int level)
@Deprecated public static PyObject[] importFrom(String mod, String[] names, PyFrame frame)
public static PyObject[] importFrom(String mod, String[] names, PyFrame frame, int level)
@Deprecated public static PyObject[] importFromAs(String mod, String[] names, PyFrame frame)
public static PyObject[] importFromAs(String mod, String[] names, String[] asnames, PyFrame frame, int level)
public static void importAll(String mod, PyFrame frame, int level)
@Deprecated public static void importAll(String mod, PyFrame frame)
public static void importAll(PyObject module, PyFrame frame)
public static int getAPIVersion()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |