Skip to content

Commit e8a2dc4

Browse files
authored
FCP 7 XML - Fix failure on empty name tags (#674)
* Empty or missing name elements in FCP XML use empty string for names instead of failing trying to instantiate OTIO objects with None. * Added test file and additional unittesting for FCP 7 XML missing name issue
1 parent 0421b89 commit e8a2dc4

File tree

3 files changed

+22370
-8
lines changed

3 files changed

+22370
-8
lines changed

src/py-opentimelineio/opentimelineio/adapters/fcp_xml.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,19 @@ def _element_identification_string(element):
181181

182182
def _name_from_element(element):
183183
"""
184-
Fetches the name from the ``name`` element child of the provided element.
185-
If no element exists, returns ``None``.
184+
Fetches a name suitable for OTIO objects from the ``name`` element child
185+
of the provided element.
186+
If no element exists, returns empty string.
186187
187188
:param element: The element to find the name for.
188189
189-
:return: The name string or ``None``
190+
:return: The name string or and empty string
190191
"""
191192
name_elem = element.find("./name")
192193
if name_elem is not None:
193-
return name_elem.text
194+
return name_elem.text if name_elem.text is not None else ""
194195

195-
return None
196+
return ""
196197

197198

198199
def _rate_for_element(element):
@@ -1107,7 +1108,7 @@ def effect_from_filter_element(self, filter_element):
11071108
"could not find effect in filter: {}".format(filter_element)
11081109
)
11091110

1110-
name = effect_element.find("./name").text
1111+
name = _name_from_element(effect_element)
11111112

11121113
effect_metadata = _xml_tree_to_dict(effect_element, {"name"})
11131114

@@ -1138,7 +1139,7 @@ def transition_for_element(self, item_element, context):
11381139
cut_point = _transition_cut_point(item_element, context)
11391140

11401141
transition = schema.Transition(
1141-
name=item_element.find('./effect/name').text,
1142+
name=_name_from_element(item_element.find('./effect')),
11421143
transition_type=schema.TransitionTypes.SMPTE_Dissolve,
11431144
in_offset=cut_point - start,
11441145
out_offset=end - cut_point,

0 commit comments

Comments
 (0)