Skip to content

Commit bee0789

Browse files
committed
Added handling for extra blank lines after the Column statement.\nCo-authored-by: Sean Wallitsch <shidarin@alphamatte.com>
Signed-off-by: Eric Reinecke <reinecke.eric@gmail.com>
1 parent 3a88cf8 commit bee0789

File tree

4 files changed

+65
-7
lines changed

4 files changed

+65
-7
lines changed

src/otio_ale_adapter/ale.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,13 @@ def _read_columns(lines):
214214
Consumes the Column information from the ALE and returns the list of
215215
columns.
216216
"""
217-
line = lines.pop(0)
217+
try:
218+
line = lines.pop(0)
219+
while not line.strip():
220+
line = lines.pop(0)
221+
except IndexError:
222+
raise ALEParseError("Unexpected end of file after 'Column'")
223+
218224
columns = line.split("\t")
219225

220226
return columns
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Heading
2+
3+
FIELD_DELIM TABS
4+
5+
VIDEO_FORMAT 1080
6+
7+
AUDIO_FORMAT 48khz
8+
9+
FPS 25
10+
11+
12+
13+
Column
14+
15+
Name Tracks Start End Take Tape UNC FPS Reel Scene Shoot date Manufacturer Source Resolution Source Bit Depth DESCRIPT Comments Audio SR Audio Bit Depth Auxiliary TC1 KN Start Source File Path Filter Camera ID ISO Lens Number Camera Serial # Camera Type White Point (Kelvin) Angle Camera Clip Number Stereoscopic Eye Gamma Space LUT 1 ASC_SOP ASC_SAT RESOLVE_SIZING
16+
17+
18+
19+
Data
20+
21+
A020C003_150905_E2XZ.mov V 05:42:12:20 05:42:30:12 A020E2XZ Y:\Pennrand_CompWorkflow_XXXXXX\04_Compositing\11_Render_Compositing\PennComp_Za250\PennComp_Za250_Raw\A020C003_150905_E2XZ.mov 25 A020E2XZ 20150905 DaVinci Resolve 2048x1152 16 Y:\Pennrand_CompWorkflow_XXXXXX\04_Compositing\11_Render_Compositing\PennComp_Za250\PennComp_Za250_Raw\A020C003_150905_E2XZ.mov 0 E2XZ 800 0 3120 Alexa Plus 4700 1800 A A020C003_150905_E2XZ SINGLE LOG-C None (1.1822 1.2183 1.2284)(-0.2429 -0.2823 -0.2849)(0.7283 0.7096 0.7054) 1.0680 (0.0000 0.0000 1.0000 0.0000 0.0000 0 0)
22+

tests/sample_data/sample_no_blank_lines_between_sections.ale renamed to tests/sample_data/sample_no_blanks.ale

File renamed without changes.

tests/test_ale_adapter.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
EXAMPLE_PATH = os.path.join(SAMPLE_DATA_DIR, "sample.ale")
1414
EXAMPLE2_PATH = os.path.join(SAMPLE_DATA_DIR, "sample2.ale")
1515
EXAMPLE_CDL_PATH = os.path.join(SAMPLE_DATA_DIR, "sample_cdl.ale")
16-
EXAMPLE_NO_SECTION_NEWLINE_PATH = os.path.join(
17-
SAMPLE_DATA_DIR, "sample_no_blank_lines_between_sections.ale"
18-
)
1916
EXAMPLEUHD_PATH = os.path.join(SAMPLE_DATA_DIR, "sampleUHD.ale")
20-
17+
EXAMPLE_BLANK_PATH = os.path.join(SAMPLE_DATA_DIR, "sample_blanks.ale")
18+
EXAMPLE_NO_BLANKS = os.path.join(SAMPLE_DATA_DIR, "sample_no_blanks.ale")
2119

2220
class ALEAdapterTest(unittest.TestCase):
2321

@@ -174,9 +172,41 @@ def test_ale_uhd(self):
174172
)
175173
self.assertEqual(frmt, "CUSTOM")
176174

177-
def test_ale_no_newline_between_sections(self):
178-
ale_path = EXAMPLE_NO_SECTION_NEWLINE_PATH
175+
def test_ale_read_blank_lines(self):
176+
ale_path = EXAMPLE_BLANK_PATH
179177
collection = otio.adapters.read_from_file(ale_path)
178+
self.assertTrue(collection is not None)
179+
self.assertEqual(type(collection), otio.schema.SerializableCollection)
180+
self.assertEqual(len(collection), 1)
181+
# The ALE header information is the original FPS stored in the file,
182+
# and not the nearest SMPTE timecode rate
183+
fps = float(collection.metadata.get("ALE").get("header").get("FPS"))
184+
self.assertEqual(fps, 25)
185+
self.assertEqual([c.name for c in collection], [
186+
"A020C003_150905_E2XZ.mov"
187+
])
188+
self.assertEqual(collection[0].source_range, otio.opentime.TimeRange(
189+
otio.opentime.from_timecode("05:42:12:20", fps),
190+
otio.opentime.from_timecode("00:00:17:17", fps)
191+
))
192+
193+
# Slope, offset, and power values are of type _otio.AnyVector
194+
# So we have to convert them to lists otherwise
195+
# the comparison between those two types would fail
196+
197+
self.assertEqual(
198+
list(collection[0].metadata['cdl']['asc_sop']['slope']),
199+
[1.1822, 1.2183, 1.2284])
200+
self.assertEqual(
201+
list(collection[0].metadata['cdl']['asc_sop']['offset']),
202+
[-0.2429, -0.2823, -0.2849])
203+
self.assertEqual(
204+
list(collection[0].metadata['cdl']['asc_sop']['power']),
205+
[0.7283, 0.7096, 0.7054])
206+
self.assertEqual(collection[0].metadata['cdl']['asc_sat'], 1.0680)
207+
208+
def test_ale_no_newline_between_sections(self):
209+
collection = otio.adapters.read_from_file(EXAMPLE_NO_BLANKS)
180210
assert len(collection) == 6
181211

182212
# Spot-check one of the clips

0 commit comments

Comments
 (0)