From b5f2f5e37e2ee99f1c8a060d971d1461e7cf2bca Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 28 Jan 2021 12:02:48 +0100 Subject: [PATCH] resolve: restructure host folder position --- pype/hosts/resolve/__init__.py | 12 +- pype/hosts/resolve/{ => api}/README.markdown | 0 .../resolve/{ => api}/RESOLVE_API_README.txt | 0 .../{ => api}/RESOLVE_API_README_NEW.txt | 0 pype/hosts/resolve/api/__init__.py | 0 pype/hosts/resolve/{ => api}/action.py | 0 pype/hosts/resolve/{ => api}/lib.py | 0 pype/hosts/resolve/{ => api}/menu.py | 0 pype/hosts/resolve/{ => api}/menu_style.qss | 0 pype/hosts/resolve/{ => api}/pipeline.py | 0 pype/hosts/resolve/{ => api}/plugin.py | 0 .../resolve/{ => api}/preload_console.py | 0 .../hosts/resolve/{ => api}/todo-rendering.py | 0 pype/hosts/resolve/{ => api}/utils.py | 0 pype/hosts/resolve/{ => api}/workio.py | 0 .../_publish/collect_clip_resolution.py | 0 .../plugins}/_publish/collect_clips.py | 0 .../plugins}/create/create_shot_clip.py | 0 .../hosts/resolve/plugins/create_shot_clip.py | 263 ++++++++++++++++++ .../resolve/plugins}/load/load_sequence.py | 0 .../plugins}/publish/collect_instances.py | 0 .../plugins}/publish/collect_workfile.py | 0 .../plugins}/publish/extract_workfile.py | 0 23 files changed, 269 insertions(+), 6 deletions(-) rename pype/hosts/resolve/{ => api}/README.markdown (100%) rename pype/hosts/resolve/{ => api}/RESOLVE_API_README.txt (100%) rename pype/hosts/resolve/{ => api}/RESOLVE_API_README_NEW.txt (100%) create mode 100644 pype/hosts/resolve/api/__init__.py rename pype/hosts/resolve/{ => api}/action.py (100%) rename pype/hosts/resolve/{ => api}/lib.py (100%) rename pype/hosts/resolve/{ => api}/menu.py (100%) rename pype/hosts/resolve/{ => api}/menu_style.qss (100%) rename pype/hosts/resolve/{ => api}/pipeline.py (100%) rename pype/hosts/resolve/{ => api}/plugin.py (100%) rename pype/hosts/resolve/{ => api}/preload_console.py (100%) rename pype/hosts/resolve/{ => api}/todo-rendering.py (100%) rename pype/hosts/resolve/{ => api}/utils.py (100%) rename pype/hosts/resolve/{ => api}/workio.py (100%) rename pype/{plugins/resolve => hosts/resolve/plugins}/_publish/collect_clip_resolution.py (100%) rename pype/{plugins/resolve => hosts/resolve/plugins}/_publish/collect_clips.py (100%) rename pype/{plugins/resolve => hosts/resolve/plugins}/create/create_shot_clip.py (100%) create mode 100644 pype/hosts/resolve/plugins/create_shot_clip.py rename pype/{plugins/resolve => hosts/resolve/plugins}/load/load_sequence.py (100%) rename pype/{plugins/resolve => hosts/resolve/plugins}/publish/collect_instances.py (100%) rename pype/{plugins/resolve => hosts/resolve/plugins}/publish/collect_workfile.py (100%) rename pype/{plugins/resolve => hosts/resolve/plugins}/publish/extract_workfile.py (100%) diff --git a/pype/hosts/resolve/__init__.py b/pype/hosts/resolve/__init__.py index fd1efcc6e1..f1f8bd2a4a 100644 --- a/pype/hosts/resolve/__init__.py +++ b/pype/hosts/resolve/__init__.py @@ -1,9 +1,9 @@ -from .utils import ( +from .api.utils import ( setup, get_resolve_module ) -from .pipeline import ( +from .api.pipeline import ( install, uninstall, ls, @@ -13,7 +13,7 @@ from .pipeline import ( maintained_selection ) -from .lib import ( +from .api.lib import ( publish_clip_color, get_project_manager, get_current_project, @@ -34,15 +34,15 @@ from .lib import ( get_otio_clip_instance_data ) -from .menu import launch_pype_menu +from .api.menu import launch_pype_menu -from .plugin import ( +from .api.plugin import ( SequenceLoader, Creator, PublishClip ) -from .workio import ( +from .api.workio import ( open_file, save_file, current_file, diff --git a/pype/hosts/resolve/README.markdown b/pype/hosts/resolve/api/README.markdown similarity index 100% rename from pype/hosts/resolve/README.markdown rename to pype/hosts/resolve/api/README.markdown diff --git a/pype/hosts/resolve/RESOLVE_API_README.txt b/pype/hosts/resolve/api/RESOLVE_API_README.txt similarity index 100% rename from pype/hosts/resolve/RESOLVE_API_README.txt rename to pype/hosts/resolve/api/RESOLVE_API_README.txt diff --git a/pype/hosts/resolve/RESOLVE_API_README_NEW.txt b/pype/hosts/resolve/api/RESOLVE_API_README_NEW.txt similarity index 100% rename from pype/hosts/resolve/RESOLVE_API_README_NEW.txt rename to pype/hosts/resolve/api/RESOLVE_API_README_NEW.txt diff --git a/pype/hosts/resolve/api/__init__.py b/pype/hosts/resolve/api/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pype/hosts/resolve/action.py b/pype/hosts/resolve/api/action.py similarity index 100% rename from pype/hosts/resolve/action.py rename to pype/hosts/resolve/api/action.py diff --git a/pype/hosts/resolve/lib.py b/pype/hosts/resolve/api/lib.py similarity index 100% rename from pype/hosts/resolve/lib.py rename to pype/hosts/resolve/api/lib.py diff --git a/pype/hosts/resolve/menu.py b/pype/hosts/resolve/api/menu.py similarity index 100% rename from pype/hosts/resolve/menu.py rename to pype/hosts/resolve/api/menu.py diff --git a/pype/hosts/resolve/menu_style.qss b/pype/hosts/resolve/api/menu_style.qss similarity index 100% rename from pype/hosts/resolve/menu_style.qss rename to pype/hosts/resolve/api/menu_style.qss diff --git a/pype/hosts/resolve/pipeline.py b/pype/hosts/resolve/api/pipeline.py similarity index 100% rename from pype/hosts/resolve/pipeline.py rename to pype/hosts/resolve/api/pipeline.py diff --git a/pype/hosts/resolve/plugin.py b/pype/hosts/resolve/api/plugin.py similarity index 100% rename from pype/hosts/resolve/plugin.py rename to pype/hosts/resolve/api/plugin.py diff --git a/pype/hosts/resolve/preload_console.py b/pype/hosts/resolve/api/preload_console.py similarity index 100% rename from pype/hosts/resolve/preload_console.py rename to pype/hosts/resolve/api/preload_console.py diff --git a/pype/hosts/resolve/todo-rendering.py b/pype/hosts/resolve/api/todo-rendering.py similarity index 100% rename from pype/hosts/resolve/todo-rendering.py rename to pype/hosts/resolve/api/todo-rendering.py diff --git a/pype/hosts/resolve/utils.py b/pype/hosts/resolve/api/utils.py similarity index 100% rename from pype/hosts/resolve/utils.py rename to pype/hosts/resolve/api/utils.py diff --git a/pype/hosts/resolve/workio.py b/pype/hosts/resolve/api/workio.py similarity index 100% rename from pype/hosts/resolve/workio.py rename to pype/hosts/resolve/api/workio.py diff --git a/pype/plugins/resolve/_publish/collect_clip_resolution.py b/pype/hosts/resolve/plugins/_publish/collect_clip_resolution.py similarity index 100% rename from pype/plugins/resolve/_publish/collect_clip_resolution.py rename to pype/hosts/resolve/plugins/_publish/collect_clip_resolution.py diff --git a/pype/plugins/resolve/_publish/collect_clips.py b/pype/hosts/resolve/plugins/_publish/collect_clips.py similarity index 100% rename from pype/plugins/resolve/_publish/collect_clips.py rename to pype/hosts/resolve/plugins/_publish/collect_clips.py diff --git a/pype/plugins/resolve/create/create_shot_clip.py b/pype/hosts/resolve/plugins/create/create_shot_clip.py similarity index 100% rename from pype/plugins/resolve/create/create_shot_clip.py rename to pype/hosts/resolve/plugins/create/create_shot_clip.py diff --git a/pype/hosts/resolve/plugins/create_shot_clip.py b/pype/hosts/resolve/plugins/create_shot_clip.py new file mode 100644 index 0000000000..19e613ee7a --- /dev/null +++ b/pype/hosts/resolve/plugins/create_shot_clip.py @@ -0,0 +1,263 @@ +# from pprint import pformat +from pype.hosts import resolve +from pype.hosts.resolve import lib + + +class CreateShotClip(resolve.Creator): + """Publishable clip""" + + label = "Create Publishable Clip" + family = "clip" + icon = "film" + defaults = ["Main"] + + gui_tracks = resolve.get_video_track_names() + gui_name = "Pype publish attributes creator" + gui_info = "Define sequential rename and fill hierarchy data." + gui_inputs = { + "renameHierarchy": { + "type": "section", + "label": "Shot Hierarchy And Rename Settings", + "target": "ui", + "order": 0, + "value": { + "hierarchy": { + "value": "{folder}/{sequence}", + "type": "QLineEdit", + "label": "Shot Parent Hierarchy", + "target": "tag", + "toolTip": "Parents folder for shot root folder, Template filled with `Hierarchy Data` section", # noqa + "order": 0}, + "clipRename": { + "value": False, + "type": "QCheckBox", + "label": "Rename clips", + "target": "ui", + "toolTip": "Renaming selected clips on fly", # noqa + "order": 1}, + "clipName": { + "value": "{sequence}{shot}", + "type": "QLineEdit", + "label": "Clip Name Template", + "target": "ui", + "toolTip": "template for creating shot namespaused for renaming (use rename: on)", # noqa + "order": 2}, + "countFrom": { + "value": 10, + "type": "QSpinBox", + "label": "Count sequence from", + "target": "ui", + "toolTip": "Set when the sequence number stafrom", # noqa + "order": 3}, + "countSteps": { + "value": 10, + "type": "QSpinBox", + "label": "Stepping number", + "target": "ui", + "toolTip": "What number is adding every new step", # noqa + "order": 4}, + } + }, + "hierarchyData": { + "type": "dict", + "label": "Shot Template Keywords", + "target": "tag", + "order": 1, + "value": { + "folder": { + "value": "shots", + "type": "QLineEdit", + "label": "{folder}", + "target": "tag", + "toolTip": "Name of folder used for root of generated shots.\nUsable tokens:\n\t{_clip_}: name of used clip\n\t{_track_}: name of parent track layer\n\t{_sequence_}: name of parent sequence (timeline)", # noqa + "order": 0}, + "episode": { + "value": "ep01", + "type": "QLineEdit", + "label": "{episode}", + "target": "tag", + "toolTip": "Name of episode.\nUsable tokens:\n\t{_clip_}: name of used clip\n\t{_track_}: name of parent track layer\n\t{_sequence_}: name of parent sequence (timeline)", # noqa + "order": 1}, + "sequence": { + "value": "sq01", + "type": "QLineEdit", + "label": "{sequence}", + "target": "tag", + "toolTip": "Name of sequence of shots.\nUsable tokens:\n\t{_clip_}: name of used clip\n\t{_track_}: name of parent track layer\n\t{_sequence_}: name of parent sequence (timeline)", # noqa + "order": 2}, + "track": { + "value": "{_track_}", + "type": "QLineEdit", + "label": "{track}", + "target": "tag", + "toolTip": "Name of sequence of shots.\nUsable tokens:\n\t{_clip_}: name of used clip\n\t{_track_}: name of parent track layer\n\t{_sequence_}: name of parent sequence (timeline)", # noqa + "order": 3}, + "shot": { + "value": "sh###", + "type": "QLineEdit", + "label": "{shot}", + "target": "tag", + "toolTip": "Name of shot. `#` is converted to paded number. \nAlso could be used with usable tokens:\n\t{_clip_}: name of used clip\n\t{_track_}: name of parent track layer\n\t{_sequence_}: name of parent sequence (timeline)", # noqa + "order": 4} + } + }, + "verticalSync": { + "type": "section", + "label": "Vertical Synchronization Of Attributes", + "target": "ui", + "order": 2, + "value": { + "vSyncOn": { + "value": True, + "type": "QCheckBox", + "label": "Enable Vertical Sync", + "target": "ui", + "toolTip": "Switch on if you want clips above each other to share its attributes", # noqa + "order": 0}, + "vSyncTrack": { + "value": gui_tracks, # noqa + "type": "QComboBox", + "label": "Master track", + "target": "ui", + "toolTip": "Select driving track name which should be mastering all others", # noqa + "order": 1} + } + }, + "publishSettings": { + "type": "section", + "label": "Publish Settings", + "target": "ui", + "order": 3, + "value": { + "subsetName": { + "value": ["", "main", "bg", "fg", "bg", + "animatic"], + "type": "QComboBox", + "label": "Subset Name", + "target": "ui", + "toolTip": "chose subset name patern, if is selected, name of track layer will be used", # noqa + "order": 0}, + "subsetFamily": { + "value": ["plate", "take"], + "type": "QComboBox", + "label": "Subset Family", + "target": "ui", "toolTip": "What use of this subset is for", # noqa + "order": 1}, + "reviewTrack": { + "value": ["< none >"] + gui_tracks, + "type": "QComboBox", + "label": "Use Review Track", + "target": "ui", + "toolTip": "Generate preview videos on fly, if `< none >` is defined nothing will be generated.", # noqa + "order": 2}, + "audio": { + "value": False, + "type": "QCheckBox", + "label": "Include audio", + "target": "tag", + "toolTip": "Process subsets with corresponding audio", # noqa + "order": 3}, + "sourceResolution": { + "value": False, + "type": "QCheckBox", + "label": "Source resolution", + "target": "tag", + "toolTip": "Is resloution taken from timeline or source?", # noqa + "order": 4}, + } + }, + "shotAttr": { + "type": "section", + "label": "Shot Attributes", + "target": "ui", + "order": 4, + "value": { + "workfileFrameStart": { + "value": 1001, + "type": "QSpinBox", + "label": "Workfiles Start Frame", + "target": "tag", + "toolTip": "Set workfile starting frame number", # noqa + "order": 0}, + "handleStart": { + "value": 0, + "type": "QSpinBox", + "label": "Handle start (head)", + "target": "tag", + "toolTip": "Handle at start of clip", # noqa + "order": 1}, + "handleEnd": { + "value": 0, + "type": "QSpinBox", + "label": "Handle end (tail)", + "target": "tag", + "toolTip": "Handle at end of clip", # noqa + "order": 2}, + } + } + } + + presets = None + + def process(self): + # get key pares from presets and match it on ui inputs + for k, v in self.gui_inputs.items(): + if v["type"] in ("dict", "section"): + # nested dictionary (only one level allowed + # for sections and dict) + for _k, _v in v["value"].items(): + if self.presets.get(_k) is not None: + self.gui_inputs[k][ + "value"][_k]["value"] = self.presets[_k] + if self.presets.get(k): + self.gui_inputs[k]["value"] = self.presets[k] + + # open widget for plugins inputs + widget = self.widget(self.gui_name, self.gui_info, self.gui_inputs) + widget.exec_() + + if len(self.selected) < 1: + return + + if not widget.result: + print("Operation aborted") + return + + self.rename_add = 0 + + # get ui output for track name for vertical sync + v_sync_track = widget.result["vSyncTrack"]["value"] + + # sort selected trackItems by + sorted_selected_track_items = list() + unsorted_selected_track_items = list() + for track_item_data in self.selected: + if track_item_data["track"]["name"] in v_sync_track: + sorted_selected_track_items.append(track_item_data) + else: + unsorted_selected_track_items.append(track_item_data) + + sorted_selected_track_items.extend(unsorted_selected_track_items) + + # sequence attrs + sq_frame_start = self.sequence.GetStartFrame() + sq_markers = self.sequence.GetMarkers() + + # create media bin for compound clips (trackItems) + mp_folder = resolve.create_current_sequence_media_bin(self.sequence) + + kwargs = { + "ui_inputs": widget.result, + "avalon": self.data, + "mp_folder": mp_folder, + "sq_frame_start": sq_frame_start, + "sq_markers": sq_markers + } + + for i, track_item_data in enumerate(sorted_selected_track_items): + self.rename_index = i + + # convert track item to timeline media pool item + track_item = resolve.PublishClip( + self, track_item_data, **kwargs).convert() + track_item.SetClipColor(lib.publish_clip_color) diff --git a/pype/plugins/resolve/load/load_sequence.py b/pype/hosts/resolve/plugins/load/load_sequence.py similarity index 100% rename from pype/plugins/resolve/load/load_sequence.py rename to pype/hosts/resolve/plugins/load/load_sequence.py diff --git a/pype/plugins/resolve/publish/collect_instances.py b/pype/hosts/resolve/plugins/publish/collect_instances.py similarity index 100% rename from pype/plugins/resolve/publish/collect_instances.py rename to pype/hosts/resolve/plugins/publish/collect_instances.py diff --git a/pype/plugins/resolve/publish/collect_workfile.py b/pype/hosts/resolve/plugins/publish/collect_workfile.py similarity index 100% rename from pype/plugins/resolve/publish/collect_workfile.py rename to pype/hosts/resolve/plugins/publish/collect_workfile.py diff --git a/pype/plugins/resolve/publish/extract_workfile.py b/pype/hosts/resolve/plugins/publish/extract_workfile.py similarity index 100% rename from pype/plugins/resolve/publish/extract_workfile.py rename to pype/hosts/resolve/plugins/publish/extract_workfile.py