gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] navidoc ./rst2any.py navidoc/modules/navbar.py


From: Benja Fallenstein
Subject: [Gzz-commits] navidoc ./rst2any.py navidoc/modules/navbar.py
Date: Fri, 21 Mar 2003 17:02:54 -0500

CVSROOT:        /cvsroot/navidoc
Module name:    navidoc
Changes by:     Benja Fallenstein <address@hidden>      03/03/21 17:02:54

Modified files:
        .              : rst2any.py 
        navidoc/modules: navbar.py 

Log message:
        tweaking

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/rst2any.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/modules/navbar.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: navidoc/navidoc/modules/navbar.py
diff -u navidoc/navidoc/modules/navbar.py:1.3 
navidoc/navidoc/modules/navbar.py:1.4
--- navidoc/navidoc/modules/navbar.py:1.3       Fri Mar 21 05:36:28 2003
+++ navidoc/navidoc/modules/navbar.py   Fri Mar 21 17:02:54 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: navbar.py,v 1.3 2003/03/21 10:36:28 humppake Exp $
+#$Id: navbar.py,v 1.4 2003/03/21 22:02:54 benja Exp $
 
 #
 # Written by Benja Fallenstein
@@ -51,7 +51,9 @@
     
     def addFile(self, filename, contents=None):
         if contents is None:
-            contents = open(filename).read()
+            file = open(filename)
+            contents = file.read()
+            file.close()
         
         match = self.re_title.search(contents)
         if not match:
@@ -64,8 +66,8 @@
         if os.path.basename(filename) in ('index.html',
                                           'peg.gen.html'):
             self.name = name
-        else:
-            self.files.append([filename, name])
+
+        self.files.append([filename, name])
 
     def addDir(self, dir):
         t = Tree(dir)
@@ -88,6 +90,7 @@
 def simpleNavbar(tree, indent=""):
     s = ""
     for el in tree.files:
+        if el[0].endswith('index.html'): continue
         s += '%s<a href="%s">%s</a><br>\n' % \
              (indent, 
el[0][len(_slashify(config.working_directory)):len(el[0])], el[1])
         if len(el) > 2:
@@ -98,26 +101,30 @@
     if bar is None:
         bar = '<hr class="footer"/>'
         bar += '<div class="left-bar">\n'
-        bar += ('<h1 class="boxhead"><a href="./">%s'
-                '</a></h1>\n') % tree.name
+        bar += ('<h3 class="boxhead"><a href="./">%s'
+                '</a></h3>\n') % tree.name
         bar += '<p class="boxcontent">\n'
         bar += simpleNavbar(tree)
         bar += '</p></div>\n'
 
     if single_file:
-        s = open(filename).read()
+        file = open(el[0]); s = file.read(); file.close()
         i = s.find('<hr class="footer"/>')
         s = s[:i] + bar + s[i:]
-        open(filename, 'w').write(s)
+        file = open(el[0], 'w')
+        file.write(s)
+        file.close()
         dbg("Inserted navbar into %s" % filename)
 
     else:
         for el in tree.files:
             if len(el) == 2:
-                s = open(el[0]).read()
+                file = open(el[0]); s = file.read(); file.close()
                 i = s.find('<hr class="footer"/>')
                 s = s[:i] + bar + s[i:]
-                open(el[0], 'w').write(s)
+                file = open(el[0], 'w')
+                file.write(s)
+                file.close()
                 dbg( "Inserted navbar into %s" % el[0])
             else:
                 insertNavbars(el[2], bar)
Index: navidoc/rst2any.py
diff -u navidoc/rst2any.py:1.10 navidoc/rst2any.py:1.11
--- navidoc/rst2any.py:1.10     Fri Mar 21 09:35:53 2003
+++ navidoc/rst2any.py  Fri Mar 21 17:02:54 2003
@@ -80,7 +80,12 @@
 
     if html:
         dbg('Compiling: '+input)
-        output = output+".gen.html"
+        if not output.endswith('index'):
+            output = output+".gen.html"
+        else:
+            # For practical reasons, we need to transform
+            # index.rst into index.html ...
+            output = output+".html"
         config.output_filename = os.path.basename(output)
         dbg_config("Output file: "+config.output_filename)
         args = "--config "+config.docutils+" "+input+' '+output




reply via email to

[Prev in Thread] Current Thread [Next in Thread]