Skip to content

Commit c1bf13b

Browse files
committed
added variables to specify color-coding, and updated formatting
Signed-off-by: Yingjie Wang <[email protected]>
1 parent d34ef9d commit c1bf13b

File tree

5 files changed

+607
-492
lines changed

5 files changed

+607
-492
lines changed

src/py-opentimelineio/opentimelineio/console/otiodiff/clipData.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
# TODO: clip comparable??? ClipInfo
44
# source clip or clip ref?
5-
# full name = name + version, name is just name, add ex, split on space, b4 is name, after is version
5+
# full name = name + version, name is just name,
6+
# add ex, split on space, b4 is name, after is version
7+
8+
69
class ClipData:
710
full_name = ""
811
name = ""
912
version = None # currently not used in comparisons
1013
media_ref = None
1114
source_range = otio.opentime.TimeRange()
1215
timeline_range = otio.opentime.TimeRange()
13-
track_num = None # not originally stored in otio.schema.Clip
16+
track_num = None # not originally stored in otio.schema.Clip
1417
source_clip = otio.schema.Clip()
1518
# everything below holds comparison result info
1619
note = ""
@@ -27,9 +30,9 @@ def __init__(self, source_clip, track_num, note=None):
2730
self.source_clip = source_clip
2831
self.note = note
2932

30-
3133
# split full name into name of clip and version by white space
3234
# uses structure of "clipA v1" where clipA is the name and v1 is the version
35+
3336
def splitFullName(self, clip):
3437
shortName = clip.name.split(" ")[0]
3538
version = clip.name.split(" ")[1] if len(clip.name.split(" ")) > 1 else None
@@ -40,19 +43,21 @@ def printData(self):
4043
print("name: ", self.name)
4144
print("version: ", self.version)
4245
print("media ref: ", self.media_ref)
43-
print("source start time: ", self.source_range.start_time.value, " duration: ", self.source_range.duration.value)
44-
print("timeline start time:", self.timeline_range.start_time.value, " duration: ", self.timeline_range.duration.value)
45-
if(self.note != ""):
46+
print("source start time: ", self.source_range.start_time.value,
47+
" duration: ", self.source_range.duration.value)
48+
print("timeline start time:", self.timeline_range.start_time.value,
49+
" duration: ", self.timeline_range.duration.value)
50+
if (self.note != ""):
4651
print("note: ", self.note)
4752
print("source clip: ", self.source.name)
4853

4954
# compare truncated names
5055
def sameName(self, cA):
51-
if(self.name.lower() == cA.name.lower()):
56+
if (self.name.lower() == cA.name.lower()):
5257
return True
5358
else:
5459
return False
55-
60+
5661
# note: local and source duration should always match, can assume same
5762
# compare the duration within the timeline for 2 clips
5863
def sameDuration(self, cA):
@@ -66,17 +71,19 @@ def checkSame(self, cA):
6671
if self.sameName(cA):
6772
# check source range is same
6873
# TODO: call trimmed range instead of source range ???
69-
# TODO: make test where has null source range -> see things break, then go back and change <- low priority
70-
if(self.source_range == cA.source_range):
74+
# TODO: make test where has null source range -> see things break,
75+
# then go back and change <- low priority
76+
if (self.source_range == cA.source_range):
7177
# print(self.name, " ", self.timeline_range, " ", cA.timeline_range)
7278
# check in same place on timeline
73-
if(self.timeline_range == cA.timeline_range):
79+
if (self.timeline_range == cA.timeline_range):
7480
isSame = True
7581
# check duration is same but not necessarily in same place on timeline
7682
# TODO: change to else? (does the elif always run?)
77-
elif(self.sameDuration(cA)):
83+
elif (self.sameDuration(cA)):
7884
# Note: check in relation to left and right?
79-
# know if moved in seq rather than everything shifted over because of lengthen/shorten of other clips
85+
# know if moved in seq rather than everything shifted over
86+
# because of lengthen/shorten of other clips
8087
isSame = True
8188
self.note = "shifted laterally in track"
8289
else:
@@ -86,15 +93,17 @@ def checkSame(self, cA):
8693
pass
8794

8895
return isSame
89-
90-
# compare 2 clips and see if they have been
96+
97+
# compare 2 clips and see if they have been
9198
# compare self: "new", to old
9299
def checkEdited(self, cA):
93100
isEdited = False
94101

95102
# Note: assumption that source range and timeline range duration always equal
96-
# assert(self.source_range.duration.value == self.timeline_range.duration.value), "clip source range and timeline range durations don't match"
97-
# assert(cA.source_range.duration.value == cA.timeline_range.duration.value), "clip source range and timeline range durations don't match"
103+
# assert(self.source_range.duration.value == self.timeline_range.duration.value
104+
# ), "clip source range and timeline range durations don't match"
105+
# assert(cA.source_range.duration.value == cA.timeline_range.duration.value
106+
# ), "clip source range and timeline range durations don't match"
98107

99108
selfDur = self.source_range.duration
100109
cADur = cA.source_range.duration
@@ -109,34 +118,34 @@ def checkEdited(self, cA):
109118
# # self.printData()
110119
# # cA.printData()
111120
# self.note = "source range start times differ"
112-
# isEdited = True
121+
# isEdited = True
113122

114-
if(self.source_range != cA.source_range):
123+
if (self.source_range != cA.source_range):
115124
self.note = "source range changed"
116125
isEdited = True
117126
deltaFramesStr = str(abs(selfDur.to_frames() - cADur.to_frames()))
118127

119-
if(selfDur.value == cADur.value):
128+
if (selfDur.value == cADur.value):
120129
self.note = "start time in source range changed"
121130

122131
# put note assignment into function, return note?
123132
# self, other, olderClipData rather than cA
124133
# clip duration shorter
125-
elif(selfDur.value < cADur.value):
134+
elif (selfDur.value < cADur.value):
126135
self.note = "trimmed " + deltaFramesStr + " frames"
127-
128-
if(selfSourceStart.value == cASourceStart.value):
136+
137+
if (selfSourceStart.value == cASourceStart.value):
129138
self.note = "trimmed tail by " + deltaFramesStr + " frames"
130-
elif(selfSourceStart.value < cASourceStart.value):
139+
elif (selfSourceStart.value < cASourceStart.value):
131140
self.note = "trimmed head by " + deltaFramesStr + " frames"
132141

133142
# clip duration longer
134-
elif(selfDur.value > cADur.value):
143+
elif (selfDur.value > cADur.value):
135144
self.note = "lengthened " + deltaFramesStr + " frames"
136145

137-
if(selfSourceStart.value == cASourceStart.value):
146+
if (selfSourceStart.value == cASourceStart.value):
138147
self.note = "lengthened tail by " + deltaFramesStr + " frames"
139-
elif(selfSourceStart.value > cASourceStart.value):
148+
elif (selfSourceStart.value > cASourceStart.value):
140149
self.note = "lengthened head by " + deltaFramesStr + " frames"
141150

142-
return isEdited
151+
return isEdited

0 commit comments

Comments
 (0)