]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.5.25
authorfred <fred>
Wed, 5 Dec 2001 17:42:45 +0000 (17:42 +0000)
committerfred <fred>
Wed, 5 Dec 2001 17:42:45 +0000 (17:42 +0000)
buildscripts/bib2html.py [new file with mode: 0644]

diff --git a/buildscripts/bib2html.py b/buildscripts/bib2html.py
new file mode 100644 (file)
index 0000000..37bc469
--- /dev/null
@@ -0,0 +1,86 @@
+#!@PYTHON@
+import os
+import sys
+import getopt
+import tempfile
+import string
+
+# usage:
+def usage ():
+    print 'usage: %s [-s style] [-o <outfile>] BIBFILES...';
+
+
+
+(options, files) = getopt.getopt(sys.argv[1:], 's:o:', [])
+
+output = 'bib.html'
+style = 'long'
+for (o,a) in options:
+       if o == '-h' or o == '--help':
+               usage ()
+               sys.exit (0)
+       elif o == '-s' or o == '--style':
+               style = a
+       elif o == '-o' or o == '--output':
+               output = a
+       else:
+               raise 'unknown opt ', o
+
+
+if style not in ['alpha','index','long','longp','long-pario','short','short-pario','split']:
+    sys.stderr.write ("Unknown style \`%s'\n" % style)
+
+tempfile = tempfile.mktemp ('bib2html')
+
+if not files:
+    usage ()
+    sys.exit (2)
+
+
+def strip_extension (f, ext):
+       (p, e) = os.path.splitext (f)
+       if e == ext:
+               e = ''
+       return p + e
+
+nf = []
+for f in files:
+    nf.append (strip_extension(f, '.bib'))
+
+files = string.join (nf,',')
+
+open(tempfile + '.aux', 'w').write (r'''
+\relax 
+\citation{*}
+\bibstyle{html-%(style)s}
+\bibdata{%(files)s}''' % vars ()) 
+
+cmd = "bibtex %s" % tempfile;
+
+sys.stdout.write ("Invoking `%s'\n" % cmd)
+os.system (cmd) 
+
+
+#TODO: do tex -> html on output 
+
+bbl =open (tempfile + '.bbl').read ()
+
+open (output, 'w').write  (bbl)
+
+
+def cleanup (tempfile):
+    for a in ['aux','bbl', 'blg']:
+       os.unlink (tempfile + '.' + a)
+
+cleanup(tempfile)
+
+
+
+
+
+
+
+
+
+
+