Skip to content

Commit

Permalink
Added contextual data to EDLParserError where available
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Reinecke <ereinecke@netflix.com>
  • Loading branch information
reinecke committed Dec 11, 2023
1 parent 3af9b9c commit 5e86a53
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/otio_cmx3600_adapter/cmx_3600_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ def load_from_statements(self, statements: Iterator[EDLStatement]):
should_start_new_event = True
elif current_event is None:
raise EDLParseError(
f"Unknown statement type on line {statement.line_number}"
f"Unknown statement type on line {statement.line_number}",
line_number=statement.line_number,
)

# accumulate statements in the same event
Expand Down Expand Up @@ -575,13 +576,17 @@ def make_transition(
else:
raise EDLParseError(
f"Transition type '{effect.type}' on line {statement.line_number}"
" not supported by the CMX EDL reader currently."
" not supported by the CMX EDL reader currently.",
line_number=statement.line_number,
event_number=statement.edit_number,
)

if effect.transition_duration is None:
raise EDLParseError(
f"Transition type '{effect.type}' on line {statement.line_number}"
"is missing a duration."
"is missing a duration.",
line_number = statement.line_number,
event_number = statement.edit_number,
)
transition_duration = opentime.RationalTime(
effect.transition_duration,
Expand Down
8 changes: 6 additions & 2 deletions src/otio_cmx3600_adapter/edl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def statements_from_lines(
if len(fields) < 3:
raise EDLParseError(
f"incorrect number of fields [{len(fields)}] in line number:"
f" {line_number} statement: {line}"
f" {line_number} statement: {line}",
line_number=line_number,
event_number=edit_number,
)

# consume the fields from the head of the line
Expand Down Expand Up @@ -164,7 +166,9 @@ def statements_from_lines(
if (len(fields) < 6 or len(fields) > 8) and not allow_best_effort_parsing:
raise EDLParseError(
f"incorrect number of fields [{len(fields)}] in line number:"
f" {line_number} statement: {line}"
f" {line_number} statement: {line}",
line_number=line_number,
event_number=edit_number,
)

# Consume the record and source fields from the end of the line back
Expand Down
10 changes: 9 additions & 1 deletion src/otio_cmx3600_adapter/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from opentimelineio import exceptions

from typing import Optional


class EDLParseError(exceptions.OTIOError):
pass
line_number: Optional[int] = None
event_number: Optional[str] = None

def __init__(self, message, line_number=None, event_number=None):
super().__init__(message)
self.line_number = line_number
self.event_number = event_number

0 comments on commit 5e86a53

Please sign in to comment.