]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.7
authorfred <fred>
Tue, 26 Mar 2002 22:43:48 +0000 (22:43 +0000)
committerfred <fred>
Tue, 26 Mar 2002 22:43:48 +0000 (22:43 +0000)
stepmake/bin/add-html-footer.py
stepmake/bin/ls-latex.py
stepmake/bin/package-diff.py

index 3ece5fd13539315ba9a9ca3962734428bf5bf483..153cc4a48d7d1b9560a96c92127395ab30766d35 100644 (file)
@@ -12,7 +12,6 @@ import getopt
 import __main__
 
 fullname = "unknown"
-changelog_file = ''
 index_file=''
 banner_file = ''
 changelog_file=''
@@ -53,16 +52,16 @@ package_name = ''
 
 def gulp_file(f):
        try:
-                       i = open(f)
-                       i.seek (0, 2)
-                       n = i.tell ()
-                       i.seek (0,0)
+               i = open(f)
+               i.seek (0, 2)
+               n = i.tell ()
+               i.seek (0,0)
        except:
-                       sys.stderr.write ("can't open file: %s\n" % f)
-                       return ''
+               sys.stderr.write ("can't open file: %s\n" % f)
+               return ''
        s = i.read (n)
        if len (s) <= 0:
-                       sys.stderr.write ("gulped empty file: %s\n" % f)
+               sys.stderr.write ("gulped empty file: %s\n" % f)
        i.close ()
        return s
 
@@ -70,10 +69,10 @@ def help ():
        sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
 Add a nice footer, add the top of the ChangLog file (up to the ********)
 Options:
--h, --help                      print this help
---version               package version
---name                          package_name
---footer                          footer file.
+-h, --help                print this help
+--version                 package version
+--name                    package_name
+--footer                  footer file
 """)
        sys.exit (0)
 
@@ -129,16 +128,17 @@ banner = footstr (index_file)
 banner_id = '<! banner_id >'
 
 
-if changelog_file:
-       changes = gulp_file (changelog_file)
-       m = re.search ('^\*\*', changes)
-       if m:
-               changes = changes[:m.start (0)]
-
 
 
 def do_file (s):
+
        if changelog_file:
+               changes = gulp_file (changelog_file)
+               # urg?
+               #m = re.search ('^\\\\*\\\\*', changes)
+               m = re.search (r'\*\*\*', changes)
+               if m:
+                       changes = changes[:m.start (0)]
                s = re.sub ('top_of_ChangeLog', '<XMP>\n'+ changes  + '\n</XMP>\n', s)
 
 
index 2f88134be42b77f2faa1e7901cd343ec64a81cf5..791f27aaa70b6ff3676afe8fa543d4ca222b2cf9 100644 (file)
@@ -8,127 +8,172 @@ version = '0.1'
 import sys
 import os
 import string
-
-def gulp_file (fn):
-       f = open (fn)
-       return f.read ()
-
 import __main__
 import glob
-
 import re
 
 format_names  = {'ps.gz': 'Compressed PostScript',
-                'html' : 'HTML'
-                }
+                                'html' : 'HTML'
+                                }
+
+def gulp_file(f):
+       try:
+               i = open(f)
+               i.seek (0, 2)
+               n = i.tell ()
+               i.seek (0,0)
+       except:
+               sys.stderr.write ("can't open file: %s\n" % f)
+               return ''
+       s = i.read (n)
+       if len (s) <= 0:
+               sys.stderr.write ("gulped empty file: %s\n" % f)
+       i.close ()
+       return s
 
 class Latex_head:
-    def __init__ (self):
-       self.author = ''
-       self.title = ''
-       self.date = ''
-       self.format = ''
-       
+       def __init__ (self):
+               self.author = ''
+               self.title = ''
+               self.date = ''
+               self.format = ''
+               
 def read_latex_header (s):
-    header = Latex_head()
-    m = re.search(r'\\author{([^}]+)}', s)
-    if m:
-       header.author = m.group (1)
+       header = Latex_head()
+       m = re.search(r'\\author{([^}]+)}', s)
+       if m:
+               header.author = m.group (1)
 
-    m = re.search (r'\\title{([^}]+)}',s )
-    if m:
-       header.title = m.group (1)
+       m = re.search (r'\\title{([^}]+)}',s )
+       if m:
+               header.title = m.group (1)
 
-    header.formats = ['ps.gz']
-    return  header
+       header.formats = ['ps.gz']
+       return  header
 
 
 def read_bib_header (s):
+       m = re.search ('% *AUTHOR *= *(.*)\n',s)
 
-    m = re.search ('% *AUTHOR *= *(.*)\n',s)
+       header = Latex_head()
 
-    header = Latex_head()
+       if m:
+               header.author = m.group (1)
 
-    if m:
-       header.author = m.group (1)
+       m = re.search ('% *TITLE *= *(.*)\n',s )
+       if m:
+               header.title = m.group (1)
 
-    m = re.search ('% *TITLE *= *(.*)\n',s )
-    if m:
-       header.title = m.group (1)
-
-    header.formats = ['html']
-    return header
+       header.formats = ['html']
+       return header
 
 
 def read_pod_header (s):
-    header = Latex_head ()
+       header = Latex_head ()
 
-    i = re.search( '[^\n \t]', s)
-    s = s[i:]
-    i = re.search( '\n\n', s)
-    s = s[i+2:]    
-    i = re.search( '\n\n', s)
-    header.title = s[:i]
+       i = re.search( '[^\n \t]', s)
+       s = s[i:]
+       i = re.search( '\n\n', s)
+       s = s[i+2:]     
+       i = re.search( '\n\n', s)
+       header.title = s[:i]
 
-    return  header
+       header.formats = ['html']
+       return  header
 
 def read_texinfo_header (s):
-    header = Latex_head ()
-
-    m = re.search( '@settitle (.*$)', s)
-    if m:
-       header.title = m.group (1)
-
-    header.formats = ['html', 'ps.gz']
-    return header
-
+       header = Latex_head ()
+
+       m = re.search( '@settitle (.*)\n', s)
+       if m:
+               print 'title found! '
+               header.title = m.group (1)
+       m = re.search( '@author (.*)\n', s)
+       if m:
+               header.author = m.group (1)
+       
+       header.formats = ['html', 'ps.gz']
+       return header
+
+# urg
+# should make a 'next_parens '
+yo_article_re = re.compile ('article(\\([^)]*\\))[ \t\n]*(\\([^)]*\\))')
+yo_report_re = re.compile ('report(\\([^)]*\\))[\t\n ]*(\\([^)]*\\))')
+yo_sect_re  =  re.compile ('sect(\\([^)]*\\))')
+yo_chapter_re  =  re.compile ('chapter(\\([^)]*\\))')
+
+def read_yodl_header (s):
+       header = Latex_head ()
+       report = yo_report_re.search (s)
+       article = 0
+       sect = 0
+       chapter = 0
+       if report:
+               header.author = report.group (2)
+               header.title = yo_report_re.group (1)
+       else:
+               article = yo_article_re.search (s)
+               if article:
+                       header.author = article.group (2)
+                       header.title = article.group (1)
+               else:
+                       chapter = yo_chapter_re.search (s)
+                       if chapter:
+                               header.title = chapter.group (1)
+                       else:
+                               sect = yo_sect_re.search (s)
+                               if sect:
+                                       header.title = sect.group (1)
+
+       header.formats = ['html']
+       return  header
 
 
 def print_html_head (l,o,h):
-    pre =o
-
-    
-    fn = pre + h.basename
+       pre =o
+       
+       fn = pre + h.basename
 
-    t = h.filename 
-    if h.title :
-       t = t + ': '+ h.title
+       t = h.filename 
+       if h.title :
+               t = t + ': '+ h.title
 
-    l.write ('<li>%s </a>' % t)
+       l.write ('<li>%s </a>' % t)
 
-    if h.author:
-       l.write ('<p>by %s</p>' % h.author)
+       if h.author:
+               l.write ('<p>by %s</p>' % h.author)
 
-    for f in h.formats:
-       l.write ('(<a href=%s.%s>%s</a>)' % (fn, f, format_names [f]))
-    l.write ('</li>\n')
+       for f in h.formats:
+               l.write ('(<a href=%s.%s>%s</a>)' % (fn, f, format_names [f]))
+       l.write ('</li>\n')
 
 def help ():
-    sys.stdout.write ("Usage: ls-latex [OPTION]... FILE...\n"
-                "Generate html index file for FILE...\n\n"
-                + "Options:\n"
-                + "  -h, --help             print this help\n"
-                     )
-    sys.exit (0)
+       sys.stdout.write (r"""Usage: ls-latex [OPTION]... FILE...
+Generate html index file for FILE...
+
+Options:
+-h, --help                print this help
+""")
+       sys.exit (0)
 
 import getopt
 
 (options, files) = getopt.getopt(sys.argv[1:], 
-    'e:h', ['help', 'prefix=',  'title='])
+       'e:h', ['help', 'prefix=',  'title='])
 
 tex = ''
 output =''
 pre = ''
 title = ''
 for opt in options:
-    o = opt[0]
-    a = opt[1]
-    if o == '--prefix':
-       pre = a
-    elif o == '--title':
-       title = a  
-    elif o == '-h' or o == '--help':
-       help ()
+       o = opt[0]
+       a = opt[1]
+       if o == '--prefix':
+               pre = a
+       elif o == '--title':
+               title = a  
+       elif o == '-h' or o == '--help':
+                       help ()
 
 
 l = sys.stdout
@@ -140,28 +185,29 @@ l.write (r"""<html><title>%s</title>
 
 
 read_header_funcs = {
-    'pod' : read_pod_header,
-    'tex' : read_latex_header,
-    'doc' : read_latex_header,
-    'bib': read_bib_header, 
-    'latex' : read_latex_header,
-    'tely' : read_texinfo_header,
-    'texi': read_texinfo_header,
-}    
+       'pod' : read_pod_header,
+       'tex' : read_latex_header,
+       'doc' : read_latex_header,
+       'bib': read_bib_header, 
+       'latex' : read_latex_header,
+       'tely' : read_texinfo_header,
+       'texi': read_texinfo_header,
+       'yo': read_yodl_header, 
+}      
 
 
 for x in files:
-    m = re.search ('\\.([^.]*)$', x)
-    if m == None:
-       continue
+       m = re.search ('\\.([^.]*)$', x)
+       if m == None:
+               continue
 
-    s = gulp_file (x)
-    head = read_header_funcs [m.group(1)] (s)
+       s = gulp_file (x)
+       head = read_header_funcs [m.group(1)] (s)
 
-    head.filename = x
-    head.basename = re.sub ("\\.[^.]+", '', x)
-    
-    print_html_head (l, pre, head)
+       head.filename = x
+       head.basename = re.sub ("\\.[^.]+", '', x)
+       
+       print_html_head (l, pre, head)
 
 l.write ('</ul></body></html>')
 
index 927cb0999ef78c81708d47500889b4f751358f7c..b1fe324985e0d8963afcdbda1965a1d14fc11c34 100644 (file)
@@ -1,5 +1,9 @@
 #!@PYTHON@
 
+#
+# TODO: CLEAN THIS UP.
+#
+
 
 import find
 import sys
@@ -134,7 +138,9 @@ usage
 
 Patches do not contain automatically generated files 
 or (urg) empty directories, 
-i.e., you should rerun autoconf, configure """
+i.e., you should rerun autoconf, configure
+
+"""
 
 
 def makediff (fromdir, todir, patch_name):