Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ruff toml with code fixes #37

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/ayon_flame/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,8 @@ def _get_resolution_info_from_origin(self, xml_data):

# height
out_feed_height_obj = out_feed.find("storageFormat/height")
self.height = int(self._get_typed_value(out_feed_height_obj))
self.height = int(
self._get_typed_value(out_feed_height_obj))

# pixel aspect ratio
out_feed_pixel_aspect_obj = out_feed.find(
Expand Down
8 changes: 6 additions & 2 deletions client/ayon_flame/api/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_main_window():
None
)
return _MAIN_WINDOW


class _FlameMenuApp(object):
def __init__(self, framework):
Expand Down Expand Up @@ -83,7 +83,11 @@ def __init__(self, framework):
project_name = get_current_project_name()
self.menu = {
"actions": [
{"name": f"0 - {project_name or 'project'}", "isEnabled": False}],
{
"name": f"0 - {project_name or 'project'}",
"isEnabled": False
}
],
"name": self.menu_group_name,
}
self.tools_helper = host_tools.HostToolsHelper(
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_flame/otio/flame_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ def create_otio_clip(clip_data):

# create source range
available_media_start = media_reference.available_range.start_time
conformed_media_start = available_media_start.value_rescaled_to(CTX.get_fps())
conformed_media_start = available_media_start.value_rescaled_to(
CTX.get_fps())
source_range = create_otio_time_range(
conformed_media_start + source_in,
_clip_record_duration,
Expand Down
86 changes: 47 additions & 39 deletions client/ayon_flame/plugins/create/create_shot_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def create(self, instance_data, _):
})

new_instance = CreatedInstance(
self.product_type, instance_data["productName"], instance_data, self
self.product_type,
instance_data["productName"],
instance_data,
self
)
self._add_instance_to_context(new_instance)
new_instance.transient_data["has_promised_context"] = True
Expand Down Expand Up @@ -620,7 +623,8 @@ def create(self, product_name, instance_data, pre_create_data):
# Delete any existing instances previously generated for the clip.
prev_tag_data = lib.get_segment_data_marker(segment)
if prev_tag_data:
for creator_id, inst_data in prev_tag_data.get(_CONTENT_ID, {}).items():
for creator_id, inst_data in prev_tag_data.get(
_CONTENT_ID, {}).items():
creator = self.create_context.creators[creator_id]
prev_instance = self.create_context.instances_by_id.get(
inst_data["instance_id"]
Expand All @@ -639,7 +643,8 @@ def create(self, product_name, instance_data, pre_create_data):
pre_create_data.get("export_audio", False)
)

enabled_creators = tuple(cre for cre, enabled in all_creators.items() if enabled)
enabled_creators = tuple(
cre for cre, enabled in all_creators.items() if enabled)
clip_instances = {}
shot_folder_path = segment_instance_data["folderPath"]
shot_instances = self.shot_instances.setdefault(
Expand All @@ -659,32 +664,35 @@ def create(self, product_name, instance_data, pre_create_data):
segment_duration = int(segment_data["record_duration"])
workfileFrameStart = sub_instance_data[
"workfileFrameStart"]
sub_instance_data.update({
"variant": "main",
"productType": "shot",
"productName": "shotMain",
"creator_attributes": {
"workfileFrameStart": sub_instance_data[
"workfileFrameStart"],
"handleStart": sub_instance_data["handleStart"],
"handleEnd": sub_instance_data["handleEnd"],
"frameStart": workfileFrameStart,
"frameEnd": (
workfileFrameStart + segment_duration),
"clipIn": int(segment_data["record_in"]),
"clipOut": int(segment_data["record_out"]),
"clipDuration": segment_duration,
"sourceIn": int(segment_data["source_in"]),
"sourceOut": int(segment_data["source_out"]),
"includeHandles": pre_create_data[
"includeHandles"],
"retimedHandles": pre_create_data[
"retimedHandles"],
"retimedFramerange": pre_create_data[
"retimedFramerange"],
},
"label": f"{shot_folder_path} shot",
})
sub_instance_data.update(
{
"variant": "main",
"productType": "shot",
"productName": "shotMain",
"creator_attributes": {
"workfileFrameStart": workfileFrameStart,
"handleStart": sub_instance_data[
"handleStart"],
"handleEnd": sub_instance_data["handleEnd"],
"frameStart": workfileFrameStart,
"frameEnd": (
workfileFrameStart + segment_duration),
"clipIn": int(segment_data["record_in"]),
"clipOut": int(segment_data["record_out"]),
"clipDuration": segment_duration,
"sourceIn": int(segment_data["source_in"]),
"sourceOut": int(segment_data["source_out"]),
"includeHandles": pre_create_data[
"includeHandles"],
"retimedHandles": pre_create_data[
"retimedHandles"],
"retimedFramerange": pre_create_data[
"retimedFramerange"
],
},
"label": f"{shot_folder_path} shot",
}
)

# Plate,
# insert parent instance data to allow
Expand All @@ -693,7 +701,8 @@ def create(self, product_name, instance_data, pre_create_data):
parenting_data = shot_instances[shot_creator_id]
sub_instance_data.update(
{
"parent_instance_id": parenting_data["instance_id"],
"parent_instance_id": parenting_data[
"instance_id"],
"label": (
f"{sub_instance_data['folderPath']} "
f"{sub_instance_data['productName']}"
Expand Down Expand Up @@ -722,7 +731,8 @@ def create(self, product_name, instance_data, pre_create_data):
parenting_data = shot_instances[shot_creator_id]
sub_instance_data.update(
{
"parent_instance_id": parenting_data["instance_id"],
"parent_instance_id": parenting_data[
"instance_id"],
"label": (
f"{sub_instance_data['folderPath']} "
f"{sub_instance_data['productName']}"
Expand Down Expand Up @@ -757,8 +767,8 @@ def create(self, product_name, instance_data, pre_create_data):

return instances

def _create_and_add_instance(self, data, creator_id,
segment, instances):
def _create_and_add_instance(
self, data, creator_id, segment, instances):
"""
Args:
data (dict): The data to re-recreate the instance from.
Expand Down Expand Up @@ -797,17 +807,15 @@ def _collect_legacy_instance(self, segment, marker_data):
sub_instance_data = instance_data.copy()
segment_data = flame_export.get_segment_attributes(segment)
segment_duration = int(segment_data["record_duration"])
workfileFrameStart = \
sub_instance_data["workfileFrameStart"]
workfileFrameStart = sub_instance_data["workfileFrameStart"]
sub_instance_data.update({
"creator_attributes": {
"workfileFrameStart": \
sub_instance_data["workfileFrameStart"],
"workfileFrameStart": workfileFrameStart,
"handleStart": sub_instance_data["handleStart"],
"handleEnd": sub_instance_data["handleEnd"],
"frameStart": workfileFrameStart,
"frameEnd": (workfileFrameStart +
segment_duration),
"frameEnd": (
workfileFrameStart + segment_duration),
"clipIn": int(segment_data["record_in"]),
"clipOut": int(segment_data["record_out"]),
"clipDuration": segment_duration,
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_flame/plugins/create/create_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _create_new_instance(self):

def create(self, options=None):
"""Auto-create an instance by default."""
instance_data = self._load_instance_data()
instance_data = self._load_instance_data()
if instance_data:
return

Expand Down
6 changes: 4 additions & 2 deletions client/ayon_flame/plugins/load/load_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def load(self, context, name, namespace, options):
openclip_path
)

# add additional metadata from the version to imprint basic folder attributes
# add additional metadata from the version to imprint basic
# folder attributes
add_keys = [
"frameStart", "frameEnd", "source", "author",
"fps", "handleStart", "handleEnd"
Expand Down Expand Up @@ -209,7 +210,8 @@ def _get_segment_from_clip(self, clip):
# if colorspace:
# clip.setSourceMediaColourTransform(colorspace)

# # add additional metadata from the version to imprint basic folder attributes
# # add additional metadata from the version to imprint basic
# # folder attributes
# add_keys = [
# "frameStart", "frameEnd", "source", "author",
# "fps", "handleStart", "handleEnd"
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_flame/plugins/load/load_clip_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def load(self, context, name, namespace, options):
openclip_path
)

# add additional metadata from the version to imprint basic folder attributes
# add additional metadata from the version to imprint basic
# folder attributes
add_keys = [
"frameStart", "frameEnd", "source", "author",
"fps", "handleStart", "handleEnd"
Expand Down
3 changes: 2 additions & 1 deletion client/ayon_flame/plugins/publish/collect_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def process(self, instance):
otio_timeline, instance.data["clip_index"]
)
if not otio_clip:
raise RuntimeError("Could not retrieve otioClip for shot %r", instance)
raise RuntimeError(
f"Could not retrieve otioClip for shot {instance}")

instance.data["otioClip"] = otio_clip

Expand Down
6 changes: 4 additions & 2 deletions client/ayon_flame/plugins/publish/collect_plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def process(self, instance):
otio_timeline, instance.data["clip_index"]
)
if not otio_clip:
raise RuntimeError("Could not retrieve otioClip for shot %r", instance)
raise RuntimeError(
f"Could not retrieve otioClip for shot {instance}")

instance.data["otioClip"] = otio_clip

Expand Down Expand Up @@ -60,4 +61,5 @@ def process(self, instance):
version_data["colorSpace"] = clip_data["colour_space"]
instance.data["colorspace"] = clip_data["colour_space"]

instance.data["shotDurationFromSource"] = instance.data.get("retimedFramerange")
instance.data["shotDurationFromSource"] = instance.data.get(
"retimedFramerange")
25 changes: 12 additions & 13 deletions client/ayon_flame/plugins/publish/collect_shots.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CollectShot(pyblish.api.InstancePlugin):

# TODO: add to own plugin for Flame
# TODO: toggle for marking task which should be used for product parent
add_tasks = []
add_tasks = []

@classmethod
def _inject_editorial_shared_data(cls, instance):
Expand Down Expand Up @@ -84,7 +84,8 @@ def process(self, instance):
otio_timeline, instance.data["clip_index"]
)
if not otio_clip:
raise RuntimeError("Could not retrieve otioClip for shot %r", instance)
raise RuntimeError(
f"Could not retrieve otioClip for shot {instance}")

# Compute fps from creator attribute.
creator_attrs = instance.data['creator_attributes']
Expand All @@ -99,18 +100,19 @@ def process(self, instance):
for item in instance.context.data["flameSegments"]:
item_data = ayfapi.get_segment_data_marker(item) or {}
if item_data.get("clip_index") == instance.data["clip_index"]:
segment_item = item
break
segment_item = item
break

if segment_item is None:
raise PublishError("Could not retrieve source from sequence segments.")
raise PublishError(
"Could not retrieve source from sequence segments.")

comment_attributes = self._get_comment_attributes(segment_item)
instance.data.update(comment_attributes)

clip_data = ayfapi.get_segment_attributes(segment_item)
clip_name = clip_data["segment_name"]
self.log.debug("clip_name: {}".format(clip_name))
self.log.debug(f"clip_name: {clip_name}")

# get file path
file_path = clip_data["fpath"]
Expand Down Expand Up @@ -142,8 +144,6 @@ def process(self, instance):
"path": file_path,
"sourceFirstFrame": int(first_frame),
"workfileFrameStart": workfile_start,

#TODO
"flameAddTasks": self.add_tasks,
"tasks": {
task["name"]: {"type": task["type"]}
Expand All @@ -153,7 +153,7 @@ def process(self, instance):

self._get_resolution_to_data(instance.data, instance.context)
self._inject_editorial_shared_data(instance)
self.log.debug("__ inst_data: {}".format(pformat(instance.data)))
self.log.debug(f"__ inst_data: {pformat(instance.data)}")

@staticmethod
def _set_workfile_start(data):
Expand Down Expand Up @@ -279,15 +279,14 @@ def _get_head_tail(self, clip_data, otio_clip, handle_start, handle_end):
# calculate head and tail with forward compatibility
head = clip_data.get("segment_head")
tail = clip_data.get("segment_tail")
self.log.debug("__ head: `{}`".format(head))
self.log.debug("__ tail: `{}`".format(tail))
self.log.debug(f"__ head: `{head}`")
self.log.debug(f"__ tail: `{tail}`")

# HACK: it is here to serve for versions below 2021.1
if not any([head, tail]):
retimed_attributes = get_media_range_with_retimes(
otio_clip, handle_start, handle_end)
self.log.debug(
">> retimed_attributes: {}".format(retimed_attributes))
self.log.debug(f">> retimed_attributes: {retimed_attributes}")

# retimed head and tail
head = int(retimed_attributes["handleStart"])
Expand Down
Loading
Loading