Skip to content

Commit

Permalink
Fixed item_type_info erroring out in case of unknown item types
Browse files Browse the repository at this point in the history
  • Loading branch information
Garvit Verma committed Jul 5, 2019
1 parent bc7328c commit 5ca1fda
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions hooks/tk-multi-publish2/ingest/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"role supervisor": "annotation",
}

# Default snapshot_type
DEFAULT_SNAPSHOT_TYPE = "ingest"

# This is a dictionary of note_type values to their access keys in the fields dict.
DEFAULT_NOTE_TYPES_ACCESS_KEYS = {
"kickoff": ["sg_version", "name"],
Expand Down Expand Up @@ -89,7 +92,7 @@ def settings_schema(self):
"type": "str",
"description": "Specifies the default snapshot type to be used for an ingested item.",
"allows_empty": True,
"default_value": "ingest",
"default_value": DEFAULT_SNAPSHOT_TYPE,
}
items_schema["default_fields"] = {
"type": dict,
Expand Down Expand Up @@ -205,16 +208,17 @@ def _add_file_item(self, settings, parent_item, path, is_sequence=False, seq_fil
ignored_filename = settings["Ignore Filename"].value

file_components = publisher.util.get_file_path_components(path)
file_ignored = False
extension_ignored = False
filename_ignored = False

if file_components["extension"] in ignored_extensions:
file_ignored = True
extension_ignored = True

if ignored_filename:
file_ignored = any(re.match(ignored_string, file_components["filename"])
for ignored_string in ignored_filename)
filename_ignored = any(re.match(ignored_string, file_components["filename"])
for ignored_string in ignored_filename)

if file_ignored:
if extension_ignored or filename_ignored:

if is_sequence:
# include an indicator that this is an image sequence and the known
Expand Down Expand Up @@ -356,6 +360,32 @@ def process_file(self, settings, parent_item, path):

return file_items

def _get_item_type_info(self, settings, item_type):
"""
Return the dictionary corresponding to this item's 'Item Types' settings.
:param dict settings: Configured settings for this collector
:param item_type: The type of Item to identify info for
:return: A dictionary of information about the item to create::
# item_type = "file.image.sequence"
{
"extensions": ["jpeg", "jpg", "png"],
"type_display": "Rendered Image Sequence",
"icon_path": "/path/to/some/icons/folder/image_sequence.png",
"work_path_template": "some_template_name"
}
"""
item_info = super(IngestCollectorPlugin, self)._get_item_type_info(settings, item_type)

item_info.setdefault("default_snapshot_type", DEFAULT_SNAPSHOT_TYPE)
item_info.setdefault("default_fields", dict())

# everything should now be populated, so return the dictionary
return item_info

def _resolve_item_fields(self, settings, item):
"""
Populates the item's defaults that are to be stored on an ingested item.
Expand Down

0 comments on commit 5ca1fda

Please sign in to comment.