]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/build/bib2texi.py
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scripts / build / bib2texi.py
index ab8a6b902be6752e2a0aedb1298c3baf3428d340..b76a171a09263bd64c9ba1970a1b0439845aa3ac 100644 (file)
@@ -6,7 +6,7 @@ import tempfile
 
 # usage:
 def usage ():
-    print 'usage: %s [-s style] [-o <outfile>] [-q] BIBFILES...'
+    print 'usage: bib2texi.py [-s style] [-o <outfile>] [-q] BIBFILES...'
     print '-q suppresses most output'
 
 (options, files) = getopt.getopt (sys.argv[1:], 's:o:hq', [])
@@ -32,6 +32,11 @@ if not files:
    usage ()
    sys.exit (2)
 
+marker = """@c This file was autogenerated
+@c     from: %s
+@c     by:   %s
+
+""" % (", ".join(files), sys.argv[0])
 
 def strip_extension (f, ext):
     (p, e) = os.path.splitext (f)
@@ -69,16 +74,25 @@ cmd = "TEXMFOUTPUT=%s bibtex %s %s" % (tmpdir, quiet_flag, tmpfile)
 
 if (show_output):
     sys.stdout.write ("Running bibtex on %s\n" % files)
+    sys.stdout.write (cmd)
 #And invoke it
 stat = os.system (cmd)
 if stat <> 0:
-    sys.exit(1)
+    sys.stderr.write ("Bibtex exited with nonzero exit status!")
+    sys.exit (1)
 
 #TODO: do tex -> itexi on output
-# Following lines copy tmpfile.bbl to the desired output file
+# Following lines copy tmpfile.bbl to the desired output file
 bbl = open (tmpfile + '.bbl').read ()
 
-open (output, 'w').write  (bbl)
+if bbl.strip () == '':
+    sys.stderr.write ("Bibtex generated an empty file!")
+    sys.exit (1)
+
+fout = open (output, 'w')
+fout.write (marker)
+fout.write (bbl)
+fout.close ()
 
 def cleanup (tmpfile):
     for a in ['aux','bbl', 'blg']: