import string
from gettext import gettext as _
-
-
-for d in ['@lilypond_datadir@',
- '@lilypond_libdir@']:
- sys.path.insert (0, os.path.join (d, 'python'))
-
-# dynamic relocation, for GUB binaries.
-bindir = os.path.abspath (os.path.split (sys.argv[0])[0])
-for p in ['share', 'lib']:
- datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p)
- sys.path.insert (0, datadir)
-
-
-
+"""
+@relocate-preamble@
+"""
import lilylib as ly
try:
(n,a) = {
'major' : (0,0),
- 'minor' : (6,0),
+ 'minor' : (5,0),
}[mode]
start_pitch.step = n
start_pitch.alteration = a
fifth.step *= -1
fifth.normalize ()
- start_pitch = musicexp.Pitch()
for x in range (fifths):
start_pitch = start_pitch.transposed (fifth)
event = musicexp.RestEvent()
elif n.instrument_name:
event = musicexp.NoteEvent ()
- event.drum_type = instrument_drumtype_dict[n.instrument_name]
-
+ try:
+ event.drum_type = instrument_drumtype_dict[n.instrument_name]
+ except KeyError:
+ n.message ("drum %s type unknow, please add to instrument_drumtype_dict" % n.instrument_name)
+ event.drum_type = 'acousticsnare'
if not event:
- n.message ("could not find suitable event")
+ n.message ("cannot find suitable event")
event.duration = musicxml_duration_to_lily (n)
return event
diff = moment - current_end
if diff < Rational (0):
- raise NegativeSkip(current_end, moment)
+ print 'Negative skip', diff
+ diff = Rational (0)
if diff > Rational (0):
skip = musicexp.SkipEvent()
if isinstance (n, musicxml.Attributes):
if n.is_first () and n._measure_position == Rational (0):
- voice_builder.add_bar_check (int (n.get_parent ().number))
+ try:
+ number = int (n.get_parent ().number)
+ except ValueError:
+ number = 0
+
+ voice_builder.add_bar_check (number)
for a in musicxml_attributes_to_lily (n):
voice_builder.add_music (a, Rational (0))
continue
continue
if n.is_first () and n._measure_position == Rational (0):
- num = int (n.get_parent ().number)
+ try:
+ num = int (n.get_parent ().number)
+ except ValueError:
+ num = 0
voice_builder.add_bar_check (num)
main_event = musicxml_note_to_lily_main_event (n)
def option_parser ():
- p = ly.get_option_parser(usage='musicxml2ly FILE.xml',
- version = """%prog (LilyPond) @TOPLEVEL_VERSION@
-
-This program is free software. It is covered by the GNU General Public
+ p = ly.get_option_parser(usage=_ ("musicxml2ly FILE.xml"),
+ version=('''%prog (LilyPond) @TOPLEVEL_VERSION@\n\n'''
+ +
+_ ("""This program is free software. It is covered by the GNU General Public
License and you are welcome to change it and/or distribute copies of it
-under certain conditions. Invoke as `lilypond --warranty' for more
-information.
-
+under certain conditions. Invoke as `%s --warranty' for more
+information.""") % 'lilypond'
++ """
Copyright (c) 2005--2006 by
Han-Wen Nienhuys <hanwen@xs4all.nl> and
Jan Nieuwenhuizen <janneke@gnu.org>
-""",
-
- description =
- """Convert MusicXML file to LilyPond input.
-"""
- )
+"""),
+ description=_ ("Convert %s to LilyPond input.") % 'MusicXML' + "\n")
p.add_option ('-v', '--verbose',
- action = "store_true",
- dest = 'verbose',
- help = 'be verbose')
+ action="store_true",
+ dest='verbose',
+ help=_ ("be verbose"))
p.add_option ('', '--lxml',
action="store_true",
default=False,
dest="use_lxml",
- help="Use lxml.etree; uses less memory and cpu time.")
+ help=_ ("Use lxml.etree; uses less memory and cpu time."))
p.add_option ('-o', '--output',
- metavar = 'FILE',
+ metavar=_ ("FILE"),
action="store",
default=None,
type='string',
dest='output_name',
- help='set output file')
-
- p.add_option_group ('', description = '''Report bugs via http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs
-''')
+ help=_ ("set output filename to FILE"))
+ p.add_option_group ('bugs',
+ description=(_ ("Report bugs via")
+ + ''' http://post.gmane.org/post.php'''
+ '''?group=gmane.comp.gnu.lilypond.bugs\n'''))
return p
def music_xml_voice_name_to_lily_name (part, name):
def print_ly_preamble (printer, filename):
printer.dump_version ()
- printer.print_verbatim ('%% converted from %s\n' % filename)
+ printer.print_verbatim ('%% automatically converted from %s\n' % filename)
def read_musicxml (filename, use_lxml):
if use_lxml: