Package autodesk_toxik :: Module media :: Class ExternalDepArchive
[frames] | no frames]

Class ExternalDepArchive

object --+
         |
        ExternalDepArchive

Class wrapper for accessing and creating external dependency archives. An external dependency archive is basically a collection of zip files in the same directory, each of which contains external dependency files of a certain type.

Instance Methods
 
__init__(self, archiveName, extDepDirectory, mode='r', compress=False)
ExternalDepArchive constructor.
 
__del__(self)
ExternalDepArchive destructor.
bool
hasExternalDep(self, extDepTypes)
Returns: True if there's at least one external dependency file of one of the specified types in the archive.
[str]
listExternalDeps(self, extDepTypes)
Returns: A list of absolute paths of all the external dependency files matching one of the specified type present in the archive.
[str]
getExternalDepZipFilePaths(self)
Returns: A list of the external dependency zip file paths.
bool
extractExternalDeps(self, extDepTypes, relocationCallback=None, overwriteCallback=None)
Extracts all external dependency files of the specified types present in the archive.
 
addExternalDeps(self, extDepPaths, extDepType, pathRenameCallback=None)
Adds external dependency files to the archive.
 
dump(self)
Dumps external dependency archives content to standard output.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, archiveName, extDepDirectory, mode='r', compress=False)
(Constructor)

 

ExternalDepArchive constructor.

Parameters:
  • archiveName - The name of the archive. It is used as a prefix in all the external dependency zip files.
  • extDepDirectory - A path to the directory containing the external dependency zip files.
  • mode - Is either 'r' to read from an existing archive, in which case existing external dependency zip files are located and accessed in read-only. New external dependency zip files can still be added though. If mode is set to 'w', ExternalDepArchive starts empty (meaning that it will actually delete any existing external dependency zip file it finds) and new external dependency zip files can be created.
  • compress - Indicates whether added external dependency files should be compressed.
  • archiveName - str
  • extDepDirectory - str
  • mode - str
  • compress - bool
Overrides: object.__init__

hasExternalDep(self, extDepTypes)

 
Parameters:
  • extDepTypes - A combination of graph.ExternalDepType values.
Returns: bool
True if there's at least one external dependency file of one of the specified types in the archive.

listExternalDeps(self, extDepTypes)

 
Parameters:
  • extDepTypes - A combination of graph.ExternalDepType values.
Returns: [str]
A list of absolute paths of all the external dependency files matching one of the specified type present in the archive.

getExternalDepZipFilePaths(self)

 
Returns: [str]
A list of the external dependency zip file paths.

extractExternalDeps(self, extDepTypes, relocationCallback=None, overwriteCallback=None)

 

Extracts all external dependency files of the specified types present in the archive.

Parameters:
  • extDepTypes (int) - A combination of graph.ExternalDepType values.
  • relocationCallback (callable) - A function that performs the substitutions to apply to the extracted file paths in order to relocate the external dependencies. It receives an external dependency file path and its type in parameter.
  • overwriteCallback (callable) - A function that is invoked when an extracted file already exists. The callback receives the conflicting file path and the external dependency type and must return one of these decision code:
    • 0 : overwrite
    • 1 : skip
    • -1 : cancel (abort)

    If no callback is specified, the default behavior is to overwrite.

Returns: bool
True on success or False if the operation was cancelled.

addExternalDeps(self, extDepPaths, extDepType, pathRenameCallback=None)

 

Adds external dependency files to the archive.

Attention: During this operation, new zip files might be created in the archive directory. If there's a file name conflict, existing zip files are automatically overwritten.

Parameters:
  • extDepPaths - A list of external dependency absolute file paths.
  • extDepType - One of the graph.ExternalDepType values.
  • pathRenameCallback - For each added external dependency file, this callback is called to rename the path entry as it will appear in the archive.