_ = ly._
-def error (str):
- ly.stderr_write ((_ ("error: %s") % str) + "\n")
-
def escape_ly_output_string (input_string):
return_string = input_string
return ''.join ([c.get_text () for c in self._children])
def message (self, msg):
- ly.stderr_write (msg+'\n')
+ ly.warning (msg)
p = self
while p:
- sys.stderr.write (' In: <%s %s>\n' % (p._name, ' '.join (['%s=%s' % item for item in p._attribute_dict.items ()])))
+ ly.progress (' In: <%s %s>\n' % (p._name, ' '.join (['%s=%s' % item for item in p._attribute_dict.items ()])))
p = p.get_parent ()
def dump (self, indent = ''):
- sys.stderr.write ('%s<%s%s>' % (indent, self._name, ''.join ([' %s=%s' % item for item in self._attribute_dict.items ()])))
+ ly.debug_output ('%s<%s%s>' % (indent, self._name, ''.join ([' %s=%s' % item for item in self._attribute_dict.items ()])))
non_text_children = [c for c in self._children if not isinstance (c, Hash_text)]
if non_text_children:
- sys.stderr.write ('\n')
+ ly.debug_output ('\n')
for c in self._children:
c.dump (indent + " ")
if non_text_children:
- sys.stderr.write (indent)
- sys.stderr.write ('</%s>\n' % self._name)
+ ly.debug_output (indent)
+ ly.debug_output ('</%s>\n' % self._name)
def get_typed_children (self, klass):
def get_unique_typed_child (self, klass):
cn = self.get_typed_children(klass)
if len (cn) <> 1:
- sys.stderr.write (self.__dict__ + '\n')
+ ly.error (self.__dict__)
raise 'Child is not unique for', (klass, 'found', cn)
return cn[0]
ret.append (r.get_text ())
return string.join (ret, "\n")
+ # get contents of the source-element (usually used for publishing information). (These contents are saved in a custom variable named "source" in the header of the .ly file.)
+ def get_source (self):
+ source = self.get_named_children ('source')
+ ret = []
+ for r in source:
+ ret.append (r.get_text ())
+ return string.join (ret, "\n")
+
def get_creator (self, type):
creators = self.get_named_children ('creator')
# return the first creator tag that has the particular type
return mf.get_text ()
return None
-
-
class Duration (Music_xml_node):
def get_length (self):
dur = int (self.get_text ()) * Rational (1,4)
pass
class Hash_text (Music_xml_node):
def dump (self, indent = ''):
- sys.stderr.write ('%s' % string.strip (self._data))
+ ly.debug_output ('%s' % string.strip (self._data))
class Pitch (Music_xml_node):
def get_step (self):
if mxl.get_maybe_exist_named_child ('senza-misura'):
# TODO: Handle pieces without a time signature!
- error (_ ("Senza-misura time signatures are not yet supported!"))
+ ly.warning (_ ("Senza-misura time signatures are not yet supported!"))
return (4, 4)
else:
signature = []
if instrument_name:
return instrument_name
else:
- ly.stderr_write (_ ("Unable to find instrument for ID=%s\n") % id)
+ ly.warning (_ ("Unable to find instrument for ID=%s\n") % id)
return "Grand Piano"
class Part_group (Music_xml_node):
attributes._dict = attr._dict.copy ()
attributes._original_tag = attr
# copy only the relevant children over for the given staff
+ if staff == "None":
+ staff = "1"
for c in attr._children:
if (not (hasattr (c, 'number') and (c.number != staff)) and
not (isinstance (c, Hash_text))):
if voice_id:
vid = voice_id.get_text ()
elif isinstance (n, Note):
+ # TODO: Check whether we shall really use "None" here, or
+ # rather use "1" as the default?
vid = "None"
staff_id = n.get_maybe_exist_named_child (u'staff')
if staff_id:
sid = staff_id.get_text ()
else:
+ # TODO: Check whether we shall really use "None" here, or
+ # rather use "1" as the default?
+ # If this is changed, need to change the corresponding
+ # check in extract_attributes_for_staff, too.
sid = "None"
if vid and not voices.has_key (vid):
voices[vid] = Musicxml_voice()