fixes python3 compatibility

This commit is contained in:
Jakub Jezek 2021-12-02 19:02:04 +01:00
parent 5ace3472d7
commit fcec9a820d
No known key found for this signature in database
GPG key ID: D8548FBF690B100A
5 changed files with 31 additions and 22 deletions

View file

@ -23,6 +23,7 @@ from .pipeline import (
from .lib import (
pype_tag_name,
flatten,
get_track_items,
get_current_project,
get_current_sequence,
@ -75,6 +76,7 @@ __all__ = [
# Lib functions
"pype_tag_name",
"flatten",
"get_track_items",
"get_current_project",
"get_current_sequence",

View file

@ -37,14 +37,14 @@ self.default_bin_name = "openpypeBin"
AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype")
def get_current_project(remove_untitled=False):
def flatten(l):
for i in l:
if isinstance(i, (list, tuple)):
yield from flatten(i)
else:
yield i
def flatten(input_list):
for item in input_list:
if isinstance(item, (list, tuple)):
yield from flatten(item)
else:
yield item
def get_current_project(remove_untitled=False):
projects = flatten(hiero.core.projects())
if not remove_untitled:
return next(iter(projects))
@ -256,7 +256,7 @@ def set_track_item_pype_tag(track_item, data=None):
Returns:
hiero.core.Tag
"""
data = data or dict()
data = data or {}
# basic Tag's attribute
tag_data = {
@ -290,7 +290,7 @@ def get_track_item_pype_data(track_item):
Returns:
dict: data found on pype tag
"""
data = dict()
data = {}
# get pype data tag from track item
tag = get_track_item_pype_tag(track_item)
@ -305,8 +305,20 @@ def get_track_item_pype_data(track_item):
try:
# capture exceptions which are related to strings only
value = ast.literal_eval(v)
except (ValueError, SyntaxError):
if re.match(r"^[\d]+$", v):
value = int(v)
elif re.match(r"^True$", v):
value = True
elif re.match(r"^False$", v):
value = False
elif re.match(r"^None$", v):
value = None
elif re.match(r"^[\w\d_]+$", v):
value = v
else:
value = ast.literal_eval(v)
except (ValueError, SyntaxError) as msg:
log.warning(msg)
value = v
data.update({key: value})

View file

@ -81,13 +81,11 @@ def create_time_effects(otio_clip, track_item):
otio_effect = otio.schema.LinearTimeWarp()
otio_effect.name = "Speed"
otio_effect.time_scalar = speed
otio_effect.metadata = {}
# freeze frame effect
if speed == 0.:
otio_effect = otio.schema.FreezeFrame()
otio_effect.name = "FreezeFrame"
otio_effect.metadata = {}
if otio_effect:
# add otio effect to clip effects

View file

@ -4,8 +4,6 @@ from openpype.hosts.hiero import api as phiero
from openpype.hosts.hiero.api.otio import hiero_export
import hiero
from compiler.ast import flatten
# # developer reload modules
from pprint import pformat
@ -339,10 +337,10 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
continue
track_index = track.trackIndex()
_sub_track_items = flatten(track.subTrackItems())
_sub_track_items = phiero.flatten(track.subTrackItems())
# continue only if any subtrack items are collected
if len(_sub_track_items) < 1:
if not list(_sub_track_items):
continue
enabled_sti = []
@ -357,7 +355,7 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
enabled_sti.append(_sti)
# continue only if any subtrack items are collected
if len(enabled_sti) < 1:
if not enabled_sti:
continue
# add collection of subtrackitems to dict
@ -371,7 +369,7 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
Returns list of Clip's hiero.core.Annotation
"""
annotations = []
subTrackItems = flatten(clip.subTrackItems())
subTrackItems = phiero.flatten(clip.subTrackItems())
annotations += [item for item in subTrackItems if isinstance(
item, hiero.core.Annotation)]
return annotations
@ -382,7 +380,7 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
Returns list of Clip's hiero.core.SubTrackItem
"""
subtracks = []
subTrackItems = flatten(clip.parent().subTrackItems())
subTrackItems = phiero.flatten(clip.parent().subTrackItems())
for item in subTrackItems:
if "TimeWarp" in item.name():
continue

View file

@ -171,8 +171,7 @@ class CollectOcioSubsetResources(pyblish.api.InstancePlugin):
instance.data["representations"].append(repre)
self.log.debug(">>>>>>>> {}".format(repre))
import pprint
self.log.debug(pprint.pformat(instance.data))
self.log.debug(instance.data)
def _create_representation(self, start, end, **kwargs):
"""