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

Chore: Formatting fixes #283

Merged
merged 14 commits into from
Mar 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def setup_node(self, node):
path = "render/{0}/{0}.".format(node.split("/")[-1])
harmony.send(
{
"function": f"PypeHarmony.Creators.CreateRender.create",
"function": "PypeHarmony.Creators.CreateRender.create",
"args": [node, path]
})
harmony.send(
{
"function": f"PypeHarmony.color",
"function": "PypeHarmony.color",
"args": [[0.9, 0.75, 0.3, 1.0]]
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def process(self, context):
"""Plugin entry point."""
result = harmony.send(
{
f"function": "PypeHarmony.getSceneSettings",
"function": "PypeHarmony.getSceneSettings",
"args": []}
)["result"]

Expand Down Expand Up @@ -62,7 +62,7 @@ def process(self, context):

result = harmony.send(
{
f"function": "PypeHarmony.getVersion",
"function": "PypeHarmony.getVersion",
"args": []}
)["result"]
context.data["harmonyVersion"] = "{}.{}".format(result[0], result[1])
36 changes: 13 additions & 23 deletions client/ayon_core/hosts/hiero/api/otio/hiero_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ def apply_transition(otio_track, otio_item, track):
if transition_type == 'dissolve':
transition_func = getattr(
hiero.core.Transition,
'create{kind}DissolveTransition'.format(kind=kind)
"create{kind}DissolveTransition".format(kind=kind)
)

try:
transition = transition_func(
item_in,
item_out,
otio_item.in_offset.value,
otio_item.out_offset.value
otio_item.out_offset.value,
)

# Catch error raised if transition is bigger than TrackItem source
Expand All @@ -134,7 +134,7 @@ def apply_transition(otio_track, otio_item, track):

transition = transition_func(
item_out,
otio_item.out_offset.value
otio_item.out_offset.value,
)

elif transition_type == 'fade_out':
Expand Down Expand Up @@ -183,9 +183,7 @@ def prep_url(url_in):
def create_offline_mediasource(otio_clip, path=None):
global _otio_old

hiero_rate = hiero.core.TimeBase(
otio_clip.source_range.start_time.rate
)
hiero_rate = hiero.core.TimeBase(otio_clip.source_range.start_time.rate)

try:
legal_media_refs = (
Expand All @@ -212,7 +210,7 @@ def create_offline_mediasource(otio_clip, path=None):
source_range.start_time.value,
source_range.duration.value,
hiero_rate,
source_range.start_time.value
source_range.start_time.value,
)

return media
Expand Down Expand Up @@ -385,7 +383,8 @@ def create_trackitem(playhead, track, otio_clip, clip):
# Only reverse effect can be applied here
if abs(time_scalar) == 1.:
trackitem.setPlaybackSpeed(
trackitem.playbackSpeed() * time_scalar)
trackitem.playbackSpeed() * time_scalar
)

elif isinstance(effect, otio.schema.FreezeFrame):
# For freeze frame, playback speed must be set after range
Expand All @@ -397,28 +396,21 @@ def create_trackitem(playhead, track, otio_clip, clip):
source_in = source_range.end_time_inclusive().value

timeline_in = playhead + source_out
timeline_out = (
timeline_in +
source_range.duration.value
) - 1
timeline_out = (timeline_in + source_range.duration.value) - 1
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved
else:
# Normal playback speed
source_in = source_range.start_time.value
source_out = source_range.end_time_inclusive().value

timeline_in = playhead
timeline_out = (
timeline_in +
source_range.duration.value
) - 1
timeline_out = (timeline_in + source_range.duration.value) - 1
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved

# Set source and timeline in/out points
trackitem.setTimes(
timeline_in,
timeline_out,
source_in,
source_out

source_out,
)

# Apply playback speed for freeze frames
Expand All @@ -435,7 +427,8 @@ def create_trackitem(playhead, track, otio_clip, clip):


def build_sequence(
otio_timeline, project=None, sequence=None, track_kind=None):
otio_timeline, project=None, sequence=None, track_kind=None
):
if project is None:
if sequence:
project = sequence.project()
Expand Down Expand Up @@ -509,10 +502,7 @@ def build_sequence(

# Create TrackItem
trackitem = create_trackitem(
playhead,
track,
otio_clip,
clip
playhead, track, otio_clip, clip
)

# Add markers
Expand Down
1 change: 0 additions & 1 deletion client/ayon_core/hosts/hiero/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ def _populate_data(self):
repr = self.context["representation"]
repr_cntx = repr["context"]
folder_path = self.context["folder"]["path"]
folder_name = self.context["folder"]["name"]
product_name = self.context["product"]["name"]
representation = repr["name"]
self.data["clip_name"] = self.clip_name_template.format(**repr_cntx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def _setStatus(self, status):
global gStatusTags

# Get a valid Tag object from the Global list of statuses
if not status in gStatusTags.keys():
if status not in gStatusTags.keys():
print("Status requested was not a valid Status string.")
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,29 @@ def apply_transition(otio_track, otio_item, track):
if transition_type == "dissolve":
transition_func = getattr(
hiero.core.Transition,
'create{kind}DissolveTransition'.format(kind=kind)
"create{kind}DissolveTransition".format(kind=kind)
)

transition = transition_func(
item_in,
item_out,
otio_item.in_offset.value,
otio_item.out_offset.value
otio_item.out_offset.value,
)

elif transition_type == "fade_in":
transition_func = getattr(
hiero.core.Transition,
'create{kind}FadeInTransition'.format(kind=kind)
)
transition = transition_func(
item_out,
otio_item.out_offset.value
)
transition = transition_func(item_out, otio_item.out_offset.value)

elif transition_type == "fade_out":
transition_func = getattr(
hiero.core.Transition,
'create{kind}FadeOutTransition'.format(kind=kind)
)
transition = transition_func(
item_in,
otio_item.in_offset.value
"create{kind}FadeOutTransition".format(kind=kind)
)
transition = transition_func(item_in, otio_item.in_offset.value)

else:
# Unknown transition
Expand All @@ -138,11 +132,10 @@ def apply_transition(otio_track, otio_item, track):
# Apply transition to track
track.addTransition(transition)

except Exception, e:
except Exception as e:
sys.stderr.write(
'Unable to apply transition "{t}": "{e}"\n'.format(
t=otio_item,
e=e
t=otio_item, e=e
)
)

Expand All @@ -153,18 +146,13 @@ def prep_url(url_in):
if url.startswith("file://localhost/"):
return url.replace("file://localhost/", "")

url = '{url}'.format(
sep=url.startswith(os.sep) and "" or os.sep,
url=url.startswith(os.sep) and url[1:] or url
)
url = "{url}".format(url=url.startswith(os.sep) and url[1:] or url)
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved

return url


def create_offline_mediasource(otio_clip, path=None):
hiero_rate = hiero.core.TimeBase(
otio_clip.source_range.start_time.rate
)
hiero_rate = hiero.core.TimeBase(otio_clip.source_range.start_time.rate)

if isinstance(otio_clip.media_reference, otio.schema.ExternalReference):
source_range = otio_clip.available_range()
Expand All @@ -180,7 +168,7 @@ def create_offline_mediasource(otio_clip, path=None):
source_range.start_time.value,
source_range.duration.value,
hiero_rate,
source_range.start_time.value
source_range.start_time.value,
)

return media
Expand All @@ -203,7 +191,7 @@ def load_otio(otio_file):
"MAGENTA": "Magenta",
"BLACK": "Blue",
"WHITE": "Green",
"MINT": "Cyan"
"MINT": "Cyan",
}


Expand Down Expand Up @@ -254,12 +242,6 @@ def add_markers(otio_item, hiero_item, tagsbin):
if _tag is None:
_tag = hiero.core.Tag(marker_color_map[marker.color])

start = marker.marked_range.start_time.value
end = (
marker.marked_range.start_time.value +
marker.marked_range.duration.value
)

tag = hiero_item.addTag(_tag)
tag.setName(marker.name or marker_color_map[marker_color])

Expand All @@ -275,12 +257,12 @@ def create_track(otio_track, tracknum, track_kind):
# Create a Track
if otio_track.kind == otio.schema.TrackKind.Video:
track = hiero.core.VideoTrack(
otio_track.name or 'Video{n}'.format(n=tracknum)
otio_track.name or "Video{n}".format(n=tracknum)
)

else:
track = hiero.core.AudioTrack(
otio_track.name or 'Audio{n}'.format(n=tracknum)
otio_track.name or "Audio{n}".format(n=tracknum)
)

return track
Expand Down Expand Up @@ -315,34 +297,25 @@ def create_trackitem(playhead, track, otio_clip, clip, tagsbin):
for effect in otio_clip.effects:
if isinstance(effect, otio.schema.LinearTimeWarp):
trackitem.setPlaybackSpeed(
trackitem.playbackSpeed() *
effect.time_scalar
trackitem.playbackSpeed() * effect.time_scalar
)

# If reverse playback speed swap source in and out
if trackitem.playbackSpeed() < 0:
source_out = source_range.start_time.value
source_in = (
source_range.start_time.value +
source_range.duration.value
source_range.start_time.value + source_range.duration.value
) - 1
timeline_in = playhead + source_out
timeline_out = (
timeline_in +
source_range.duration.value
) - 1
timeline_out = (timeline_in + source_range.duration.value) - 1
else:
# Normal playback speed
source_in = source_range.start_time.value
source_out = (
source_range.start_time.value +
source_range.duration.value
source_range.start_time.value + source_range.duration.value
) - 1
timeline_in = playhead
timeline_out = (
timeline_in +
source_range.duration.value
) - 1
timeline_out = (timeline_in + source_range.duration.value) - 1

# Set source and timeline in/out points
trackitem.setSourceIn(source_in)
Expand All @@ -357,7 +330,8 @@ def create_trackitem(playhead, track, otio_clip, clip, tagsbin):


def build_sequence(
otio_timeline, project=None, sequence=None, track_kind=None):
otio_timeline, project=None, sequence=None, track_kind=None
):

if project is None:
if sequence:
Expand Down Expand Up @@ -414,8 +388,7 @@ def build_sequence(
if isinstance(otio_clip, otio.schema.Stack):
bar = hiero.ui.mainWindow().statusBar()
bar.showMessage(
"Nested sequences are created separately.",
timeout=3000
"Nested sequences are created separately.", timeout=3000
)
build_sequence(otio_clip, project, otio_track.kind)

Expand All @@ -428,11 +401,7 @@ def build_sequence(

# Create TrackItem
trackitem = create_trackitem(
playhead,
track,
otio_clip,
clip,
tagsbin
playhead, track, otio_clip, clip, tagsbin
)

# Add trackitem to track
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/hiero/api/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def update_tag(tag, data):
# set all data metadata to tag metadata
for _k, _v in data_mtd.items():
value = str(_v)
if type(_v) == dict:
if isinstance(_v, dict):
value = json.dumps(_v)

# set the value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,18 @@ def collect_sub_track_items(self, tracks):
# collect all subtrack items
sub_track_items = {}
for track in tracks:
items = track.items()

effet_items = track.subTrackItems()
effect_items = track.subTrackItems()

# skip if no clips on track > need track with effect only
if not effet_items:
if not effect_items:
continue

# skip all disabled tracks
if not track.isEnabled():
continue

track_index = track.trackIndex()
_sub_track_items = phiero.flatten(effet_items)
_sub_track_items = phiero.flatten(effect_items)

_sub_track_items = list(_sub_track_items)
# continue only if any subtrack items are collected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def process(self, instance):
speed = track_item.playbackSpeed()

# calculate available material before retime
available_in = int(track_item.handleInLength() * speed)
available_out = int(track_item.handleOutLength() * speed)
# available_in = int(track_item.handleInLength() * speed)
# available_out = int(track_item.handleOutLength() * speed)
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved

self.log.debug((
"_BEFORE: \n timeline_in: `{0}`,\n timeline_out: `{1}`, \n "
Expand Down
Loading
Loading