💾 Archived View for tris.fyi › pydoc › zipimport captured on 2022-01-08 at 13:44:06. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2023-01-29)

-=-=-=-=-=-=-

Back to module index

Go to module by name

zipimport

zipimport provides support for importing Python modules from Zip archives.

This module exports three objects:
- zipimporter: a class; its constructor takes a path to a Zip archive.
- ZipImportError: exception raised by zipimporter objects. It's a
  subclass of ImportError, so it can be caught as ImportError, too.
- _zip_directory_cache: a dict, mapping archive paths to zip directory
  info dicts, as used in zipimporter._files.

It is usually not needed to use the zipimport module explicitly; it is
used by the builtin import mechanism for sys.path items that are paths
to Zip archives.

Classes

ZipImportError

with_traceback(...)

  Exception.with_traceback(tb) --
      set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
msg = <member 'msg' of 'ImportError' objects>
  exception message
name = <member 'name' of 'ImportError' objects>
  module name
path = <member 'path' of 'ImportError' objects>
  module path

zipimporter

zipimporter(archivepath) -> zipimporter object

    Create a new zipimporter instance. 'archivepath' must be a path to
    a zipfile, or to a specific path inside a zipfile. For example, it can be
    '/tmp/myimport.zip', or '/tmp/myimport.zip/mydirectory', if mydirectory is a
    valid directory inside the archive.

    'ZipImportError is raised if 'archivepath' doesn't point to a valid Zip
    archive.

    The 'archive' attribute of zipimporter objects contains the name of the
    zipfile targeted.
    
find_loader(self, fullname, path=None)

  find_loader(fullname, path=None) -> self, str or None.

          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, a string containing the
          full path name if it's possibly a portion of a namespace package,
          or None otherwise. The optional 'path' argument is ignored -- it's
          there for compatibility with the importer protocol.
        
find_module(self, fullname, path=None)

  find_module(fullname, path=None) -> self or None.

          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(self, fullname)

  get_code(fullname) -> code object.

          Return the code object for the specified module. Raise ZipImportError
          if the module couldn't be found.
        
get_data(self, pathname)

  get_data(pathname) -> string with file data.

          Return the data associated with 'pathname'. Raise OSError if
          the file wasn't found.
        
get_filename(self, fullname)

  get_filename(fullname) -> filename string.

          Return the filename for the specified module.
        
get_resource_reader(self, fullname)

  Return the ResourceReader for a package in a zip file.

          If 'fullname' is a package within the zip file, return the
          'ResourceReader' object for the package.  Otherwise return None.
        
get_source(self, fullname)

  get_source(fullname) -> source string.

          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(self, fullname)

  is_package(fullname) -> bool.

          Return True if the module specified by fullname is a package.
          Raise ZipImportError if the module couldn't be found.
        
load_module(self, fullname)

  load_module(fullname) -> module.

          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.
        

Other members

END_CENTRAL_DIR_SIZE = 22
MAX_COMMENT_LEN = 65535
STRING_END_ARCHIVE = b'PK\x05\x06'
alt_path_sep = ''
cp437_table = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7fÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xa0'
path_sep = '/'

Modules

marshal

sys

time