1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
""":synopsis: support for importing Python modules from ZIP archives.
"""
class zipimporter:
"""
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 :file:`foo/bar.zip/lib` will look for modules in the :file:`lib` directory
inside the ZIP file :file:`foo/bar.zip` (provided that it exists).
:exc:`ZipImportError` is raised if *archivepath* doesn't point to a valid ZIP
archive.
"""
def __init__(self, ):
pass
def find_module(self, 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 :const:`None` if it wasn't. The optional
*path* argument is ignored---it's there for compatibility with the
importer protocol.
"""
pass
def get_code(self, fullname):
"""
Return the code object for the specified module. Raise
:exc:`ZipImportError` if the module couldn't be found.
"""
pass
def get_data(self, pathname):
"""
Return the data associated with *pathname*. Raise :exc:`IOError` if the
file wasn't found.
"""
pass
def get_filename(self, fullname):
"""
Return the value ``__file__`` would be set to if the specified module
was imported. Raise :exc:`ZipImportError` if the module couldn't be
found.
"""
pass
def get_source(self, fullname):
"""
Return the source code for the specified module. Raise
:exc:`ZipImportError` if the module couldn't be found, return
:const:`None` if the archive does contain the module, but has no source
for it.
"""
pass
def is_package(self, fullname):
"""
Return True if the module specified by *fullname* is a package. Raise
:exc:`ZipImportError` if the module couldn't be found.
"""
pass
def load_module(self, fullname):
"""
Load the module specified by *fullname*. *fullname* must be the fully
qualified (dotted) module name. It returns the imported module, or raises
:exc:`ZipImportError` if it wasn't found.
"""
pass
|