Package autodesk_toxik :: Module admin :: Class LibraryMgr
[frames] | no frames]

Class LibraryMgr

 object --+    
          |    
Boost.Python.instance --+
              |
             LibraryMgr

The library manager is a static class used to access and manage Toxik and regular files on the filesystem. For Toxik files, it provides some mechanisms to help preserve the integrity of Toxik data. For example, the function remove() will prevent deleting a composition if it is in use.

Nested Classes
  Type
Instance Methods
 
__init__(...)
The LibraryMgr() constructor can be used to access the library manager singleton.
 
__reduce__(...)
helper for pickle

Inherited from Boost.Python.instance: __new__

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

Static Methods
 
copyComponent(...)
Copy the contents of the file named pathSrc to a file named pathDst.
bool
exists(...)
Returns: True if path refers to an existing Toxik component.
str
getDefaultReplacementChar(...)
Returns: The default replacement character used by Toxik.
str
getSetting(...)
Returns: The component's setting value for the specified setting group and key.
[str]
getSettingGroups(...)
Returns: The list of setting groups on the specified component.
dict
getSettings(...)
Returns: The component's settings for the specified setting group, as a dict of setting keys to setting values.
tuple
getStat(...)
Returns: A tuple of component attributes:
 
getType(...)
Returns the component type (LibraryMgr.Type enum) for the given path.
bool
hasSetting(...)
Returns: True if the component has a value set for the specified setting group and key.
bool
isComposition(...)
Returns: True if path is an existing composition.
bool
isFolder(...)
Returns: True if path is an existing folder.
bool
isLocked(...)
Returns: True if the specified file is locked by any Toxik process.
bool
isValidComponentName(...)
Returns: A bool indicating whether the given string is a valid component name.
[str]
listFolder(...)
Returns: A list containing the names of the files in the specified folder path.
 
makeFolder(...)
Creates a folder at the location specified by path.
 
makeFolders(...)
Recursive directory creation function.
 
makeSetup(...)
Creates a simple setup component that can store a data string.
 
remove(...)
Removes the file at location path.
 
removeFolder(...)
Removes the folder named path.
 
removeSettingGroup(...)
Removes the specified setting group (and all the settings in that group) from the specified component.
 
removeTree(...)
Removes the folder named path and its contents.
 
rename(...)
Renames the file or folder pathSrc to pathDst.
str
sanitizeComponentName(...)
Transforms the given string into a valid component name.
 
setDescription(...)
Sets the description of the specified component.
 
setSetting(...)
Sets the component's setting value for the specified setting group and key.
 
toXml(...)
Generically converts the object pointed to by the given path to XML.
 
walk(self, top, topDown=True, onError=None)
Library folder tree generator.
Class Variables
  __instance_size__ = 24
  compTypes = {libDLpyextAdmin.Type.FOLDER: 'folder', libDLpyext...
Properties

Inherited from object: __class__

Method Details

__init__(...)
(Constructor)

 

The LibraryMgr() constructor can be used to access the library manager singleton. This is optional however, since all the LibraryMgr methods are static and therefore can be invoked on the class itself or on an instance of it. For example, the following two lines of code are equivalent:

   admin.LibraryMgr().exists(...)
   admin.LibraryMgr.exists(...)
Overrides: object.__init__

__reduce__(...)

 

helper for pickle

Overrides: object.__reduce__
(inherited documentation)

copyComponent(...)
Static Method

 

Copy the contents of the file named pathSrc to a file named pathDst.

Parameters:
  • pathSrc (str)
  • pathDst (str)
Raises:
  • Exception - If pathDst exists.

exists(...)
Static Method

 
Parameters:
  • path (str)
Returns: bool
True if path refers to an existing Toxik component.

getDefaultReplacementChar(...)
Static Method

 
Returns: str
The default replacement character used by Toxik.

getSetting(...)
Static Method

 
Parameters:
  • path (str)
  • group (str)
  • key (str)
Returns: str
The component's setting value for the specified setting group and key.

getSettingGroups(...)
Static Method

 
Parameters:
  • path (str)
Returns: [str]
The list of setting groups on the specified component.

getSettings(...)
Static Method

 
Parameters:
  • path (str)
  • group (str)
Returns: dict
The component's settings for the specified setting group, as a dict of setting keys to setting values.

getStat(...)
Static Method

 
Parameters:
  • path (str)
Returns: tuple
A tuple of component attributes:
  • id (uuid)
  • component type (LibraryMgr.Type enum)
  • role (string)
  • last modification time (time tuple (see "time" standard Python module))
  • creation time (time tuple (see "time" standard Python module))
  • description (str)

getType(...)
Static Method

 

Returns the component type (LibraryMgr.Type enum) for the given path.

Parameters:
  • path (str)

hasSetting(...)
Static Method

 
Parameters:
  • path (str)
  • group (str)
  • key (str)
Returns: bool
True if the component has a value set for the specified setting group and key.

isComposition(...)
Static Method

 
Parameters:
  • path (str)
Returns: bool
True if path is an existing composition.

isFolder(...)
Static Method

 
Parameters:
  • path (str)
Returns: bool
True if path is an existing folder.

isLocked(...)
Static Method

 
Parameters:
  • path (str)
Returns: bool
True if the specified file is locked by any Toxik process.

isValidComponentName(...)
Static Method

 
Parameters:
  • name (str)
Returns: bool
A bool indicating whether the given string is a valid component name.

listFolder(...)
Static Method

 
Parameters:
  • path (str)
Returns: [str]
A list containing the names of the files in the specified folder path.

makeFolder(...)
Static Method

 

Creates a folder at the location specified by path. The folder to create must not already exist and its parent folder must exist.

Parameters:
  • path (str)
Raises:
  • Exception - If the folder cannot be created.

makeFolders(...)
Static Method

 

Recursive directory creation function. Like makeFolder(), but creates all intermediate-level folders required to contain the leaf directory.

Parameters:
  • path (str)
Raises:
  • Exception - If the leaf folder already exists or cannot be created.

makeSetup(...)
Static Method

 

Creates a simple setup component that can store a data string. This is mainly used for internal testing purposes.

Parameters:
  • path (str)
  • role (str)
  • data (str)

remove(...)
Static Method

 

Removes the file at location path.

Parameters:
  • path (str)
Raises:
  • Exception - If the path points to a directory.

See Also: removeFolder() to remove a directory.

removeFolder(...)
Static Method

 

Removes the folder named path.

Parameters:
  • path (str)
Raises:
  • Exception - If the path is not an existing folder or if the folder is not empty.

See Also: removeTree() to erase an entire folder hierarchy.

removeSettingGroup(...)
Static Method

 

Removes the specified setting group (and all the settings in that group) from the specified component.

Parameters:
  • path (str)
  • group (str)

removeTree(...)
Static Method

 

Removes the folder named path and its contents.

Parameters:
  • path (str)
Raises:
  • Exception - If the path is not an existing folder.

rename(...)
Static Method

 

Renames the file or folder pathSrc to pathDst.

Parameters:
  • pathSrc (str)
  • pathDst (str)
Raises:
  • Exception - If pathDst is an existing file or directory.

sanitizeComponentName(...)
Static Method

 

Transforms the given string into a valid component name. Substitutes invalid characters in the given component name by the specified (optional) replacement character or by their ASCII numerical value prefixed by '$' when a replacement char is not specified. It also strips out leading and trailing whitespace characters.

Parameters:
  • name (str)
  • replacementChar (str) - Optional replacement character. Defaults to None.
Returns: str
The sanitized string.

setDescription(...)
Static Method

 

Sets the description of the specified component.

Parameters:
  • path (str)
  • description (str)

setSetting(...)
Static Method

 

Sets the component's setting value for the specified setting group and key.

Parameters:
  • path (str)
  • group (str)
  • key (str)
  • value (str)

toXml(...)
Static Method

 

Generically converts the object pointed to by the given path to XML.

Parameters:
  • path (str)
  • indent (int) - Optional parameter that specifies the number of characters to indent by. Defaults to 3.

walk(self, top, topDown=True, onError=None)
Static Method

 

Library folder tree generator.

Note: this method behaves exactly like the standard Python function os.walk() except that directories are Toxik library folders and files are paths to compositions only.

It generates the file names in a directory tree, by walking the tree either top down or bottom up. For each directory in the tree rooted at directory top (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames):

  • dirpath is a str representing the path to the directory.
  • dirnames is a list of the names of the subdirectories in dirpath (excluding '.' and '..').
  • filenames is a list of the names of the non-directory files in dirpath. Note that the names in the lists contain no path components. To get a full path (which begins with top) to a file or directory in dirpath, do "os.path.join(dirpath, name)".
Parameters:
  • top (str)
  • topDown (bool) - If this optional argument is left unspecified or set to True, the triple for a directory is generated before the triples for any of its subdirectories (directories are generated top down). If topDown is False, the triple for a directory is generated after the triples for all of its subdirectories (directories are generated bottom up).

    When topDown is True, the caller can modify the dirnames list in-place (perhaps using del or slice assignment), and walk() will only recurse into the subdirectories whose names remain in dirnames; this can be used to prune the search, impose a specific order of visiting, or even to inform walk() about directories the caller creates or renames before it resumes walk() again. Modifying dirnames when topDown is False is ineffective, because in bottom-up mode the directories in dirnames are generated before dirnames itself is generated.

  • onError (function) - By default, errors from the os.listdir() call are ignored. If optional argument onError is specified, it should be a function; it will be called with one argument, the thrown exception (an OSError instance). It can report the error to continue with the walk, or raise the exception to abort the walk. Note that the filename is available as the filename attribute of the exception object.

See Also: os.walk() for detailed instructions on how this method works.


Class Variable Details

compTypes

Value:
{libDLpyextAdmin.Type.FOLDER: 'folder',
 libDLpyextAdmin.Type.COMPOSITION: 'composition',
 libDLpyextAdmin.Type.PROJECT: 'project',
 libDLpyextAdmin.Type.USER: 'user',
 libDLpyextAdmin.Type.MACHINE: 'machine',
 libDLpyextAdmin.Type.SETUP: 'setup'}