zipimport.zipimporter

class zipimport.zipimporter(archivepath)

Create a new zipimporter instance. archivepath must be a path to a ZIP file, or to a specific path within a ZIP file. For example, an archivepath of foo/bar.zip/lib will look for modules in the lib directory inside the ZIP file foo/bar.zip (provided that it exists).

ZipImportError is raised if archivepath doesn’t point to a valid ZIP archive.

find_module(fullname[, path])

Search for a module specified by fullname. fullname must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, or None if it wasn’t. The optional path argument is ignored—it’s there for compatibility with the importer protocol.

get_code(fullname)

Return the code object for the specified module. Raise ZipImportError if the module couldn’t be found.

get_data(pathname)

Return the data associated with pathname. Raise OSError if the file wasn’t found.

Changed in version 3.3: IOError used to be raised instead of OSError.

get_filename(fullname)

Return the value __file__ would be set to if the specified module was imported. Raise ZipImportError if the module couldn’t be found.

New in version 3.1.

get_source(fullname)

Return the source code for the specified module. Raise ZipImportError if the module couldn’t be found, return None if the archive does contain the module, but has no source for it.

is_package(fullname)

Return True if the module specified by fullname is a package. Raise ZipImportError if the module couldn’t be found.

load_module(fullname)

Load the module specified by fullname. fullname must be the fully qualified (dotted) module name. It returns the imported module, or raises ZipImportError if it wasn’t found.

archive

The file name of the importer’s associated ZIP file, without a possible subpath.

prefix

The subpath within the ZIP file where modules are searched. This is the empty string for zipimporter objects which point to the root of the ZIP file.

The archive and prefix attributes, when combined with a slash, equal the original archivepath argument given to the zipimporter constructor.

doc_python
2016-10-07 17:48:45
Comments
Leave a Comment

Please login to continue.