common.core#
Common attributes, methods and flag values.
Classes:
|
Custom dictionary class used to store model item data. |
|
A custom QTimer class used across the app. |
Functions:
|
Add a relative link to a link config file fount in the root of "path". |
|
Converts a numeric byte value to a human-readable string. |
|
Verify the type of object. |
|
Function decorator used to log a debug message. |
|
Decorator function used to handle exceptions and report them to the user. |
|
Returns a scandir entry of the given file path. |
|
Calculates the md5 hash of a string. |
|
Returns a list of file links defined in a |
Returns the current platform. |
|
|
Sum size of object & members. |
Returns the sequence and shot name of the given path. |
|
|
Returns the path to the source template file. |
|
Returns the key associated with args and the current thread. |
Returns the name of the currently logged-in user. |
|
|
Makes certain we convert int keys back to int values. |
|
Cache-back type query. |
Return a location on the local system to store temporary files. |
|
|
Returns a resource item from the rsc directory. |
|
Sorts a comma separated list of words found in the given string. |
Path to the folder to store temporary files. |
Data:
The config file name |
|
Startup mode used when Bookmarks runs embedded in a host DCC. |
|
Startup mode when Bookmarks is running as a standalone Qt application |
- class bookmarks.common.core.DataDict(*args, **kwargs)[source]#
Bases:
dict
Custom dictionary class used to store model item data.
This class adds compatibility for
weakref.ref
referencing and custom attributes for storing data state.Attributes:
Returns the associated model item type.
Special attribute used by the item models and associated thread workers.
Used to signal that the cached data is out of date and needs updating.
- property data_type#
Returns the associated model item type.
- property loaded#
Special attribute used by the item models and associated thread workers.
When set to True, the helper threads have finished populating data and the item is considered fully loaded.
- property refresh_needed#
Used to signal that the cached data is out of date and needs updating.
- class bookmarks.common.core.Timer(*args, **kwargs)[source]#
Bases:
QTimer
A custom QTimer class used across the app.
Methods:
Delete all cached timers instances.
Set the instance object name.
- bookmarks.common.core.add_link(path, link, section='links/asset')[source]#
Add a relative link to a link config file fount in the root of “path”.
- Parameters:
path (str) – Path to a folder where the link file resides. E.g. an asset root folder.
link (str) – Relative path to the link file.
section (str) – The settings section to look for links in. Defaults to links/asset.
- bookmarks.common.core.byte_to_pretty_string(num, suffix='B')[source]#
Converts a numeric byte value to a human-readable string.
- Parameters:
num (int) – The number of bytes.
suffix (str) – A custom suffix.
- Returns:
Human readable byte value.
- Return type:
str
- bookmarks.common.core.check_type(value, _type)[source]#
Verify the type of object.
- Parameters:
value (object) – An object of invalid type.
_type (type or tuple or types) – The valid type.
- Raises:
TypeError – When
value
is not of_type
.
- bookmarks.common.core.debug(func)[source]#
Function decorator used to log a debug message. No message will be logged, unless
debug_on
is set to True.
- bookmarks.common.core.error(func)[source]#
Decorator function used to handle exceptions and report them to the user.
- bookmarks.common.core.get_entry_from_path(path, is_dir=True)[source]#
Returns a scandir entry of the given file path.
- Parameters:
path (str) – Path to directory.
is_dir (bool) – Is the path a directory or a file.
- Returns:
A scandir entry, or None if not found.
- Return type:
scandir.DirEntry
- bookmarks.common.core.get_hash(key)[source]#
Calculates the md5 hash of a string.
In practice, we use this function to generate hashes for file paths. These hashes are used by the ImageCache, user_settings and BookmarkDB to associate data with the file items. Generated hashes are server agnostic, meaning, if the passed string contains a known server’s name, we’ll remove it before hashing.
- Parameters:
key (str) – A key string to calculate a md5 hash for.
- Returns:
MD5 hexadecimal digest of the key.
- Return type:
str
- bookmarks.common.core.get_links(path, section='links/asset')[source]#
Returns a list of file links defined in a
.links
file..link files are simple QSettings ini files that define a list of paths relative to the .link file. These can be used to define nested assets or bookmark item locations inside job templates.
If a .links file contains two relative paths, subfolder1/nested_asset1 and subfolder2/nested_asset2…
asset/ ├─ .links ├─ subfolder1/ │ ├─ nested_asset1/ ├─ subfolder2/ │ ├─ nested_asset2/
…two asset will be read, nested_asset1 and nested_asset2 (but not the original root asset).
- Parameters:
path (str) – Path to a folder where the link file resides. E.g. an asset root folder.
section (str) – The settings section to look for links in. Optional. Defaults to ‘links/asset’.
- Returns:
A list of relative file paths.
- Return type:
list
- bookmarks.common.core.get_sequence_and_shot(s)[source]#
Returns the sequence and shot name of the given path.
E.g. if the path is C:/SEQ050/SH010/my_file.ma will return (‘SEQ050’, ‘SH010’).
- Parameters:
s (str) – A file or folder path.
- Returns:
- Sequence and shot name, or (None, None)
if not found.
- Return type:
tuple (str, str)
- bookmarks.common.core.get_template_file_path(name)[source]#
Returns the path to the source template file.
- Parameters:
name (str) – The name of the template file.
- Returns:
The path to the template file.
- Return type:
str
- bookmarks.common.core.get_thread_key(*args)[source]#
Returns the key associated with args and the current thread.
- Parameters:
*args – server, job, root path segments.
- Returns:
The key value.
- Return type:
str
- bookmarks.common.core.pseudo_local_bookmark()[source]#
Return a location on the local system to store temporary files. This is used to store thumbnails for starred items and other temporary items.
- Returns:
A tuple of path segments.
- Return type:
tuple
- bookmarks.common.core.sort_words(s)[source]#
Sorts a comma separated list of words found in the given string.
- Returns:
A comma-separated list of sorted words.
- Return type:
str
- bookmarks.common.core.temp_path()[source]#
Path to the folder to store temporary files.
- Returns:
Path to a directory.
- Return type:
str
- bookmarks.common.core.CONFIG = 'config.json'#
The config file name
- bookmarks.common.core.EmbeddedMode = 'embedded'#
Startup mode used when Bookmarks runs embedded in a host DCC.
- bookmarks.common.core.StandaloneMode = 'standalone'#
Startup mode when Bookmarks is running as a standalone Qt application