]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
revert the "fix".
[lilypond.git] / scripts / lilypond-book.py
index 5acc2238bc167a83d4a7e623442d742defb049fd..32829bdb47ed3941c80a5e072ccab0d0883d5d1f 100644 (file)
@@ -158,7 +158,8 @@ def get_option_parser ():
        
        p.add_option ("-o", '--output', help=_('write output to DIR'),
                      metavar="DIR",
-                     action='store', dest='output_name', default=None)
+                     action='store', dest='output_name',
+                     default='')
        p.add_option ('-P', '--process', metavar=_("COMMAND"),
                      help = _ ("process ly_files using COMMAND FILE..."),
                      action='store', 
@@ -602,7 +603,14 @@ output = {
 @end html
 ''',
 
-               PRINTFILENAME: '''@file{%(filename)s}
+               PRINTFILENAME: '''
+@html
+<a href="%(base)s.ly">
+@end html
+@file{%(filename)s}
+@html
+</a>
+@end html
        ''',
 
                QUOTE: r'''@quotation
@@ -1402,6 +1410,12 @@ LATEX_INSPECTION_DOCUMENT = r'''
 # Do we need anything else besides `textwidth'?
 def get_latex_textwidth (source):
        m = re.search (r'''(?P<preamble>\\begin\s*{document})''', source)
+       if m == None:
+               warning (_ ("Can't find \\begin{document} in LaTeX document"))
+               
+               ## what's a sensible default?
+               return 550.0
+       
        preamble = source[:m.start (0)]
        latex_document = LATEX_INSPECTION_DOCUMENT % vars ()
        
@@ -1554,6 +1568,14 @@ def note_input_file (name, inputs=[]):
        inputs.append (name)
        return inputs
 
+def samefile (f1, f2):
+       try:
+               return os.path.samefile (f1, f2)
+       except AttributeError:          # Windoze
+               f1 = re.sub ("//*", "/", f1)
+               f2 = re.sub ("//*", "/", f2)
+               return f1 == f2
+
 def do_file (input_filename):
        # Ugh.
        if not input_filename or input_filename == '-':
@@ -1590,7 +1612,7 @@ def do_file (input_filename):
                else: 
                        if os.path.exists (input_filename) \
                           and os.path.exists (output_filename) \
-                          and os.path.samefile (output_filename, input_fullname):
+                          and samefile (output_filename, input_fullname):
                           error (
                           _ ("Output would overwrite input file; use --output."))
                           exit (2)