file_saver.main#

The module contains the definition of FileSaverWidget, the main widget used by Bookmarks to create versioned template files.

The suggested save destination will be partially dependent on the extension specified, the current token config values as well as the active bookmark and asset items.

See the bookmarks.tokens and bookmarks.editor.bookmark_properties modules for more information.

1editor = FileSaverWidget(
2    server,
3    job,
4    root,
5    asset=asset,
6    extension='fbx'
7)
bookmarks.file_saver.main.SECTIONS#

The ui layout definition of the file saver widget.

Type

dict

bookmarks.file_saver.main.INACTIVE_KEYS#

A tuple of keys used to mark hidden and disabled editors.

Type

tuple

Classes:

FileSaverWidget(server, job, root, asset[, ...])

The main widget used to create template files.

Functions:

close()

Close the FileSaverWidget widget.

increment_version(v, dir, name, func, increment)

Increments the version number by one or to the smallest/largest available version number based on existing files found in the destination folder.

show(server, job, root, asset[, extension, ...])

Show the FileSaverWidget widget.

Data:

SECTIONS

UI layout definition

class bookmarks.file_saver.main.FileSaverWidget(server, job, root, asset, extension=None, file=None, create_file=True, increment=False, parent=None)[source]#

Bases: BasePropertyEditor

The main widget used to create template files.

Methods:

add_task(relative_path)

Adds a task folder to the folder editor.

create_file()

Creates a new file on the disk.

db_source()

A file path to use as the source of database values.

exec_()

Customized exec function.

file_path()

File path.

file_saver_task_button_clicked()

Lets the user select a custom save destination.

file_saver_template_button_clicked()

Button click action.

filename_button_clicked()

Used to reveal the parent folder in the file explorer.

init_data()

Initialises values of each editor.

name()

Returns the current name.

parent_folder()

The folder where the new file is about to be saved.

prefix_button_clicked()

Button click action.

save_changes()

Saves changes.

set_file(file)

Set the given file as the current file.

update_expanded_template()

Slot connected to the update timer used to preview the current file name.

update_tasks(ext)

Update the available task folder options based on the given file extension.

verify_unique()

Checks if the proposed file name exists already, and if it does, makes the output file name red.

version_button2_clicked()

Decrements the version number by one.

version_button_clicked()

Increments the version number by one.

add_task(relative_path)[source]#

Adds a task folder to the folder editor.

create_file()[source]#

Creates a new file on the disk.

db_source()[source]#

A file path to use as the source of database values.

Returns

The database source file.

Return type

str

exec_()[source]#

Customized exec function.

file_path()[source]#

File path.

file_saver_task_button_clicked()[source]#

Lets the user select a custom save destination.

The selection has to be inside the currently selected asset, otherwise will be rejected. If the folder is not part of the current available options, it will be added as a new option.

file_saver_template_button_clicked()[source]#

Button click action.

filename_button_clicked()[source]#

Used to reveal the parent folder in the file explorer.

init_data()[source]#

Initialises values of each editor.

Some values are retrieved by the context the widget was called in, and some are loaded from the user settings if the user saved a custom value previously.

name()[source]#

Returns the current name.

parent_folder()[source]#

The folder where the new file is about to be saved.

prefix_button_clicked()[source]#

Button click action.

save_changes()[source]#

Saves changes.

set_file(file)[source]#

Set the given file as the current file.

Parameters

file (str) – Path to a file.

update_expanded_template()[source]#

Slot connected to the update timer used to preview the current file name.

update_tasks(ext)[source]#

Update the available task folder options based on the given file extension.

verify_unique()[source]#

Checks if the proposed file name exists already, and if it does, makes the output file name red.

version_button2_clicked()[source]#

Decrements the version number by one.

version_button_clicked()[source]#

Increments the version number by one.

bookmarks.file_saver.main.close()[source]#

Close the FileSaverWidget widget.

bookmarks.file_saver.main.increment_version(v, dir, name, func, increment)[source]#

Increments the version number by one or to the smallest/largest available version number based on existing files found in the destination folder.

bookmarks.file_saver.main.show(server, job, root, asset, extension=None, file=None, create_file=True, increment=False)[source]#

Show the FileSaverWidget widget.

Parameters
  • server (str) – server path segment.

  • job (str) – job path segment.

  • root (str) – root path segment.

  • asset (str) – asset path segment.

  • extension (str) – Optional file extension. Default is None.

  • file (str) – Optional, path to an existing file.

  • create_file (bool) – Optional, when True the widget will create empty placeholder files. Default is True.

  • increment (bool) – Optional bool. Will increment the version of file when True. Default is False

bookmarks.file_saver.main.SECTIONS = {0: {'color': PySide2.QtGui.QColor.fromRgbF(0.254902, 0.254902, 0.254902, 1.000000), 'groups': {0: {0: {'button': 'Edit', 'description': "A short name of the bookmark (or job) used when saving files.\n\ne.g. 'MYB_sh0010_anim_v001.ma' where 'MYB' is the prefix specified here.", 'key': 'file_saver/template', 'name': 'Template', 'placeholder': "Custom prefix, e.g. 'MYB'", 'validator': <PySide2.QtGui.QRegExpValidator(0x26177cf1030)>, 'widget': <class 'bookmarks.file_saver.widgets.TemplateComboBox'>}, 1: {'button': 'Reveal', 'description': 'The file name, based on the current template.', 'key': 'filename', 'name': 'Name', 'placeholder': 'Invalid file name...', 'validator': None, 'widget': <class 'PySide2.QtWidgets.QLabel'>}}}, 'icon': 'file', 'name': 'Name Template'}, 1: {'color': PySide2.QtGui.QColor.fromRgbF(0.254902, 0.254902, 0.254902, 1.000000), 'groups': {0: {0: {'description': 'The current bookmark item.', 'key': 'bookmark', 'name': 'Bookmark', 'placeholder': None, 'validator': None, 'widget': <class 'bookmarks.file_saver.widgets.BookmarkComboBox'>}, 1: {'description': 'The current asset item.', 'key': 'asset', 'name': 'Asset', 'placeholder': None, 'validator': None, 'widget': <class 'bookmarks.file_saver.widgets.AssetComboBox'>}, 2: {'button': 'Pick', 'description': 'The current task item.', 'key': 'file_saver/task', 'name': 'Task', 'placeholder': None, 'validator': None, 'widget': <class 'bookmarks.file_saver.widgets.TaskComboBox'>}}, 1: {0: {'description': "A short description of the file's contents.\nIndicate significant changes and notes here.", 'key': 'description', 'name': 'Description', 'placeholder': "A short description, e.g. 'Compositing files'", 'validator': None, 'widget': <class 'bookmarks.ui.LineEdit'>}}, 2: {0: {'button': 'Edit', 'description': "A short prefix used to identify the job e.g.'MYB'.", 'key': 'prefix', 'name': 'Project Prefix', 'placeholder': 'Prefix not yet set!', 'validator': <PySide2.QtGui.QRegExpValidator(0x26177cf1030)>, 'widget': <class 'bookmarks.ui.LineEdit'>}, 1: {'description': "The name of the element being saved. e.g., 'ForegroundTower', or 'BackgroundElements'", 'key': 'file_saver/element', 'name': 'Specify Element', 'placeholder': "The element being saved, e.g. 'CastleInterior'", 'validator': <PySide2.QtGui.QRegExpValidator(0x26177cf1030)>, 'widget': <class 'bookmarks.ui.LineEdit'>}, 2: {'button': '+', 'button2': '-', 'description': "A version number with, or without, a preceding 'v'. e.g. 'v001'.", 'key': 'version', 'name': 'File Version', 'placeholder': "A version number, e.g. 'v001'", 'validator': <PySide2.QtGui.QRegExpValidator(0x26177cf1c90)>, 'widget': <class 'bookmarks.ui.LineEdit'>}, 3: {'description': "The name of the current user, e.g. 'JohnDoe', or 'JD'", 'key': 'file_saver/user', 'name': 'User', 'placeholder': "Your name, e.g. 'JohnDoe'", 'validator': <PySide2.QtGui.QRegExpValidator(0x26177cf1030)>, 'widget': <class 'bookmarks.ui.LineEdit'>}, 4: {'description': "A file extension, without the leading dot. e.g. 'ma'", 'key': 'file_saver/extension', 'name': 'Format', 'placeholder': "File extension, e.g. 'exr'", 'validator': None, 'widget': <class 'bookmarks.file_saver.widgets.FormatComboBox'>}}}, 'icon': 'todo', 'name': 'Name Elements'}}#

UI layout definition