From: Reinhold Kainhofer Date: Sun, 19 Aug 2007 21:58:27 +0000 (+0200) Subject: Don't crash when a score does not have an explicit key or clef set (e.g. Rosegarden... X-Git-Tag: release/2.11.30-1~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=dffba2a49f12b6f204be1056b8e81b275f0d162f;p=lilypond.git Don't crash when a score does not have an explicit key or clef set (e.g. Rosegarden produces such files). --- diff --git a/python/musicxml.py b/python/musicxml.py index 304b2c62d2..e7fe77d699 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -39,10 +39,13 @@ class Xml_node: p = p.get_parent () def get_typed_children (self, klass): - return [c for c in self._children if isinstance(c, klass)] + if not klass: + return [] + else: + return [c for c in self._children if isinstance(c, klass)] def get_named_children (self, nm): - return self.get_typed_children (class_dict[nm]) + return self.get_typed_children (class_dict.get (nm)) def get_named_child (self, nm): return self.get_maybe_exist_named_child (nm) diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index a82f3dd097..4bb3081558 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -131,10 +131,10 @@ def musicxml_attributes_to_lily (attrs): 'key': musicxml_key_to_lily } for (k, func) in attr_dispatch.items (): - childs = attrs.get_named_children (k) + children = attrs.get_named_children (k) ## ugh: you get clefs spread over staves for piano - if childs: + if children: elts.append (func (attrs)) return elts