Utilities module

synchronizer.utils.create_dir(dirpath)

Creates given directory.

Arguments:
dirpath {str} – Full path to a directory that needs to be created.
Returns:
[bool] – True if directory creation was successful, False otherwise.
synchronizer.utils.get_sequence_files(file_path)

Find and return all files that are part of a sequence matching file_path. If no sequence found, returns None. Two files are enough to make a sequence, even if they’re not sequential. This assumes the sequence digits are right beside the file extension.

e.g.:
  • C_myfile_v568.jpg
  • MJ_thisisafileseq_4568.dpx
  • MB_udimsforthewin.1008.tx
Arguments:
file_path {string} – Path to a file
Returns:
[list] – List of sequence files including given file_path. None if sequence is not found.
synchronizer.utils.get_sequence_name_pattern(file_path)

Finds the name pattern and number of digits that make the name of the file. Both elements are used by other functions to identify file sequences. This assumes the sequence digits are right beside the file extension.

e.g.:
  • C_myfile_v568.jpg
  • MJ_thisisafileseq_4568.dpx
  • MB_udimsforthewin.1008.tx
Arguments:
file_path {string} – Full path to a file
Returns:

[str] – A string consisting of the base name for the file without trailing digits.

e.g.:
  • File: ‘C_cresta_02__MSH-BUMP.1001.png’
  • Name Pattern: ‘C_cresta_02__MSH-BUMP.’

[None] – If no digits can be found in the name, returns None

synchronizer.utils.is_sequence(file_path)

Looks for sibling files in the same directory. Since two sibling files is enough to make a sequence, even if they are not sequential, if it finds one, it’ll stop looking and return True. This assumes the sequence digits are right beside the file extension.

e.g.:
  • C_myfile_v568.jpg
  • MJ_thisisafileseq_4568.dpx
  • MB_udimsforthewin.1008.tx

If you want to get a complete list of files, use get_sequence_files()

Arguments:
file_path {str} – Full path to a file
Returns:
[bool] – If another a file is found with the same name pattern, True is returned. Missing files are taken into account.
synchronizer.utils.is_sequence_complete(files, name_pattern)

Evaluates a list of sequence files, if the sequence is missing one or more files, returns False. If sequence is complete, returns True. This assumes the sequence digits are right beside the file extension.

e.g.:
  • C_myfile_v568.jpg
  • MJ_thisisafileseq_4568.dpx
  • MB_udimsforthewin.1008.tx
Arguments:

files {list} – List of complete file paths to a file sequence. You could use get_sequence_files() to get a list.

name_pattern {str} – As returned by get_sequence_name_pattern(), It’s a string consisting of the base name for the file without trailing digits.

e.g.:
  • File: ‘C_cresta_02__MSH-BUMP.1001.png’
  • Name Pattern: ‘C_cresta_02__MSH-BUMP.’
Returns:
[bool] – True if sequence is complete. False otherwise.