Commit 939bbee1c007d307f80c538b2a09ee2632f16655

Ankit Dhankhar 2018-04-15T22:35:40

[docmaker] Make it work with python3. * src/tools/docmaker (*.py): Use parentheses around arguments of `print'. Remove unused imports.

diff --git a/src/tools/docmaker/content.py b/src/tools/docmaker/content.py
index c9969db..198780a 100644
--- a/src/tools/docmaker/content.py
+++ b/src/tools/docmaker/content.py
@@ -109,7 +109,7 @@ class  DocCode:
     def  dump( self, prefix = "", width = 60 ):
         lines = self.dump_lines( 0, width )
         for l in lines:
-            print prefix + l
+            print( prefix + l )
 
     def  dump_lines( self, margin = 0, width = 60 ):
         result = []
@@ -139,7 +139,7 @@ class  DocPara:
     def  dump( self, prefix = "", width = 60 ):
         lines = self.dump_lines( 0, width )
         for l in lines:
-            print prefix + l
+            print( prefix + l )
 
     def  dump_lines( self, margin = 0, width = 60 ):
         cur    = ""  # current line
@@ -243,13 +243,13 @@ class  DocField:
 
     def  dump( self, prefix = "" ):
         if self.field:
-            print prefix + self.field + " ::"
+            print( prefix + self.field + " ::" )
             prefix = prefix + "----"
 
         first = 1
         for p in self.items:
             if not first:
-                print ""
+                print( "" )
             p.dump( prefix )
             first = 0
 
@@ -330,10 +330,10 @@ class  DocMarkup:
             return None
 
     def  dump( self, margin ):
-        print " " * margin + "<" + self.tag + ">"
+        print( " " * margin + "<" + self.tag + ">" )
         for f in self.fields:
             f.dump( "  " )
-        print " " * margin + "</" + self.tag + ">"
+        print( " " * margin + "</" + self.tag + ">" )
 
 
 ################################################################
diff --git a/src/tools/docmaker/docbeauty.py b/src/tools/docmaker/docbeauty.py
index 3ddf4a9..0b021fa 100644
--- a/src/tools/docmaker/docbeauty.py
+++ b/src/tools/docmaker/docbeauty.py
@@ -10,9 +10,7 @@ from sources import *
 from content import *
 from utils   import *
 
-import utils
-
-import sys, os, time, string, getopt
+import sys, os, string, getopt
 
 
 content_processor = ContentProcessor()
@@ -40,13 +38,13 @@ def  beautify_block( block ):
 
 
 def  usage():
-    print "\nDocBeauty 0.1 Usage information\n"
-    print "  docbeauty [options] file1 [file2 ...]\n"
-    print "using the following options:\n"
-    print "  -h : print this page"
-    print "  -b : backup original files with the 'orig' extension"
-    print ""
-    print "  --backup : same as -b"
+    print( "\nDocBeauty 0.1 Usage information\n" )
+    print( "  docbeauty [options] file1 [file2 ...]\n" )
+    print( "using the following options:\n" )
+    print( "  -h : print this page" )
+    print( "  -b : backup original files with the 'orig' extension" )
+    print( "" )
+    print( "  --backup : same as -b" )
 
 
 def  main( argv ):
diff --git a/src/tools/docmaker/docmaker.py b/src/tools/docmaker/docmaker.py
index 253a4d3..eb49afb 100644
--- a/src/tools/docmaker/docmaker.py
+++ b/src/tools/docmaker/docmaker.py
@@ -31,21 +31,21 @@ from tohtml    import *
 
 import utils
 
-import sys, os, time, string, glob, getopt
+import sys, glob, getopt
 
 
 def  usage():
-    print "\nDocMaker Usage information\n"
-    print "  docmaker [options] file1 [file2 ...]\n"
-    print "using the following options:\n"
-    print "  -h : print this page"
-    print "  -t : set project title, as in '-t \"My Project\"'"
-    print "  -o : set output directory, as in '-o mydir'"
-    print "  -p : set documentation prefix, as in '-p ft2'"
-    print ""
-    print "  --title  : same as -t, as in '--title=\"My Project\"'"
-    print "  --output : same as -o, as in '--output=mydir'"
-    print "  --prefix : same as -p, as in '--prefix=ft2'"
+    print( "\nDocMaker Usage information\n" )
+    print( "  docmaker [options] file1 [file2 ...]\n" )
+    print( "using the following options:\n" )
+    print( "  -h : print this page" )
+    print( "  -t : set project title, as in '-t \"My Project\"'" )
+    print( "  -o : set output directory, as in '-o mydir'" )
+    print( "  -p : set documentation prefix, as in '-p ft2'" )
+    print( "" )
+    print( "  --title  : same as -t, as in '--title=\"My Project\"'" )
+    print( "  --output : same as -o, as in '--output=mydir'" )
+    print( "  --prefix : same as -p, as in '--prefix=ft2'" )
 
 
 def  main( argv ):
diff --git a/src/tools/docmaker/sources.py b/src/tools/docmaker/sources.py
index 2cd5a33..e3b95e0 100644
--- a/src/tools/docmaker/sources.py
+++ b/src/tools/docmaker/sources.py
@@ -29,7 +29,7 @@
 #
 
 
-import fileinput, re, sys, os, string
+import fileinput, re, string
 
 
 ################################################################
@@ -296,10 +296,10 @@ class  SourceBlock:
     # debugging only -- not used in normal operations
     def  dump( self ):
         if self.content:
-            print "{{{content start---"
+            print( "{{{content start---" )
             for l in self.content:
-                print l
-            print "---content end}}}"
+                print( l )
+            print( "---content end}}}" )
             return
 
         fmt = ""
@@ -307,7 +307,7 @@ class  SourceBlock:
             fmt = repr( self.format.id ) + " "
 
         for line in self.lines:
-            print line
+            print( line )
 
 
 ################################################################
diff --git a/src/tools/docmaker/tohtml.py b/src/tools/docmaker/tohtml.py
index 7f5ecda..9f318a2 100644
--- a/src/tools/docmaker/tohtml.py
+++ b/src/tools/docmaker/tohtml.py
@@ -406,7 +406,7 @@ class  HtmlFormatter( Formatter ):
         return string.join( lines, '\n' )
 
     def  print_html_items( self, items ):
-        print self.make_html_items( items )
+        print( self.make_html_items( items ) )
 
     def  print_html_field( self, field ):
         if field.name:
@@ -414,10 +414,10 @@ class  HtmlFormatter( Formatter ):
                    + field.name
                    + "</b></td><td>" )
 
-        print self.make_html_items( field.items )
+        print( self.make_html_items( field.items ) )
 
         if field.name:
-            print "</td></tr></table>"
+            print( "</td></tr></table>" )
 
     def  html_source_quote( self, line, block_name = None ):
         result = ""
@@ -468,14 +468,14 @@ class  HtmlFormatter( Formatter ):
         return result
 
     def  print_html_field_list( self, fields ):
-        print '<table class="fields">'
+        print( '<table class="fields">' )
         for field in fields:
-            print ( '<tr><td class="val" id="' + field.name + '">'
-                    + field.name
-                    + '</td><td class="desc">' )
+            print( '<tr><td class="val" id="' + field.name + '">'
+                   + field.name
+                   + '</td><td class="desc">' )
             self.print_html_items( field.items )
-            print "</td></tr>"
-        print "</table>"
+            print( "</td></tr>" )
+        print( "</table>" )
 
     def  print_html_markup( self, markup ):
         table_fields = []
@@ -499,7 +499,7 @@ class  HtmlFormatter( Formatter ):
     # formatting the index
     #
     def  index_enter( self ):
-        print self.html_index_header
+        print( self.html_index_header )
         self.index_items = {}
 
     def  index_name_enter( self, name ):
@@ -512,7 +512,7 @@ class  HtmlFormatter( Formatter ):
         count = len( self.block_index )
         rows  = ( count + self.columns - 1 ) // self.columns
 
-        print '<table class="index">'
+        print( '<table class="index">' )
         for r in range( rows ):
             line = "<tr>"
             for c in range( self.columns ):
@@ -531,15 +531,15 @@ class  HtmlFormatter( Formatter ):
                 else:
                     line = line + '<td></td>'
             line = line + "</tr>"
-            print line
+            print( line )
 
-        print "</table>"
+        print( "</table>" )
 
         print( index_footer_start
                + self.file_prefix + "toc.html"
                + index_footer_end )
 
-        print self.html_footer
+        print( self.html_footer )
 
         self.index_items = {}
 
@@ -553,25 +553,25 @@ class  HtmlFormatter( Formatter ):
     # formatting the table of contents
     #
     def  toc_enter( self ):
-        print self.html_toc_header
-        print "<h1>Table of Contents</h1>"
+        print( self.html_toc_header )
+        print( "<h1>Table of Contents</h1>" )
 
     def  toc_chapter_enter( self, chapter ):
-        print chapter_header + string.join( chapter.title ) + chapter_inter
-        print '<table class="toc">'
+        print( chapter_header + string.join( chapter.title ) + chapter_inter )
+        print( '<table class="toc">' )
 
     def  toc_section_enter( self, section ):
-        print ( '<tr><td class="link">'
-                + '<a href="' + self.make_section_url( section ) + '">'
-                + section.title + '</a></td><td class="desc">' )
-        print self.make_html_para( section.abstract )
+        print( '<tr><td class="link">'
+               + '<a href="' + self.make_section_url( section ) + '">'
+               + section.title + '</a></td><td class="desc">' )
+        print( self.make_html_para( section.abstract ) )
 
     def  toc_section_exit( self, section ):
-        print "</td></tr>"
+        print( "</td></tr>" )
 
     def  toc_chapter_exit( self, chapter ):
-        print "</table>"
-        print chapter_footer
+        print( "</table>" )
+        print( chapter_footer )
 
     def  toc_index( self, index_filename ):
         print( chapter_header
@@ -583,7 +583,7 @@ class  HtmlFormatter( Formatter ):
                + self.file_prefix + "index.html"
                + toc_footer_end )
 
-        print self.html_footer
+        print( self.html_footer )
 
     def  toc_dump( self, toc_filename = None, index_filename = None ):
         if toc_filename == None:
@@ -598,11 +598,11 @@ class  HtmlFormatter( Formatter ):
     # formatting sections
     #
     def  section_enter( self, section ):
-        print self.html_header
+        print( self.html_header )
 
-        print ( section_title_header1 + section.name + section_title_header2
-                + section.title
-                + section_title_footer )
+        print( section_title_header1 + section.name + section_title_header2
+               + section.title
+               + section_title_footer )
 
         maxwidth = 0
         for b in section.blocks.values():
@@ -612,8 +612,8 @@ class  HtmlFormatter( Formatter ):
         width = 70  # XXX magic number
         if maxwidth > 0:
             # print section synopsis
-            print section_synopsis_header
-            print '<table class="synopsis">'
+            print( section_synopsis_header )
+            print( '<table class="synopsis">' )
 
             columns = width // maxwidth
             if columns < 1:
@@ -650,17 +650,17 @@ class  HtmlFormatter( Formatter ):
 
                     line = line + '</td>'
                 line = line + "</tr>"
-                print line
+                print( line )
 
-            print "</table>"
-            print section_synopsis_footer
+            print( "</table>" )
+            print( section_synopsis_footer )
 
-        print description_header
-        print self.make_html_items( section.description )
-        print description_footer
+        print( description_header )
+        print( self.make_html_items( section.description ) )
+        print( description_footer )
 
     def  block_enter( self, block ):
-        print block_header
+        print( block_header )
 
         # place html anchor if needed
         if block.name:
@@ -686,28 +686,28 @@ class  HtmlFormatter( Formatter ):
 #                 + " '" + block.source.filename + "'.\n" )
 
             if header:
-                print ( header_location_header
-                        + 'Defined in ' + header + '.'
-                        + header_location_footer )
+                print( header_location_header
+                       + 'Defined in ' + header + '.'
+                       + header_location_footer )
 
-            print source_header
+            print( source_header )
             for l in block.code:
-                print self.html_source_quote( l, block.name )
-            print source_footer
+                print( self.html_source_quote( l, block.name ) )
+            print( source_footer )
 
     def  markup_enter( self, markup, block ):
         if markup.tag == "description":
-            print description_header
+            print( description_header )
         else:
-            print marker_header + markup.tag + marker_inter
+            print( marker_header + markup.tag + marker_inter )
 
         self.print_html_markup( markup )
 
     def  markup_exit( self, markup, block ):
         if markup.tag == "description":
-            print description_footer
+            print( description_footer )
         else:
-            print marker_footer
+            print( marker_footer )
 
     def  block_exit( self, block ):
         print( block_footer_start + self.file_prefix + "index.html"
@@ -715,7 +715,7 @@ class  HtmlFormatter( Formatter ):
                + block_footer_end )
 
     def  section_exit( self, section ):
-        print html_footer
+        print( html_footer )
 
     def  section_dump_all( self ):
         for section in self.sections: