Panda3D
|
Public Member Functions | |
def | __init__ |
def | add |
manages keeping the internal TOC and the guts in sync ####### | |
def | build |
Building. | |
def | checkmagic |
Sub-methods of __init__ - override as needed #############. | |
def | contents |
Informational methods. | |
def | extract |
Core method - Override as needed #########. | |
def | get_code |
This is what is called by FuncImporter ####### Since an Archive is flat, we ignore parent and modname. | |
def | loadtoc |
def | save_toc |
def | save_trailer |
def | update_headers |
Public Attributes | |
lib | |
path | |
pymagic | |
start | |
toc | |
Static Public Attributes | |
int | HDRLEN = 12 |
string | MAGIC = 'PYL\0' |
os = None | |
int | TOCPOS = 8 |
dictionary | TOCTMPLT = {} |
int | TRLLEN = 0 |
A base class for a repository of python code objects. The get_code method is used by imputil.FuntionImporter to get code objects by name. Archives are flat namespaces, so conflict between module names in different packages are possible. Use a different Archive for each package.
def __init__ | ( | self, | |
path = None , |
|||
start = 0 |
|||
) |
Initialize an Archive. If path is omitted, it will be an empty Archive. start is the seek position within path where the Archive starts.
Reimplemented in ZlibArchive.
def add | ( | self, | |
entry | |||
) |
manages keeping the internal TOC and the guts in sync #######
Add an entry to the archive. Override this to influence the mechanics of the Archive. Assumes entry is a seq beginning with (nm, pth, ...) where nm is the key by which we'll be asked for the object. pth is the name of where we find the object.
Reimplemented in ZlibArchive, and CArchive.
def build | ( | self, | |
path, | |||
lTOC | |||
) |
Building.
Top level method - shouldn't need overriding #######
Create an archive file of name PATH from LTOC. lTOC is a 'logical TOC' - a list of (name, path, ...) where name is the internal (import) name, and path is a file to get the object from, eg './a.pyc'.
def checkmagic | ( | self | ) |
Sub-methods of __init__ - override as needed #############.
Verify version and validity of file. Overridable. Check to see if the file object self.lib actually has a file we understand.
Reimplemented in CArchive.
def contents | ( | self | ) |
Informational methods.
Return a list of the contents. Default implementation assumes self.toc is a dict like object.
Reimplemented in CArchive.
def extract | ( | self, | |
name | |||
) |
Core method - Override as needed #########.
Get the object corresponding to name, or None. NAME is the name as specified in an 'import name'. 'import a.b' will become: extract('a') (return None because 'a' is not a code object) extract('a.__init__') (return a code object) extract('a.b') (return a code object) Default implementation: self.toc is a dict self.toc[name] is pos self.lib has the code object marshal-ed at pos
Reimplemented in ZlibArchive, and CArchive.
def get_code | ( | self, | |
parent, | |||
modname, | |||
fqname | |||
) |
This is what is called by FuncImporter ####### Since an Archive is flat, we ignore parent and modname.
The import hook. Called by imputil.FunctionImporter. Override extract to tune getting code from the Archive.
def loadtoc | ( | self | ) |
Load the table of contents. Overridable. Default: After magic comes an int (4 byte native) giving the position of the TOC within self.lib. Default: The TOC is a marshal-able string.
Reimplemented in CArchive.
def save_toc | ( | self, | |
tocpos | |||
) |
Save the table of contents. Default - toc is a dict Gets marshaled to self.lib
Reimplemented in CArchive.
def save_trailer | ( | self, | |
tocpos | |||
) |
Placeholder for Archives with trailers.
Reimplemented in CArchive.
def update_headers | ( | self, | |
tocpos | |||
) |
Update any header data. Default header is MAGIC + Python's magic + tocpos
int HDRLEN = 12 [static] |
Reimplemented in ZlibArchive, and CArchive.
string MAGIC = 'PYL\0' [static] |
Reimplemented in ZlibArchive, and CArchive.
os = None [static] |
Reimplemented in ZlibArchive.
int TOCPOS = 8 [static] |
Reimplemented in ZlibArchive.
dictionary TOCTMPLT = {} [static] |
Reimplemented in ZlibArchive, and CArchive.
int TRLLEN = 0 [static] |
Reimplemented in ZlibArchive, and CArchive.