Top Description Inners Fields Constructors Methods
org.python.core.util

public abstract Class importer<T>

extends PyObject
Class Inheritance
Known Direct Subclasses
org.python.modules.zipimport.zipimporter, org.python.core.ClasspathPyImporter
Imports
java.io.IOException, .InputStream, java.util.EnumSet, java.util.logging.Logger, .Level, org.python.core.BytecodeLoader, .Py, .PyCode, .PyList, .PyModule, .PyObject, .PyType, .imp

A base class for PEP-302 path hooks. Handles looking through source, compiled, package and module items in the right order, and creating and filling in modules.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract static class
importer.Bundle

Bundle is an InputStream, bundled together with a method that can close the input stream and whatever resources are associated with it when the resource is imported.

pack-priv static enum
protected class
importer.ModuleCodeData

Container for PyModule code - whether or not it's a package - and its path.

protected static enum
importer.ModuleInfo

Module information

protected static class
importer.SearchOrderEntry

A step in the module search order: the file suffix and its entry type.

Field Summary

Modifier and TypeField and Description
protected static Logger
pack-priv final importer.SearchOrderEntry[]
searchOrder

SearchOrder defines how we search for a module.

Inherited from org.python.core.PyObject:
attributesgcMonitorGlobalobjtypeTYPE

Constructor Summary

AccessConstructor and Description
public
importer(PyType subType)

public

Method Summary

Modifier and TypeMethod and Description
public abstract String
get_data(String path)

Return the bytes for the data located at path.

protected final importer<T>.ModuleCodeData

Returns:

the module's ModuleCodeData object
getModuleCode
(String
the fully qualified name of the module
fullname
)

Return the code object and its associated data for the module with the fully qualified name.

protected final importer.ModuleInfo

Returns:

the module's information
getModuleInfo
(String
the fully qualified name of the module
fullname
)

Return module information for the module with the fully qualified name.

protected abstract String
getSeparator()

Returns the separator between directories and files used by this type of importer.

protected abstract long

Returns:

long mtime of the .py, or -1 if no source is available
getSourceMtime
(String
to the compiled file
path
)

Given a path to a compiled file in the archive, return the modification time of the matching .py file.

protected final PyObject
protected final boolean

Returns:

whether the module is a package
importer_is_package
(String
the fully qualified name of the module
fullname
)

protected final PyObject
protected abstract importer.Bundle
makeBundle(String filenameAndSuffix, T entry)

Returns a Bundle for fullFilename and entry, the result from a makeEntry call for fullFilename.

protected abstract T
makeEntry(String filenameAndSuffix)

Returns an entry for a filename from makeFilename with a potential suffix such that this importer can make a bundle with it, or null if fullFilename doesn't exist in this importer.

protected abstract String
makeFilename(String fullname)

Given a full module name, return the potential file path in the archive (without extension).

protected abstract String
makeFilePath(String fullname)

Given a full module name, return the potential file path including the archive (without extension).

protected abstract String
makePackagePath(String fullname)

Returns the value to fill in __path__ on a module with the given full module name created by this importer.

private importer.SearchOrderEntry[]
Inherited from org.python.core.PyObject:
__abs____add____and____call____call____call____call____call____call____call____call____call____call____call____call____call____call____call____call____cmp____coerce____coerce_ex____complex____contains____delattr____delattr____delete____delitem____delitem____delslice____delslice____dir____div____divmod____ensure_finalizer____eq____findattr____findattr____findattr_ex____finditem____finditem____finditem____float____floordiv____format____ge____get____getattr____getattr____getitem____getitem____getnewargs____getslice____getslice____gt____hash____hex____iadd____iand____idiv____idivmod____ifloordiv____ilshift____imod____imul____index____int____invert____ior____ipow____irshift____isub____iter____iternext____itruediv____ixor____le____len____long____lshift____lt____mod____mul____ne____neg____nonzero____not____oct____or____pos____pow____pow____radd____rand____rawdir____rdiv____rdivmod____reduce____reduce_ex____reduce_ex____repr____rfloordiv____rlshift____rmod____rmul____ror____rpow____rrshift____rshift____rsub____rtruediv____rxor____set____setattr____setattr____setitem____setitem____setitem____setslice____setslice____str____sub____tojava____truediv____trunc____unicode____xor___add_and_callextra_cmp_div_divmod_doget_doget_doset_eq_floordiv_ge_gt_iadd_iand_idiv_idivmod_ifloordiv_ilshift_imod_imul_in_ior_ipow_irshift_is_isnot_isub_itruediv_ixor_jcall_jcallexc_jthrow_le_lshift_lt_mod_mul_ne_notin_or_pow_rshift_sub_truediv_unsupportedop_xoradaptToCoerceTupleasDoubleasIndexasIndexasIntasIntasIterableasLongasLongasNameasNameasStringasStringasStringOrNullasStringOrNullbit_lengthconjugatedelDictdelTypedispatch__init__equalsfastGetClassfastGetDictfinalizegetDictgetJavaProxygetTypehashCodeimpAttrimplementsDescrDeleteimplementsDescrGetimplementsDescrSetinvokeinvokeinvokeinvokeinvokeinvokeisCallableisDataDescrisIndexisIntegerisMappingTypeisNumberTypeisSequenceTypemergeClassDictmergeDictAttrmergeListAttrnoAttributeErrorobject___subclasshook__readonlyAttributeErrorrunsupportedopMessagesetDictsetTypetoStringunsupportedopMessage

Field Detail

loggerback to summary
protected static Logger logger
searchOrderback to summary
pack-priv final importer.SearchOrderEntry[] searchOrder

SearchOrder defines how we search for a module.

Constructor Detail

importerback to summary
public importer(PyType subType)
importerback to summary
public importer()

Method Detail

get_databack to summary
public abstract String get_data(String path)

Return the bytes for the data located at path.

getModuleCodeback to summary
protected final importer<T>.ModuleCodeData getModuleCode(String fullname)

Return the code object and its associated data for the module with the fully qualified name.

Parameters
fullname:String

the fully qualified name of the module

Returns:importer<T>.ModuleCodeData

the module's ModuleCodeData object

getModuleInfoback to summary
protected final importer.ModuleInfo getModuleInfo(String fullname)

Return module information for the module with the fully qualified name.

Parameters
fullname:String

the fully qualified name of the module

Returns:importer.ModuleInfo

the module's information

getSeparatorback to summary
protected abstract String getSeparator()

Returns the separator between directories and files used by this type of importer.

getSourceMtimeback to summary
protected abstract long getSourceMtime(String path)

Given a path to a compiled file in the archive, return the modification time of the matching .py file.

Parameters
path:String

to the compiled file

Returns:long

long mtime of the .py, or -1 if no source is available

importer_find_moduleback to summary
protected final PyObject importer_find_module(String fullname, String path)
importer_is_packageback to summary
protected final boolean importer_is_package(String fullname)
Parameters
fullname:String

the fully qualified name of the module

Returns:boolean

whether the module is a package

importer_load_moduleback to summary
protected final PyObject importer_load_module(String fullname)
makeBundleback to summary
protected abstract importer.Bundle makeBundle(String filenameAndSuffix, T entry)

Returns a Bundle for fullFilename and entry, the result from a makeEntry call for fullFilename.

makeEntryback to summary
protected abstract T makeEntry(String filenameAndSuffix)

Returns an entry for a filename from makeFilename with a potential suffix such that this importer can make a bundle with it, or null if fullFilename doesn't exist in this importer.

makeFilenameback to summary
protected abstract String makeFilename(String fullname)

Given a full module name, return the potential file path in the archive (without extension).

makeFilePathback to summary
protected abstract String makeFilePath(String fullname)

Given a full module name, return the potential file path including the archive (without extension).

makePackagePathback to summary
protected abstract String makePackagePath(String fullname)

Returns the value to fill in __path__ on a module with the given full module name created by this importer.

makeSearchOrderback to summary
private importer.SearchOrderEntry[] makeSearchOrder()
org.python.core.util back to summary

protected abstract Class importer.Bundle

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Known Direct Subclasses
org.python.modules.zipimport.zipimporter.ZipBundle

Bundle is an InputStream, bundled together with a method that can close the input stream and whatever resources are associated with it when the resource is imported.

Field Summary

Modifier and TypeField and Description
public InputStream

Constructor Summary

AccessConstructor and Description
public
Bundle(InputStream inputStream)

Method Summary

Modifier and TypeMethod and Description
public abstract void
close()

Redeclares java.lang.AutoCloseable.close.

Close the underlying resource if necessary.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

inputStreamback to summary
public InputStream inputStream

Constructor Detail

Bundleback to summary
public Bundle(InputStream inputStream)

Method Detail

closeback to summary
public abstract void close()

Redeclares java.lang.AutoCloseable.close.

Close the underlying resource if necessary. Raises an IOError if a problem occurs.

Annotations
@Override
org.python.core.util back to summary

pack-priv final Enum importer.EntryType

extends Enum<importer.EntryType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final importer.EntryType
public static final importer.EntryType
public static final importer.EntryType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static importer.EntryType
public static importer.EntryType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

IS_BYTECODEback to summary
public static final importer.EntryType IS_BYTECODE
IS_PACKAGEback to summary
public static final importer.EntryType IS_PACKAGE
IS_SOURCEback to summary
public static final importer.EntryType IS_SOURCE

Constructor Detail

EntryTypeback to summary
private EntryType()

Method Detail

valueOfback to summary
public static importer.EntryType valueOf(String name)
valuesback to summary
public static importer.EntryType[] values()
org.python.core.util back to summary

protected Class importer.ModuleCodeData

extends Object
Class Inheritance

Container for PyModule code - whether or not it's a package - and its path.

Field Summary

Modifier and TypeField and Description
public PyCode
public boolean
public String

Constructor Summary

AccessConstructor and Description
public
ModuleCodeData(PyCode code, boolean isPackage, String path)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

codeback to summary
public PyCode code
isPackageback to summary
public boolean isPackage
pathback to summary
public String path

Constructor Detail

ModuleCodeDataback to summary
public ModuleCodeData(PyCode code, boolean isPackage, String path)
org.python.core.util back to summary

protected final Enum importer.ModuleInfo

extends Enum<importer.ModuleInfo>
Class Inheritance

Module information

Field Summary

Modifier and TypeField and Description
public static final importer.ModuleInfo
public static final importer.ModuleInfo
public static final importer.ModuleInfo
public static final importer.ModuleInfo

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static importer.ModuleInfo
public static importer.ModuleInfo[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ERRORback to summary
public static final importer.ModuleInfo ERROR
MODULEback to summary
public static final importer.ModuleInfo MODULE
NOT_FOUNDback to summary
public static final importer.ModuleInfo NOT_FOUND
PACKAGEback to summary
public static final importer.ModuleInfo PACKAGE

Constructor Detail

ModuleInfoback to summary
private ModuleInfo()

Method Detail

valueOfback to summary
public static importer.ModuleInfo valueOf(String name)
valuesback to summary
public static importer.ModuleInfo[] values()
org.python.core.util back to summary

protected Class importer.SearchOrderEntry

extends Object
Class Inheritance

A step in the module search order: the file suffix and its entry type.

Field Summary

Modifier and TypeField and Description
public String
public EnumSet<importer.EntryType>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

suffixback to summary
public String suffix
typeback to summary
public EnumSet<importer.EntryType> type

Constructor Detail

SearchOrderEntryback to summary
public SearchOrderEntry(String suffix, EnumSet<importer.EntryType> type)