]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/mup2ly.py
Changed scripts/* to use sys.argv[0]
[lilypond.git] / scripts / mup2ly.py
index e24f38ac183730236f823ef026d3cb6c7e3808c5..e1ba8b8fda828d88eae24873d9c23d484e35279e 100644 (file)
@@ -37,17 +37,17 @@ import tempfile
 
 # if set, LILYPONDPREFIX must take prevalence
 # if datadir is not set, we're doing a build and LILYPONDPREFIX 
-datadir = '@datadir@'
+datadir = '@local_lilypond_datadir@'
 if os.environ.has_key ('LILYPONDPREFIX') \
-   or '@datadir@' == '@' + 'datadir' + '@':
+   or '@local_lilypond_datadir@' == '@' + 'local_lilypond_datadir' + '@':
        datadir = os.environ['LILYPONDPREFIX']
 else:
-       datadir = '@datadir@'
+       datadir = '@local_lilypond_datadir@'
 
 sys.path.append (os.path.join (datadir, 'python'))
 sys.path.append (os.path.join (datadir, 'python/out'))
 
-program_name = 'ly2dvi'
+program_name = sys.argv[0]
 program_version = '@TOPLEVEL_VERSION@'
 original_dir = os.getcwd ()
 temp_dir = os.path.join (original_dir,  '%s.dir' % program_name)
@@ -55,9 +55,10 @@ errorport = sys.stderr
 keep_temp_dir_p = 0
 verbose_p = 0
 
+localedir = '@localedir@'
 try:
        import gettext
-       gettext.bindtextdomain ('lilypond', '@localedir@')
+       gettext.bindtextdomain ('lilypond', localedir)
        gettext.textdomain ('lilypond')
        _ = gettext.gettext
 except:
@@ -66,15 +67,15 @@ except:
 
 
 program_name = 'mup2ly'
-help_summary = _ ("Convert mup to LilyPond source")
+help_summary = _ ("Convert mup to LilyPond source.")
 
 option_definitions = [
        ('', 'd', 'debug', _ ("debug")),
        ('NAME[=EXP]', 'D', 'define', _ ("define macro NAME [optional expansion EXP]")),
-       ('', 'h', 'help', _ ("this help")),
+       ('', 'h', 'help', _ ("print this help")),
        ('FILE', 'o', 'output', _ ("write output to FILE")),
        ('', 'E', 'pre-process', _ ("only pre-process")),
-       ('', 'V', 'verbose', _ ("verbose")),
+       ('', 'V', 'verbose', _ ("be verbose")),
        ('', 'v', 'version', _ ("print version number")),
        ('', 'w', 'warranty', _ ("show warranty and copyright")),
        ]
@@ -126,14 +127,13 @@ def identify ():
 def warranty ():
        identify ()
        sys.stdout.write ('\n')
-       sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001--2002'))
+       sys.stdout.write (_ ('Copyright (c) %s by') % '2001--2004')
        sys.stdout.write ('\n')
        sys.stdout.write ('  Han-Wen Nienhuys')
        sys.stdout.write ('  Jan Nieuwenhuizen')
-       sys.stdout.write ('\n')
-       sys.stdout.write (_ (r'''
-Distributed under terms of the GNU General Public License. It comes with
-NO WARRANTY.'''))
+       sys.stdout.write ('\n\n')
+       sys.stdout.write (_ ("Distributed under terms of the GNU General Public License."))
+       sys.stdout.write (_ ("It comes with NO WARRANTY."))
        sys.stdout.write ('\n')
 
 def progress (s):
@@ -182,9 +182,9 @@ def option_help_str (o):
        if o[1]:
                sh = '-%s' % o[1]
 
-       sep = ' '
+       sep = '  '
        if o[1] and o[2]:
-               sep = ','
+               sep = ', '
                
        long = ''
        if o[2]:
@@ -216,7 +216,7 @@ def options_help_str (opts):
        return str
 
 def help ():
-       ls = [(_ ("Usage: %s [OPTION]... FILE") % program_name),
+       ls = [(_ ("Usage: %s [OPTIONS]... FILE") % program_name),
                ('\n\n'),
                (help_summary),
                ('\n\n'),
@@ -224,7 +224,7 @@ def help ():
                ('\n'),
                (options_help_str (option_definitions)),
                ('\n\n'),
-               (_ ("Report bugs to %s") % 'bug-lilypond@gnu.org'),
+               (_ ("Report bugs to %s.") % 'bug-lilypond@gnu.org'),
                ('\n')]
        map (sys.stdout.write, ls)
        
@@ -313,12 +313,12 @@ def mkdir_p (dir, mode=0777):
 
 # if set, LILYPONDPREFIX must take prevalence
 # if datadir is not set, we're doing a build and LILYPONDPREFIX 
-datadir = '@datadir@'
+datadir = '@local_lilypond_datadir@'
 
 if os.environ.has_key ('LILYPONDPREFIX') :
        datadir = os.environ['LILYPONDPREFIX']
 else:
-       datadir = '@datadir@'
+       datadir = '@local_lilypond_datadir@'
 
 
 while datadir[-1] == os.sep:
@@ -454,8 +454,8 @@ class Slur:
                e= self.end_chord
 
                if e and s:
-                       s.note_suffix = s.note_suffix + '('
-                       e.note_prefix = ')' + e.note_prefix
+                       s.note_suffix = s.note_suffix + '-('
+                       e.note_prefix = e.note_suffix + "-)"
                else:
                        sys.stderr.write ("\nOrphaned slur")
                        
@@ -637,8 +637,8 @@ class Staff:
                                str = str + v.dump()
                                refs = refs + '\n  \\' + v.idstring ()
                str = str + '''
-%s = \context Staff = %s <%s
->
+%s = \context Staff = %s <<%s
+>>
 
 ''' % (self.idstring (), self.idstring (), refs)
                return str
@@ -720,19 +720,21 @@ class Chord:
                for p in self.pitches:
                        if str:
                                str = str + ' ' 
-                       str = str + pitch_to_lily_string (p) + sd
+                       str = str + pitch_to_lily_string (p)
 
-               for s in self.scripts:
-                       str = str + '-' + s
 
                str = self.note_prefix +str  + self.note_suffix
                
                if len (self.pitches) > 1:
                        str = '<%s>' % str
                elif self.multimeasure:
-                       str = 'R' + sd
+                       str = 'R'
                elif len (self.pitches) == 0:
-                       str = 'r' + sd
+                       str = 'r'
+
+               str = str + sd
+               for s in self.scripts:
+                       str = str + '-' + s
 
                str = self.chord_prefix + str + self.chord_suffix
                
@@ -1097,8 +1099,8 @@ class Parser:
                str = str + '''
 
 \score {
-  <%s
-  >
+  <<%s
+  >>
   \paper {}
   \midi {}
 }
@@ -1288,7 +1290,7 @@ if not files:
        files = ['-']
        
 for f in files:
-
+       h = None
        if f == '-':
                h = sys.stdin
        elif f and not os.path.isfile (f):