]> git.donarmstrong.com Git - lilypond.git/blobdiff - stepmake/bin/add-html-footer.py
`bug'fix: a colon `:' is added (only) after a sentence which is complete;
[lilypond.git] / stepmake / bin / add-html-footer.py
index 7c0f83c036ffb7aeccc983025030d1d64cb844f5..18b691719b72388489aadf8abc539851299a5a82 100644 (file)
@@ -40,10 +40,10 @@ of @PACKAGE_NAME@
 
 built = r"""<hr>
 <p><font size="-1">
-This page was built from @PACKAGE_NAME@-@PACKAGE_VERSION@ by<br>
+This page is for @PACKAGE_NAME@-@PACKAGE_VERSION@ (@BRANCH@). <br>
 </font>
-<address><font size="-1">@GCOS@ &lt;<a href="mailto:%s">@MAIL_ADDRESS@</a>&gt;,
-@LOCALTIME@.</font></address>"""
+<address><font size="-1">
+Report errors to &lt;<a href="mailto:@MAILADDRESS@">@MAILADDRESS@</a>&gt;.</font></address>"""
 
 
 def gulp_file (f):
@@ -62,7 +62,7 @@ def gulp_file (f):
        return s
 
 def help ():
-       sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
+       sys.stdout.write (r"""Usage: add-html-footer [OPTIONS]... HTML-FILE
 Add header, footer and top of ChangLog file (up to the ********) to HTML-FILE
 
 Options:
@@ -73,6 +73,7 @@ Options:
   --index=URL               set homepage to URL
   --name=NAME               set package_name to NAME
   --version=VERSION         set package version to VERSION
+
 """)
        sys.exit (0)
 
@@ -110,7 +111,7 @@ def set_gcos ():
                pw = ntpwd.getpwname(os.environ['USERNAME'])
        else:
                import pwd
-               if os.environ.has_key('FAKEROOTKEY'):
+               if os.environ.has_key('FAKEROOTKEY') and os.environ.has_key('LOGNAME'):
                        pw = pwd.getpwnam (os.environ['LOGNAME'])
                else:
                        pw = pwd.getpwuid (os.getuid())
@@ -133,7 +134,9 @@ if os.path.basename (index_url) != "index.html":
 top_url = os.path.dirname (index_url) + "/"
 
 header = compose (default_header, header_file)
-footer = compose (default_footer, footer_file) + built
+
+# compose (default_footer, footer_file)
+footer =  built
 header_tag = '<!-- header_tag -->'
 footer_tag = '<!-- footer_tag -->'
 
@@ -151,21 +154,34 @@ else:
 def remove_self_ref (s):       
        self_url = abspath (os.getcwd () + '/' + f)
        #sys.stderr.write ('url0: %s\n' % self_url)
-       self_url = re.sub ('.*' + string.lower (package_name) + '[^/]*/',
+
+       # self_url = re.sub ('.*?' + string.lower (package_name) + '[^/]*/',
+       #                '', self_url)
+       # URG - this only works when source tree is unpacked in `src/' dir
+       # For some reason, .*? still eats away
+       #     /home/fred/usr/src/lilypond-1.5.14/Documentation/user/out-www/lilypond/
+       # instead of just
+       #
+       #     /home/fred/usr/src/lilypond-1.5.14/
+       #
+       #     Tutorial.html
+       self_url = re.sub ('.*?src/' + string.lower (package_name) + '[^/]*/',
                         '', self_url)
+
        #sys.stderr.write ('url1: %s\n' % self_url)
        
        #urg, ugly lily-specific toplevel index hack
        self_url = re.sub ('.*topdocs/out-www/index.html', 'index.html', self_url)
        #sys.stderr.write ('url2: %s\n' % self_url)
 
-       m = re.match ('.*?(<a href="[\./]*' + self_url + '#?[^"]*">)([^<]*)(</a>)',
-                     s, re.DOTALL)
+       # ugh, python2.[12] re is broken.
+       ## pat = re.compile ('.*?(<a href="[\./]*' + self_url + '#?[^"]*">)([^<]*)(</a>)', re.DOTALL)
+       pat = re.compile ('[.\n]*?(<a href="[\./]*' + self_url + '#?[^"]*">)([^<]*)(</a>)')
+       m = pat.search (s)
        while m:
                #sys.stderr.write ('self: %s\n' % m.group (2))
                s = s[:m.start (1)] + m.group (2) + s[m.end (3):]
-               m = re.match ('.*?(<a href="[\./]*' + self_url + '#?[^"]*">)([^<]*)(</a>)',
-                             s, re.DOTALL)
+               m = pat.search (s)
        return s
 
 def do_file (f):
@@ -206,6 +222,7 @@ def do_file (f):
                else:
                        s = s + footer
 
+
        #URUGRGOUSNGUOUNRIU
        index = index_url
        top = top_url
@@ -219,6 +236,12 @@ def do_file (f):
                #       index = "./index.html"
                #       top = "./"
 
+
+       versiontup = string.split(package_version, '.')
+       branch_str = 'stable-branch'
+       if string.atoi ( versiontup[1]) %  2:
+               branch_str = 'development-branch'
+               
        s = re.sub ('@INDEX@', index, s)
        s = re.sub ('@TOP@', top, s)
        s = re.sub ('@PACKAGE_NAME@', package_name, s)
@@ -226,20 +249,27 @@ def do_file (f):
        s = re.sub ('@WEBMASTER@', webmaster, s)
        s = re.sub ('@GCOS@', gcos, s)
        s = re.sub ('@LOCALTIME@', localtime, s)
-       s = re.sub ('@MAIL_ADDRESS@', mail_address, s)
+       s = re.sub ('@MAILADDRESS@', mail_address, s)
+       s = re.sub ('@BRANCH@', branch_str, s)  
 
-       m = re.match ('.*?<!-- (@[a-zA-Z0-9_-]*@)=(.*?) -->', s, re.DOTALL)
+       # ugh, python2.[12] re is broken.
+       #pat = re.compile ('.*?<!--\s*(@[^@]*@)\s*=\s*([^>]*)\s*-->', re.DOTALL)
+       pat = re.compile ('[.\n]*?<!--\s*(@[^@]*@)\s*=\s*([^>]*)\s*-->')
+       m = pat.search (s)
        while m:
                at_var = m.group (1)
                at_val = m.group (2)
-               #sys.stderr.write ('at: %s -> %s\n' % (at_var, at_val))
+               sys.stderr.write ('at: %s -> %s\n' % (at_var, at_val))
                s = re.sub (at_var, at_val, s)
-               m = re.match ('.*?<!-- (@[a-zA-Z0-9_-]*@)=(.*?) -->', s, re.DOTALL)
+               m = pat.search (s)
 
        # urg
        # maybe find first node?
        fallback_web_title = '-- --'
-       m = re.match ('.*?<title>\(.*?\)</title>', s, re.DOTALL)
+
+       # ugh, python2.[12] re is broken.
+       #m = re.match ('.*?<title>\(.*?\)</title>', s, re.DOTALL)
+       m = re.match ('[.\n]*?<title>([.\n]*?)</title>', s)
        if m:
                fallback_web_title = m.group (1)
        s = re.sub ('@WEB-TITLE@', fallback_web_title, s)