version = '@TOPLEVEL_VERSION@'
if version == '@' + 'TOPLEVEL_VERSION' + '@':
version = '(unknown version)' # uGUHGUHGHGUGH
+
+
+################################################################
+# Users of python modules should include this snippet.
+#
+libdir = '@local_lilypond_libdir@'
+if not os.path.isdir (libdir):
+ libdir = '@lilypond_libdir@'
+
+# ugh
+datadir = '@local_lilypond_datadir@'
+if os.environ.has_key ('LILYPONDPREFIX'):
+ datadir = os.environ['LILYPONDPREFIX']
+ while datadir[-1] == os.sep:
+ datadir= datadir[:-1]
+ libdir = datadir.replace ('/share/', '/lib/')
+
+if os.path.exists (os.path.join (datadir, 'lib/lilypond/@TOPLEVEL_VERSION@/')):
+ libdir = os.path.join (libdir, 'lib/lilypond/@TOPLEVEL_VERSION@/')
+
+if os.path.exists (os.path.join (datadir, 'lib/lilypond/current/')):
+ libdir = os.path.join (libdir, 'lib/lilypond/current/')
+
+sys.path.insert (0, os.path.join (libdir, 'python'))
+
+# dynamic relocation, for GUB binaries.
+bindir = 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)
+
+################################################################
+
+import lilylib as ly
+_ = ly._
finale_clefs= ['treble', 'alto', 'tenor', 'bass', 'percussion', 'treble_8', 'bass_8', 'baritone']
# should cache this.
def find_scale (keysig):
cscale = map (lambda x: (x,0), range (0,7))
- print "cscale: ", cscale
+# print "cscale: ", cscale
ascale = map (lambda x: (x,0), range (-2,5))
- print "ascale: ", ascale
+# print "ascale: ", ascale
transposition = keysig.pitch
if keysig.sig_type == 1:
transposition = transpose(transposition, (2, -1))
trscale = map(lambda x, k=transposition: transpose(x, k), ascale)
else:
trscale = map(lambda x, k=transposition: transpose(x, k), cscale)
- print "trscale: ", trscale
+# print "trscale: ", trscale
return trscale
def EDU_to_duration (edu):
dots = 2
return (log, dots)
-def rat_to_lily_duration (rat):
+def rational_to_lily_skip (rat):
(n,d) = rat
basedur = 1
str = str + ' ' * 4 + line + '\n'
line = ''
- str = """\nverse%s = \\lyricmode {\n %s}\n""" % (encodeint (self.number - 1) ,str)
+ str = """\nverse%s = \\lyricmode {\n %s }\n""" % (encodeint (self.number - 1) ,str)
return str
class KeySignature:
# do grace notes.
lastch = None
+ in_grace = 0
for c in self.chords:
if c.grace and (lastch == None or (not lastch.grace)):
c.chord_prefix = r'\grace {' + c.chord_prefix
+ in_grace = 1
elif not c.grace and lastch and lastch.grace:
lastch.chord_suffix = lastch.chord_suffix + ' } '
-
+ in_grace = 0
+
lastch = c
-
+
+ if lastch and in_grace:
+ lastch.chord_suffix += '}'
def dump (self):
sys.stderr.write ("""\nHuh? Going backwards in frame no %d, start/end (%d,%d)""" % (self.number, self.start, self.end))
left = (0,1)
if left[0]:
- str = str + rat_to_lily_duration (left)
+ str = str + rational_to_lily_skip (left)
str = str + ' | \n'
return str
last_clef = m.clef
if e:
if gap <> (0,1):
- k = k +' ' + rat_to_lily_duration (gap) + '\n'
+ k = k +' ' + rational_to_lily_skip (gap) + '\n'
gap = (0,1)
k = k + e
if fr:
first_frame = fr
if gap <> (0,1):
- laystr = laystr +'} %s {\n ' % rat_to_lily_duration (gap)
+ laystr = laystr +'} %s {\n ' % rational_to_lily_skip (gap)
gap = (0,1)
laystr = laystr + fr.dump ()
else:
% (self.number, m.number))
if first_frame:
l = self.layerid (x)
- laystr = '%s = { { %s } }\n\n' % (l, laystr)
+ laystr = '%s = { { %s } }\n\n' % (l, laystr)
str = str + laystr
layerids.append (l)
return (string.atoi (dec), str)
else:
- sys.stderr.write ("Can't convert `%s'\n" % str)
+ sys.stderr.write ("can't convert `%s'\n" % str)
return (None, str)
sys.stderr.write ("\nLyrics found; edit to use \\addlyrics to couple to a staff\n")
if staffs:
- str = str + '\\score { << %s >> } ' % string.join (staffs)
+ str += '\\version "2.3.25"\n'
+ str = str + '<<\n %s\n>> } ' % string.join (staffs)
return str
def identify():
sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))
-def help ():
- sys.stdout.write("""Usage: etf2ly [OPTIONS]... ETF-FILE
-
-Convert ETF to LilyPond.
-
-Options:
- -h, --help print this help
- -o, --output=FILE set output filename to FILE
- -v, --version show version information
-
-Enigma Transport Format is a format used by Coda Music Technology's
-Finale product. This program will convert a subset of ETF to a
-ready-to-use lilypond file.
+def warranty ():
+ identify ()
+ sys.stdout.write ('''
+Copyright (c) %s by
-Report bugs to bug-lilypond@gnu.org.
+ Han-Wen Nienhuys
+ Jan Nieuwenhuizen
-Written by Han-Wen Nienhuys <hanwen@cs.uu.nl>.
+%s
+%s
+''' % ( '2001--2006',
+ _('Distributed under terms of the GNU General Public License.'),
+ _('It comes with NO WARRANTY.')))
-""")
-def print_version ():
- sys.stdout.write (r"""etf2ly (GNU lilypond) %s
-This 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 `midi2ly --warranty' for more information.
-
-Copyright (c) 2000--2004 by Han-Wen Nienhuys <hanwen@cs.uu.nl>
-""" % version)
-
-
-
-(options, files) = getopt.getopt (sys.argv[1:], 'vo:h', ['help','version', 'output='])
-out_filename = None
-
-for opt in options:
- o = opt[0]
- a = opt[1]
- if o== '--help' or o == '-h':
- help ()
+def get_option_parser ():
+ p = ly.get_option_parser (usage='etf2ly [OPTIONS]... ETF-FILE',
+ version="etf2ly (LilyPond) @TOPLEVEL_VERSION@",
+ description=_("""Enigma Transport Format is a format used by Coda Music Technology's
+Finale product. This program will convert a subset of ETF to a
+ready-to-use lilypond file."""))
+ p.add_option ('-o', '--output', help=_("write output to FILE"),
+ metavar=_("FILE"),
+ action='store')
+ p.add_option ('-w', '--warranty', help=_ ("show warranty"),
+ action='store_true',
+ ),
+
+ 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 do_options ():
+ opt_parser = get_option_parser()
+ (options,args) = opt_parser.parse_args ()
+ if options.warranty:
+ warranty ()
sys.exit (0)
- if o == '--version' or o == '-v':
- print_version ()
- sys.exit(0)
-
- if o == '--output' or o == '-o':
- out_filename = a
- else:
- print o
- raise getopt.error
+ return (options,args)
+
+(options, files) = do_options()
identify()
+out_filename = options.output
+
e = None
for f in files:
if f == '-':