filesys

jukeboxcore.filesys.copy_file(old, new)[source]

Copy the old file to the location of the new file

Parameters:
  • old (JB_File) – The file to copy
  • new (JB_File) – The JB_File for the new location
Returns:

None

Return type:

None

Raises:

None

jukeboxcore.filesys.delete_file(f)[source]

Delete the given file

Parameters:f (JB_File) – the file to delete
Returns:None
Return type:None
Raises:OSError
class jukeboxcore.filesys.FileInfo[source]

Bases: object

Abstract class that can be used for implementing info objects that can be used with FileElements

You don’t have to use this, but it provides an interface for getting the latest or next version.

classmethod get_latest()[source]

Get the latest existing file for the given info or None if there is no existing one

You should reimplement this method so it accepts some arguments with infos and returns a FileInfo that is the latest version for the given info.

Returns:a fileinfoobject that is the latest existing file for the given info
Return type:FileInfo | None
Raises:None
classmethod get_next()[source]

Return a file info object that would be the next version for the given info

You should reimplement this method so it accepts some arguments with infos and returns a FileInfo that would be the next version after the latest for the given info

Returns:a fileinfoobject that is the latest existing file for the given info
Return type:FileInfo
Raises:None
class jukeboxcore.filesys.TaskFileInfo(task, version, releasetype, typ, descriptor=None)[source]

Bases: jukeboxcore.filesys.FileInfo

FileInfo for a taskfile

Can get the latest or the next version if you provide a task, releasetype (and a descriptor).

Constructs a new TaskFileInfo

Parameters:
  • task (jukeboxcore.djadapter.models.Task) – the task of the taskfile
  • version (int) – the version of the TaskFile
  • releasetype (str - jukeboxcore.djadapter.RELEASETYPES) – the releasetype
  • typ (str) – the file type, see TaskFileInfo.TYPES
  • descriptor (str|None) – the descriptor, if the taskfile has one.
Raises:

None

TYPES = {'mayamainscene': 'mayamainscene'}

A dict for file types that can be used in a TaskFile

the values are the actual data that gets stored in the database.

Explanations:

mayamainscene:probably the most common for maya scenes. these are the usual release and workfiles maybe even a handoff file, if it does not need a direct subfolder. Main scenes hold the main information, not just extracted parts. If you export shader or maybe some blendshapes in a scene, do not use this one.
classmethod get_latest(task, releasetype, typ, descriptor=None)[source]

Returns a TaskFileInfo that with the latest existing version and the provided info

Parameters:
Returns:

taskfileinfoobject with the latest extisting version and the provided info or none if there is no latest.

Return type:

TaskFileInfo | None

Raises:

None

classmethod get_next(task, releasetype, typ, descriptor=None)[source]

Returns a TaskFileInfo that with the next available version and the provided info

Parameters:
Returns:

taskfileinfoobject with next available version and the provided info

Return type:

TaskFileInfo

Raises:

None

classmethod create_from_taskfile(taskfile)[source]

Create a new TaskFileInfo and return it for the given taskfile

Parameters:taskfile (jukeboxcore.djadapter.models.TaskFile) – the taskfile to represent
Returns:a taskfileinfo
Return type:TaskFileInfo
Raises:None
is_latest()[source]

Return True, if the version is the newest.

Returns:None
Return type:None
Raises:None
create_db_entry(comment='')[source]

Create a db entry for this task file info and link it with a optional comment

Parameters:comment (str) – a comment for the task file entry
Returns:The created TaskFile django instance and the comment. If the comment was empty, None is returned instead
Return type:tuple of dj.models.TaskFile and dj.models.Note
Raises:ValidationError, If the comment could not be created, the TaskFile is deleted and the Exception is propagated.
class jukeboxcore.filesys.FileElement[source]

Bases: object

A file element uses a file info object to retrieve some information and generate part of the path or name of a file. This Class is meant to be used as a baseclass. Override at least one of the functions:

A filepath consists of multiple directories. Each element can, but must not, contribute to this path. A filename consits of multiple chunks, that are seperated by underscores.

get_dir(obj)[source]

Return a part of the filepath for the given object, or none if the element does not contribute a directory.

Some Elements might only add a chunk to the filename. These elements should always return None. Each element is responsible for a certain aspect/attribute of the obj and uses this attribute to generate part of the filepath. E.g. an element, that creates a folder for every version of obj, could return a string like 'v###' with the version numbers inserted. A element that is responsible for the project, might return the complete root path for that objects project.

The default will return None. So override it if necessary.

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:a part of the filepath or None
Return type:str|None
Raises:None
get_chunk(obj)[source]

Return a filename chunk, or None if the element does not contribute to the filename.

Some Elements might only add a directory to the filepath. These elements should always return None. Each element is responsible for a certain aspect/attribute of the obj and uses this attribute to generate part of the filename (chunk). Chunks are seperated by underscores and should not contain any spaces. E.g. an element that inserts the username to the filename might return the username as a string.

The default will return None. So override it if necessary.

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:a filename chunk or None
Return type:str|None
Raises:None
class jukeboxcore.filesys.StaticElement(dirname=None, chunk=None)[source]

Bases: jukeboxcore.filesys.FileElement

A static element that will always give the same dir or chunk and is independent of the object

Can be used to insert static folders like a folder where all maya files go.

Constructs a new static element that will always give the specified dir and/or chunk

Parameters:
  • dirname (str|None) – the dirname the element will contribute or None
  • chunk (str|None) – the chunk for the filename the element will contribute or None
Raises:

None

get_dir(obj)[source]

Return a part of the filepath for the given object, or None if the element does not contribute a directory.

This will always return the dirname that was specified in the constructor

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:the directory that was given in the constructor
Return type:str|None
Raises:None
get_chunk(obj)[source]

Return a filenamechunk or None, if the element does not contribute a directory

This will always return the chunk that was specified in the constructor

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:the chunk that was given in the contructor
Return type:str|None
Raises:None
class jukeboxcore.filesys.AttrElement(dirattr=None, chunkattr=None, dirformat='%s', chunkformat='%s')[source]

Bases: jukeboxcore.filesys.FileElement

A simple element that will always return a certain attribute for a dir or chunk

You can also specify a format string.

Constructs a new attr element. It will use the given attribute to query with operator.attrgetter and format it with the corresponding format string. So it is possible to get nested attributes. For nested attributes specify something like this: attr1.attr2.attr3.

Parameters:
  • dirattr (str|None) – the attribute to use for directories
  • chunkattr (str|None) – the attribute to use for chunks
  • dirformat (str) – the format string for directories. formating will be done with the % operator.
  • chunkformat (str) – the format string for chunks. formating will be done with the % operator.
Raises:

None

get_dir(obj)[source]

Return the dirattr of obj formatted with the dirfomat specified in the constructor. If the attr is None then None is returned not the string 'None'.

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:the directory or None
Return type:str|None
Raises:None
get_chunk(obj)[source]

Return the chunkattr of obj formatted with the chunkfomat specified in the constructor If the attr is None then None is returned not the string 'None'.

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:the chunk or None
Return type:str|None
Raises:None
class jukeboxcore.filesys.SoftwareElement[source]

Bases: jukeboxcore.filesys.FileElement

This element checks a TaskFileInfo for the typ and returns the directory name for the software branch.

typmapping = {'mayamainscene': 'Maya'}
get_dir(taskinfo)[source]

Return a directory for the software, depending on the typ of taskinfo

Parameters:obj (TaskFileInfo) – the fileinfo with information.
Returns:directory for the software, depending on the typ of taskinfo
Return type:str
Raises:None
class jukeboxcore.filesys.TaskGroupElement[source]

Bases: jukeboxcore.filesys.FileElement

This element checks a TaskFileInfo and returns the top directory name for either shots or assets joined by either the sequence name or the assettype name

get_dir(taskinfo)[source]

Return assets/ + assettypename if it is for an assettask or shots/ + sequencename if is is for a shottask

Parameters:obj (TaskFileInfo) – the fileinfo with information.
Returns:assets or shots depending on the assetflag of the task of taskinfo
Return type:str
Raises:None
class jukeboxcore.filesys.ExtElement[source]

Bases: object

The ExtElement uses a file info object to determine the file extension

get_ext(obj)[source]

Return a file extension (without the extension seperator) for the given file info obj

Parameters:obj (TaskFileInfo) – the fileinfo with information.
Returns:None
Return type:None
Raises:None
class jukeboxcore.filesys.StaticExtElement(ext)[source]

Bases: jukeboxcore.filesys.ExtElement

This extension element will always return the same extension no matter what the file info is

Constructs a new static extension element that always returns the given file extension

Parameters:ext (str) – the extension
Raises:None
get_ext(obj)[source]
Parameters:obj (FileInfo) – the fileinfo with information.
Returns:the extension that was specified in the constructor
Return type:str
Raises:None
class jukeboxcore.filesys.TaskFileExtElement[source]

Bases: jukeboxcore.filesys.ExtElement

This extension element uses a TaskFileInfo and returns an appropriate extension

typmapping = {'mayamainscene': 'mb'}
get_ext(taskinfo)[source]

Return a file extension (without the extension seperator) for the given file info obj

Parameters:obj (TaskFileInfo) – the fileinfo with information.
Returns:the appropriate extension without extension seperator (.)
Return type:str
Raises:None
class jukeboxcore.filesys.JB_File(obj)[source]

Bases: object

This class generates filenames for arbitrary objects

The object should contain all the information that is needed for constructing a distinct filepath. It should be a subclass of FileInfo. This class uses a list of FileElement to generate the filepath. Each element should know how to handle the object. So only use certain objects with certain elements. Each element contributes to either the path or the name or both. The JB_File has a dictionary JB_File.ELEMENTPRESETS that have a list of element for every FileInfo sublcass.

Constructs a new JB_File. the type of object determines the elementspreset (the generation of the path).

Parameters:obj (FileInfo) – the fileinfo with information.
Raises:None
ELEMENTPRESETS = {<class 'jukeboxcore.filesys.TaskFileInfo'>: [<jukeboxcore.filesys.AttrElement object at 0x0000000004E49278>, <jukeboxcore.filesys.StaticElement object at 0x0000000004E49320>, <jukeboxcore.filesys.SoftwareElement object at 0x0000000004E49400>, <jukeboxcore.filesys.TaskGroupElement object at 0x0000000004E493C8>, <jukeboxcore.filesys.AttrElement object at 0x0000000004E49390>, <jukeboxcore.filesys.AttrElement object at 0x0000000004E49438>, <jukeboxcore.filesys.AttrElement object at 0x0000000004E49240>, <jukeboxcore.filesys.AttrElement object at 0x0000000004E497B8>, <jukeboxcore.filesys.AttrElement object at 0x0000000004E49780>]}

this dict has a list of elements for each file info type

EXTENSIONS = {<class 'jukeboxcore.filesys.TaskFileInfo'>: <jukeboxcore.filesys.TaskFileExtElement object at 0x0000000004E49208>}

this dict has extensionelement for each file info type

get_ext(obj=None)[source]

Return the file extension

Parameters:obj (FileInfo) – the fileinfo with information. If None, this will use the stored object of JB_File
Returns:the file extension
Return type:str
Raises:None
get_path(obj=None)[source]

Return the path (excluding the filename)

Parameters:obj (FileInfo) – the fileinfo with information. If None, this will use the stored object of JB_File
Returns:the path to the file
Return type:str
Raises:None
get_name(obj=None, withext=True)[source]

Return the filename

Parameters:
  • obj (FileInfo) – the fileinfo with information. If None, this will use the stored object of JB_File
  • withext (bool) – If True, return with the fileextension.
Returns:

the filename, default is with fileextension

Return type:

str

Raises:

None

get_fullpath(withext=True)[source]

Return the filepath with the filename

Parameters:withext (bool) – If True, return with the fileextension.
Returns:None
Return type:None
Raises:None
get_obj()[source]

Return the object that contains the information

Returns:the object with information
Return type:FileInfo
Raises:None
set_obj(obj)[source]

Set the object that contains the information

Parameters:obj (FileInfo) – the fileinfo with information.
Returns:None
Return type:None
Raises:None
get_elements()[source]

Return the file elements

Returns:list with FileElements that are used to generate the filepath
Return type:list of FileElement
Raises:None
create_directory(path=None)[source]

Create the directory for the given path. If path is None use the path of this instance

Parameters:path (str) – the path to create
Returns:None
Return type:None
Raises:OSError