Blame SOURCES/0001-FIX-port-documentation-scripts-to-python3.patch

5cf55c
From f04dd2918b15853e866d3941b72005696c8c3b8f Mon Sep 17 00:00:00 2001
5cf55c
From: Jakub Martisko <jamartis@redhat.com>
5cf55c
Date: Tue, 3 Jul 2018 09:33:07 +0200
5cf55c
Subject: [PATCH] FIX: port documentation scripts to python3
5cf55c
5cf55c
---
5cf55c
 configure                             |  2 +-
5cf55c
 configure.ac                          |  2 +-
5cf55c
 docs/cpp2markdown-1.py                |  9 ++++--
5cf55c
 docs/cpp2markdown.py                  |  6 ++--
5cf55c
 docs/make-doc.py                      | 56 ++++++++++++++++++-----------------
5cf55c
 docs/makedocs.py                      | 26 ++++++++--------
5cf55c
 docs/zzipdoc/commentmarkup.py         |  5 ++--
5cf55c
 docs/zzipdoc/dbk2htm.py               |  5 ++--
5cf55c
 docs/zzipdoc/docbookdocument.py       | 34 +++++++++++----------
5cf55c
 docs/zzipdoc/functionheader.py        |  3 +-
5cf55c
 docs/zzipdoc/functionlisthtmlpage.py  | 14 +++++----
5cf55c
 docs/zzipdoc/functionlistreference.py |  8 +++--
5cf55c
 docs/zzipdoc/functionprototype.py     |  3 +-
5cf55c
 docs/zzipdoc/htm2dbk.py               | 10 ++++---
5cf55c
 docs/zzipdoc/htmldocument.py          | 34 +++++++++++----------
5cf55c
 docs/zzipdoc/match.py                 | 17 ++++++-----
5cf55c
 docs/zzipdoc/options.py               |  5 ++--
5cf55c
 docs/zzipdoc/textfile.py              |  6 ++--
5cf55c
 docs/zzipdoc/textfileheader.py        |  6 ++--
5cf55c
 18 files changed, 140 insertions(+), 109 deletions(-)
5cf55c
5cf55c
diff --git a/configure b/configure
5cf55c
index 72a5b6c..6ff3ee4 100755
5cf55c
--- a/configure
5cf55c
+++ b/configure
5cf55c
@@ -12270,7 +12270,7 @@ fi
5cf55c
 done
5cf55c
 test -n "$PERL" || PERL="echo no perl found for"
5cf55c
 
5cf55c
-for ac_prog in python
5cf55c
+for ac_prog in python3
5cf55c
 do
5cf55c
   # Extract the first word of "$ac_prog", so it can be a program name with args.
5cf55c
 set dummy $ac_prog; ac_word=$2
5cf55c
diff --git a/configure.ac b/configure.ac
5cf55c
index 4708f8d..68aeb73 100644
5cf55c
--- a/configure.ac
5cf55c
+++ b/configure.ac
5cf55c
@@ -87,7 +87,7 @@ AX_CREATE_PKGCONFIG_INFO(dnl
5cf55c
 AX_PAX_TAR_CREATE
5cf55c
 AX_PAX_TAR_EXTRACT
5cf55c
 AC_PATH_PROGS(PERL, perl5 perl, echo no perl found for)
5cf55c
-AC_PATH_PROGS(PYTHON, python, echo no python found for)
5cf55c
+AC_PATH_PROGS(PYTHON, python3, echo no python found for)
5cf55c
 AC_PATH_PROGS(MKZIP, zip pkzip, :)
5cf55c
 AC_PATH_PROGS(XMLTO, xmlto, :)
5cf55c
 
5cf55c
diff --git a/docs/cpp2markdown-1.py b/docs/cpp2markdown-1.py
5cf55c
index 60d28c4..1deaed9 100755
5cf55c
--- a/docs/cpp2markdown-1.py
5cf55c
+++ b/docs/cpp2markdown-1.py
5cf55c
@@ -1,9 +1,12 @@
5cf55c
 #! /usr/bin/env python
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
 import pygments.lexers.compiled as lexer
5cf55c
 import optparse
5cf55c
 import re
5cf55c
 from pygments.token import Token
5cf55c
 import logging
5cf55c
+from six.moves import range
5cf55c
 
5cf55c
 logg = logging.getLogger(__name__)
5cf55c
 
5cf55c
@@ -39,7 +42,7 @@ class CppToMarkdown:
5cf55c
         check2 = re.compile(r"^\s[*]\s+\b[Cc]opyright\b")
5cf55c
         empty1 = re.compile(r"^\s[*]\s*$")
5cf55c
         state = "intro"
5cf55c
-        for i in xrange(1,len(lines)-1):
5cf55c
+        for i in range(1,len(lines)-1):
5cf55c
             line = lines[i]
5cf55c
             if state == "intro":
5cf55c
                 if empty1.match(line):
5cf55c
@@ -108,7 +111,7 @@ class CppToMarkdown:
5cf55c
     def run(self, filename):
5cf55c
         filetext = open(filename).read()
5cf55c
         for line in self.process(filetext, filename):
5cf55c
-            print line
5cf55c
+            print(line)
5cf55c
     def process(self, filetext, filename=""):
5cf55c
         section_ruler = "-----------------------------------------"
5cf55c
         copyright = ""
5cf55c
@@ -136,7 +139,7 @@ class CppToMarkdown:
5cf55c
             else:
5cf55c
                 if text:
5cf55c
                     yield "#### NOTES"
5cf55c
-                    print token, text.replace("\n", "\n  ")
5cf55c
+                    print(token, text.replace("\n", "\n  "))
5cf55c
         if copyright:
5cf55c
             yield section_ruler
5cf55c
             yield "### COPYRIGHT"
5cf55c
diff --git a/docs/cpp2markdown.py b/docs/cpp2markdown.py
5cf55c
index 710bbdc..b8fe11d 100644
5cf55c
--- a/docs/cpp2markdown.py
5cf55c
+++ b/docs/cpp2markdown.py
5cf55c
@@ -1,3 +1,5 @@
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
 import pygments.lexers.compiled as lexer
5cf55c
 import optparse
5cf55c
 import re
5cf55c
@@ -62,7 +64,7 @@ class CppToMarkdown:
5cf55c
     def run(self, filename):
5cf55c
         filetext = open(filename).read()
5cf55c
         for line in self.process(filetext, filename):
5cf55c
-            print line
5cf55c
+            print(line)
5cf55c
     def process(self, filetext, filename=""):
5cf55c
         for token, text in self.parse(filetext):
5cf55c
             if token == FileInclude:
5cf55c
@@ -86,7 +88,7 @@ class CppToMarkdown:
5cf55c
             else:
5cf55c
                 if text:
5cf55c
                     yield "#### NOTES"
5cf55c
-                    print token, text.replace("\n", "\n  ")
5cf55c
+                    print(token, text.replace("\n", "\n  "))
5cf55c
     def isexported_function(self):
5cf55c
         function = self.function_text.strip().replace("\n"," ")
5cf55c
         logg.debug("@ --------------------------------------") 
5cf55c
diff --git a/docs/make-doc.py b/docs/make-doc.py
5cf55c
index f12553f..22775ef 100644
5cf55c
--- a/docs/make-doc.py
5cf55c
+++ b/docs/make-doc.py
5cf55c
@@ -1,5 +1,7 @@
5cf55c
 #! /usr/bin/python
5cf55c
 # -*- coding: UTF-8 -*-
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
 import sys
5cf55c
 import re
5cf55c
 import string
5cf55c
@@ -23,7 +25,7 @@ def s(string, pattern, repl, count=0):
5cf55c
 def m(string, pattern):
5cf55c
     return re.match(pattern, string)
5cf55c
 def sorted_keys(dict):
5cf55c
-    keys = dict.keys()
5cf55c
+    keys = list(dict.keys())
5cf55c
     keys.sort()
5cf55c
     return keys
5cf55c
 
5cf55c
@@ -59,18 +61,18 @@ def section2html(text):
5cf55c
                 "<para>" : "

", "</para>" : "

" ,
5cf55c
                 "<function>" : "<link>", "</function>" : "</link>" }
5cf55c
     for str in mapping:
5cf55c
-        text = string.replace(text, str, mapping[str])
5cf55c
+        text = text.replace(str, mapping[str])
5cf55c
     return text
5cf55c
 def html(text):
5cf55c
     return section2html(paramdef2html(text))
5cf55c
 def cdata1(text):
5cf55c
-    return string.replace(text, "&",  "&")
5cf55c
+    return text.replace("&",  "&")
5cf55c
 def cdata31(text):
5cf55c
-    return string.replace(string.replace(text, "<","<"), ">",">")
5cf55c
+    return text.replace(text, "<","<").replace( ">",">")
5cf55c
 def cdata3(text):
5cf55c
     return cdata31(cdata1(text))
5cf55c
 def cdata43(text):
5cf55c
-    return string.replace(text,"\"", """)
5cf55c
+    return text.replace("\"", """)
5cf55c
 def cdata41(text):
5cf55c
     return cdata43(cdata31(text))
5cf55c
 def cdata4(text):
5cf55c
@@ -126,7 +128,7 @@ def this_function_link(text, name):
5cf55c
 class Options:
5cf55c
     var = {}
5cf55c
     def __getattr__(self, name):
5cf55c
-        if not self.var.has_key(name): return None
5cf55c
+        if name not in self.var: return None
5cf55c
         return self.var[name]
5cf55c
     def __setattr__(self, name, value):
5cf55c
         self.var[name] = value
5cf55c
@@ -158,7 +160,7 @@ class File:
5cf55c
         self.copyright = ""
5cf55c
     def __getattr__(self, name):
5cf55c
         """ defend against program to break on uninited members """
5cf55c
-        if self.__dict__.has_key(name): return self.__dict__[name]
5cf55c
+        if name in self.__dict__: return self.__dict__[name]
5cf55c
         warn("no such member: "+name); return None
5cf55c
     def set_author(self, text):
5cf55c
         if self.authors:
5cf55c
@@ -215,7 +217,7 @@ def scan_options (options, list):
5cf55c
         #else
5cf55c
         try:
5cf55c
             input = open(name, "r")
5cf55c
-        except IOError, error:
5cf55c
+        except IOError as error:
5cf55c
             warn(#...... (scan_options) ...............
5cf55c
                 "can not open input file: "+name, error)
5cf55c
             continue
5cf55c
@@ -294,12 +296,12 @@ class Function:
5cf55c
 #        return ""
5cf55c
     def __getattr__(self, name):
5cf55c
         """ defend against program exit on members being not inited """
5cf55c
-        if self.__dict__.has_key(name): return self.__dict__[name]
5cf55c
+        if name in self.__dict__: return self.__dict__[name]
5cf55c
         warn("no such member: "+name); return None
5cf55c
     def dict(self):
5cf55c
         return self.__dict__
5cf55c
     def dict_sorted_keys(self):
5cf55c
-        keys = self.__dict__.keys()
5cf55c
+        keys = list(self.__dict__.keys())
5cf55c
         keys.sort()
5cf55c
         return keys
5cf55c
     def parse(self, prototype):
5cf55c
@@ -376,7 +378,7 @@ def examine_head_anchors(func_list):
5cf55c
         function.head = s(function.head, r"(.*)also:(.*)", lambda x
5cf55c
                           : set_seealso(function, x.group(2)) and x.group(1))
5cf55c
         if function.seealso and None:
5cf55c
-            print "function[",function.name,"].seealso=",function.seealso
5cf55c
+            print("function[",function.name,"].seealso=",function.seealso)
5cf55c
 examine_head_anchors(function_list)
5cf55c
 
5cf55c
 # =============================================================== HTML =====
5cf55c
@@ -455,7 +457,7 @@ def combined_html_pages(func_list):
5cf55c
             s(ensure_name(this_function_link(section2html( func.body ),
5cf55c
                                              func.name), func.name),
5cf55c
               r"(?sx) (</?para>\s*) <br\s*\/>", r"\1"))
5cf55c
-    return combined.values()
5cf55c
+    return list(combined.values())
5cf55c
 html_pages = combined_html_pages(function_list)
5cf55c
 
5cf55c
 def html_resolve_links_on_page(text, list):
5cf55c
@@ -495,7 +497,7 @@ class HtmlPage:
5cf55c
         return T
5cf55c
     def add_page_map(self, list):
5cf55c
         """ generate the index-block at the start of the onepage-html file """
5cf55c
-        keys = list.keys()
5cf55c
+        keys = list(list.keys())
5cf55c
         keys.sort()
5cf55c
         for name in keys:
5cf55c
             self.toc += "\n"+ \
5cf55c
@@ -524,11 +526,11 @@ html.add_page_list(html_pages)
5cf55c
 # and finally print the html-formatted output
5cf55c
 try:
5cf55c
     F = open(o.libhtmlfile, "w")
5cf55c
-except IOError, error:
5cf55c
+except IOError as error:
5cf55c
     warn(# ............. open(o.libhtmlfile, "w") ..............
5cf55c
         "can not open html output file: "+o.libhtmlfile, error)
5cf55c
 else:
5cf55c
-    print >> F, html.page_text()
5cf55c
+    print(html.page_text(), file=F)
5cf55c
     F.close()
5cf55c
 #fi
5cf55c
 
5cf55c
@@ -987,40 +989,40 @@ doctype += '"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">'+"\n"
5cf55c
 
5cf55c
 try:
5cf55c
     F = open(o.docbookfile,"w")
5cf55c
-except IOError, error:
5cf55c
+except IOError as error:
5cf55c
     warn("can not open docbook output file: "+o.docbookfile, error)
5cf55c
 else:
5cf55c
-    print >> F, doctype, '<reference><title>Manual Pages</title>'
5cf55c
+    print(doctype, '<reference><title>Manual Pages</title>', file=F)
5cf55c
 
5cf55c
     for page in combined_pages:
5cf55c
-        print >> F, page.refentry_text()
5cf55c
+        print(page.refentry_text(), file=F)
5cf55c
     #od
5cf55c
 
5cf55c
     for page in header_refpages.values():
5cf55c
         if not page.refentry: continue
5cf55c
-        print >> F, "\n",
5cf55c
-        print >> F, page.refentry_text()
5cf55c
+        print("\n", end=' ', file=F)
5cf55c
+        print(page.refentry_text(), file=F)
5cf55c
     #od
5cf55c
 
5cf55c
-    print >> F, "\n",'</reference>',"\n"
5cf55c
+    print("\n",'</reference>',"\n", file=F)
5cf55c
     F.close()
5cf55c
 #fi
5cf55c
 
5cf55c
 # _____________________________________________________________________
5cf55c
 try:
5cf55c
     F = open( o.dumpdocfile, "w")
5cf55c
-except IOError, error:
5cf55c
+except IOError as error:
5cf55c
     warn ("can not open"+o.dumpdocfile,error)
5cf55c
 else:
5cf55c
     for func in function_list:
5cf55c
         name = func.name
5cf55c
-        print >> F, "<fn id=\""+name+"\">"+"\n"
5cf55c
+        print("<fn id=\""+name+"\">"+"\n", file=F)
5cf55c
         for H in sorted_keys(func.dict()):
5cf55c
-            print >> F, "<"+H+" name=\""+name+"\">",
5cf55c
-            print >> F, str(func.dict()[H]),
5cf55c
-            print >> F, "</"+H+">"
5cf55c
+            print("<"+H+" name=\""+name+"\">", end=' ', file=F)
5cf55c
+            print(str(func.dict()[H]), end=' ', file=F)
5cf55c
+            print("</"+H+">", file=F)
5cf55c
         #od
5cf55c
-        print >> F, "</fn>\n\n";
5cf55c
+        print("</fn>\n\n", file=F);
5cf55c
     #od
5cf55c
     F.close();
5cf55c
 #fi
5cf55c
diff --git a/docs/makedocs.py b/docs/makedocs.py
5cf55c
index 1bc8f88..d987292 100644
5cf55c
--- a/docs/makedocs.py
5cf55c
+++ b/docs/makedocs.py
5cf55c
@@ -1,3 +1,5 @@
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
 import sys
5cf55c
 from zzipdoc.match import *
5cf55c
 from zzipdoc.options import *
5cf55c
@@ -37,7 +39,7 @@ class PerFile:
5cf55c
         return None
5cf55c
     def print_list_mainheader(self):
5cf55c
         for t_fileheader in self.headers:
5cf55c
-            print t_fileheader.get_filename(), t_fileheader.src_mainheader()
5cf55c
+            print(t_fileheader.get_filename(), t_fileheader.src_mainheader())
5cf55c
         
5cf55c
 class PerFunctionEntry:
5cf55c
     def __init__(self, header, comment, prototype):
5cf55c
@@ -66,10 +68,10 @@ class PerFunction:
5cf55c
                                            functionprototype) ]
5cf55c
     def print_list_titleline(self):
5cf55c
         for funcheader in self.headers:
5cf55c
-            print funcheader.get_filename(), "[=>]", funcheader.get_titleline()
5cf55c
+            print(funcheader.get_filename(), "[=>]", funcheader.get_titleline())
5cf55c
     def print_list_name(self):
5cf55c
         for funcheader in self.prototypes:
5cf55c
-            print funcheader.get_filename(), "[>>]", funcheader.get_name()
5cf55c
+            print(funcheader.get_filename(), "[>>]", funcheader.get_name())
5cf55c
 
5cf55c
 class PerFunctionFamilyEntry:
5cf55c
     def __init__(self, leader):
5cf55c
@@ -122,12 +124,12 @@ class PerFunctionFamily:
5cf55c
         for name in self.retarget:
5cf55c
             into = self.retarget[name]
5cf55c
             if into not in name_list:
5cf55c
-                print ("function '"+name+"' retarget into '"+into+
5cf55c
-                       "' does not exist - keep alone")
5cf55c
+                print(("function '"+name+"' retarget into '"+into+
5cf55c
+                       "' does not exist - keep alone"))
5cf55c
             if into in self.retarget:
5cf55c
                 other = self.retarget[into]
5cf55c
-                print ("function '"+name+"' retarget into '"+into+
5cf55c
-                       "' which is itself a retarget into '"+other+"'")
5cf55c
+                print(("function '"+name+"' retarget into '"+into+
5cf55c
+                       "' which is itself a retarget into '"+other+"'"))
5cf55c
             if into not in lead_list:
5cf55c
                 lead_list += [ into ]
5cf55c
         for func in self.functions:
5cf55c
@@ -141,7 +143,7 @@ class PerFunctionFamily:
5cf55c
                 entry.add(func) # the first
5cf55c
                 self.entries += [ entry ]
5cf55c
             else:
5cf55c
-                print "head function '"+name+" has no entry"
5cf55c
+                print("head function '"+name+" has no entry")
5cf55c
         for func in self.functions:
5cf55c
             name = func.get_name()
5cf55c
             if name in self.retarget:
5cf55c
@@ -150,14 +152,14 @@ class PerFunctionFamily:
5cf55c
                 if entry is not None:
5cf55c
                     entry.add(func) # will not add duplicates
5cf55c
                 else:
5cf55c
-                    print "into function '"+name+" has no entry"
5cf55c
+                    print("into function '"+name+" has no entry")
5cf55c
     def print_list_name(self):
5cf55c
         for family in self.entries:
5cf55c
             name = family.get_name()
5cf55c
-            print name, ":",
5cf55c
+            print(name, ":", end=' ')
5cf55c
             for item in family.functions:
5cf55c
-                print item.get_name(), ",",
5cf55c
-            print ""
5cf55c
+                print(item.get_name(), ",", end=' ')
5cf55c
+            print("")
5cf55c
 class HtmlManualPageAdapter:
5cf55c
     def __init__(self, entry):
5cf55c
         """ usually takes a PerFunctionEntry """
5cf55c
diff --git a/docs/zzipdoc/commentmarkup.py b/docs/zzipdoc/commentmarkup.py
5cf55c
index 3f605a7..31727a3 100644
5cf55c
--- a/docs/zzipdoc/commentmarkup.py
5cf55c
+++ b/docs/zzipdoc/commentmarkup.py
5cf55c
@@ -1,4 +1,5 @@
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 def markup_link_syntax(text):
5cf55c
     """ markup the link-syntax ` => somewhere ` in the text block """
5cf55c
@@ -31,7 +32,7 @@ class CommentMarkup:
5cf55c
         comment = self.header.comment
5cf55c
         try:
5cf55c
             comment = self.header.get_otherlines()
5cf55c
-        except Exception, e:
5cf55c
+        except Exception as e:
5cf55c
             pass
5cf55c
         mode = ""
5cf55c
         text = ""
5cf55c
diff --git a/docs/zzipdoc/dbk2htm.py b/docs/zzipdoc/dbk2htm.py
5cf55c
index f8593e6..2b68e95 100644
5cf55c
--- a/docs/zzipdoc/dbk2htm.py
5cf55c
+++ b/docs/zzipdoc/dbk2htm.py
5cf55c
@@ -1,4 +1,5 @@
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from .match import Match
5cf55c
 import string
5cf55c
 
5cf55c
 class dbk2htm_conversion:
5cf55c
@@ -9,7 +10,7 @@ class dbk2htm_conversion:
5cf55c
         pass
5cf55c
     def section2html(self, text):
5cf55c
         for str in self.mapping:
5cf55c
-            text = string.replace(text, str, self.mapping[str])
5cf55c
+            text = text.replace(str, self.mapping[str])
5cf55c
         return text
5cf55c
     def paramdef2html(self, text):
5cf55c
         s = Match()
5cf55c
diff --git a/docs/zzipdoc/docbookdocument.py b/docs/zzipdoc/docbookdocument.py
5cf55c
index c4602ad..44a0b23 100644
5cf55c
--- a/docs/zzipdoc/docbookdocument.py
5cf55c
+++ b/docs/zzipdoc/docbookdocument.py
5cf55c
@@ -1,6 +1,8 @@
5cf55c
 #! /usr/bin/env python
5cf55c
 # -*- coding: UTF-8 -*-
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 class DocbookDocument:
5cf55c
     """ binds some xml content page with additional markup - in this
5cf55c
@@ -23,14 +25,14 @@ class DocbookDocument:
5cf55c
     def get_title(self):
5cf55c
         if self.title: return title
5cf55c
         try:   return self.text[0].get_title()
5cf55c
-        except Exception, e: pass
5cf55c
+        except Exception as e: pass
5cf55c
         return self.title
5cf55c
     def _xml_doctype(self, rootnode):
5cf55c
         return ""
5cf55c
     def _xml_text(self, xml):
5cf55c
         """ accepts adapter objects with .xml_text() """
5cf55c
         try:   return xml.xml_text()
5cf55c
-        except Exception, e: print "DocbookDocument/text", e; pass
5cf55c
+        except Exception as e: print("DocbookDocument/text", e); pass
5cf55c
         return str(xml)
5cf55c
     def _fetch_rootnode(self, text):
5cf55c
         fetch = Match(r"^[^<>]*<(\w+)\b")
5cf55c
@@ -47,7 +49,7 @@ class DocbookDocument:
5cf55c
         return filename
5cf55c
     def save(self, filename = None):
5cf55c
         filename = self._filename(filename)
5cf55c
-        print "writing '"+filename+"'"
5cf55c
+        print("writing '"+filename+"'")
5cf55c
         if len(self.text) > 1:
5cf55c
             self.save_all(filename)
5cf55c
         else:
5cf55c
@@ -58,12 +60,12 @@ class DocbookDocument:
5cf55c
             xml_text = self._xml_text(text)
5cf55c
             rootnode = self._fetch_rootnode(xml_text)
5cf55c
             doctype = self._xml_doctype(rootnode)
5cf55c
-            print >>fd, doctype
5cf55c
-            print >>fd, xml_text
5cf55c
+            print(doctype, file=fd)
5cf55c
+            print(xml_text, file=fd)
5cf55c
             fd.close()
5cf55c
             return True
5cf55c
-        except IOError, e:
5cf55c
-            print "could not open '"+filename+"'file", e
5cf55c
+        except IOError as e:
5cf55c
+            print("could not open '"+filename+"'file", e)
5cf55c
             return False
5cf55c
     def save_all(self, filename):
5cf55c
         assert len(self.text) > 1
5cf55c
@@ -76,20 +78,20 @@ class DocbookDocument:
5cf55c
             else:
5cf55c
                 rootnode = self.rootnode
5cf55c
             doctype = self._xml_doctype(rootnode)
5cf55c
-            print >>fd, doctype
5cf55c
+            print(doctype, file=fd)
5cf55c
             title = self.get_title()
5cf55c
             if title and self.rootnode in self.has_title_child:
5cf55c
-                print >>fd, "<"+self.rootnode+'><title>'+title+'</title>'
5cf55c
+                print("<"+self.rootnode+'><title>'+title+'</title>', file=fd)
5cf55c
             elif title:
5cf55c
-                print >>fd, "<"+self.rootnode+' id="'+title+'">'
5cf55c
+                print("<"+self.rootnode+' id="'+title+'">', file=fd)
5cf55c
             else:
5cf55c
-                print >>fd, "<"+self.rootnode+'>'
5cf55c
+                print("<"+self.rootnode+'>', file=fd)
5cf55c
             for text in self.text:
5cf55c
                 text = self._xml_text(text)
5cf55c
-                print >>fd, text
5cf55c
-            print >>fd, "</"+self.rootnode+">"
5cf55c
+                print(text, file=fd)
5cf55c
+            print("</"+self.rootnode+">", file=fd)
5cf55c
             fd.close()
5cf55c
             return True
5cf55c
-        except IOError, e:
5cf55c
-            print "could not open '"+filename+"'file", e
5cf55c
+        except IOError as e:
5cf55c
+            print("could not open '"+filename+"'file", e)
5cf55c
             return False
5cf55c
diff --git a/docs/zzipdoc/functionheader.py b/docs/zzipdoc/functionheader.py
5cf55c
index 81bb385..a424a6d 100644
5cf55c
--- a/docs/zzipdoc/functionheader.py
5cf55c
+++ b/docs/zzipdoc/functionheader.py
5cf55c
@@ -1,4 +1,5 @@
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 class FunctionHeader:
5cf55c
     """ parsing the comment block that is usually presented before
5cf55c
diff --git a/docs/zzipdoc/functionlisthtmlpage.py b/docs/zzipdoc/functionlisthtmlpage.py
5cf55c
index 4ec9178..8009194 100644
5cf55c
--- a/docs/zzipdoc/functionlisthtmlpage.py
5cf55c
+++ b/docs/zzipdoc/functionlisthtmlpage.py
5cf55c
@@ -1,5 +1,7 @@
5cf55c
-from options import *
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
+from .options import *
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 class FunctionListHtmlPage:
5cf55c
     """ The main part here is to create a TOC (table of contents) at the
5cf55c
@@ -35,7 +37,7 @@ class FunctionListHtmlPage:
5cf55c
         head_text = entry.head_xml_text()
5cf55c
         body_text = entry.body_xml_text(name)
5cf55c
         if not head_text:
5cf55c
-            print "no head_text for", name
5cf55c
+            print("no head_text for", name)
5cf55c
             return
5cf55c
         try:
5cf55c
             prespec = entry.head_get_prespec()
5cf55c
@@ -43,7 +45,7 @@ class FunctionListHtmlPage:
5cf55c
             callspec = entry.head_get_callspec()
5cf55c
             head_text = ("<function>"+namespec+"</function>"
5cf55c
                          +callspec+" : "+prespec+"")
5cf55c
-        except Exception, e:
5cf55c
+        except Exception as e:
5cf55c
             pass
5cf55c
         try:
5cf55c
             extraline = ""
5cf55c
@@ -56,7 +58,7 @@ class FunctionListHtmlPage:
5cf55c
                              '<small>'+filename+'</small>'+
5cf55c
                              '')
5cf55c
             body_text = extraline + body_text
5cf55c
-        except Exception, e:
5cf55c
+        except Exception as e:
5cf55c
             pass
5cf55c
         def link(text):
5cf55c
             return (text & Match("<function>(\w*)</function>")
5cf55c
@@ -102,7 +104,7 @@ class FunctionListHtmlPage:
5cf55c
         text &= (Match("(?s)<link>(\w+)</link>")
5cf55c
                  >> (lambda x: self.resolve_internal(x.group(1))))
5cf55c
         if len(self.not_found_in_anchors):
5cf55c
-            print "not found in anchors: ", self.not_found_in_anchors
5cf55c
+            print("not found in anchors: ", self.not_found_in_anchors)
5cf55c
         return (text & Match("(?s)<link>([^<>]*)</link>")
5cf55c
                 >> "\\1")
5cf55c
     def resolve_external(self, func, sect):
5cf55c
diff --git a/docs/zzipdoc/functionlistreference.py b/docs/zzipdoc/functionlistreference.py
5cf55c
index c38ff0a..5993d45 100644
5cf55c
--- a/docs/zzipdoc/functionlistreference.py
5cf55c
+++ b/docs/zzipdoc/functionlistreference.py
5cf55c
@@ -1,7 +1,9 @@
5cf55c
 #! /usr/bin/env python
5cf55c
 # -*- coding: UTF-8 -*-
5cf55c
-from match import Match
5cf55c
-from htm2dbk import *
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
+from .match import Match
5cf55c
+from .htm2dbk import *
5cf55c
 
5cf55c
 class FunctionListReference:
5cf55c
     """ Creating a docbook-style <reference> list of <refentry> parts
5cf55c
@@ -19,7 +21,7 @@ class FunctionListReference:
5cf55c
         description = entry.body_xml_text(name)
5cf55c
         funcsynopsis = entry.head_xml_text()
5cf55c
         if not funcsynopsis:
5cf55c
-            print "no funcsynopsis for", name
5cf55c
+            print("no funcsynopsis for", name)
5cf55c
             return
5cf55c
         if self.entry is None:
5cf55c
             self.entry = FunctionListRefEntry(entry, self.o)
5cf55c
diff --git a/docs/zzipdoc/functionprototype.py b/docs/zzipdoc/functionprototype.py
5cf55c
index fda85bb..1247f6c 100644
5cf55c
--- a/docs/zzipdoc/functionprototype.py
5cf55c
+++ b/docs/zzipdoc/functionprototype.py
5cf55c
@@ -1,4 +1,5 @@
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 class FunctionPrototype:
5cf55c
     """ takes a single function prototype line (cut from some source file)
5cf55c
diff --git a/docs/zzipdoc/htm2dbk.py b/docs/zzipdoc/htm2dbk.py
5cf55c
index ec9685b..12b70dd 100644
5cf55c
--- a/docs/zzipdoc/htm2dbk.py
5cf55c
+++ b/docs/zzipdoc/htm2dbk.py
5cf55c
@@ -6,8 +6,10 @@ The mapping of markups and links is far from perfect. But all we
5cf55c
 want is the docbook-to-pdf converter and similar technology being
5cf55c
 present in the world of docbook-to-anything converters. """
5cf55c
 
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
 from datetime import date
5cf55c
-import match
5cf55c
+from . import match
5cf55c
 import sys
5cf55c
 
5cf55c
 m = match.Match
5cf55c
@@ -146,8 +148,8 @@ def htm2dbk_files(args):
5cf55c
             doc.filename = filename
5cf55c
             doc.add(f.read())
5cf55c
             f.close()
5cf55c
-        except IOError, e:
5cf55c
-            print >> sys.stderr, "can not open "+filename
5cf55c
+        except IOError as e:
5cf55c
+            print("can not open "+filename, file=sys.stderr)
5cf55c
     return doc.value()
5cf55c
 
5cf55c
 def html2docbook(text):
5cf55c
@@ -155,4 +157,4 @@ def html2docbook(text):
5cf55c
     return htm2dbk_conversion().convert2(text)
5cf55c
 
5cf55c
 if __name__ == "__main__":
5cf55c
-    print htm2dbk_files(sys.argv[1:])
5cf55c
+    print(htm2dbk_files(sys.argv[1:]))
5cf55c
diff --git a/docs/zzipdoc/htmldocument.py b/docs/zzipdoc/htmldocument.py
5cf55c
index 47d58dc..5e4445a 100644
5cf55c
--- a/docs/zzipdoc/htmldocument.py
5cf55c
+++ b/docs/zzipdoc/htmldocument.py
5cf55c
@@ -1,6 +1,8 @@
5cf55c
 #! /usr/bin/env python
5cf55c
 # -*- coding: UTF-8 -*-
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 class HtmlDocument:
5cf55c
     """ binds some html content page with additional markup - in this
5cf55c
@@ -29,31 +31,31 @@ class HtmlDocument:
5cf55c
     def get_title(self):
5cf55c
         if self.title: return self.title
5cf55c
         try:   return self.text[0].get_title()
5cf55c
-        except Exception, e: pass
5cf55c
+        except Exception as e: pass
5cf55c
         return self.title
5cf55c
     def _html_meta(self, meta):
5cf55c
         """ accepts adapter objects with .html_meta() """
5cf55c
         try:   return meta.html_meta()
5cf55c
-        except Exception, e: pass
5cf55c
+        except Exception as e: pass
5cf55c
         return str(meta)
5cf55c
     def _html_style(self, style):
5cf55c
         """ accepts adapter objects with .html_style() and .xml_style() """
5cf55c
         ee = None
5cf55c
         try:   return style.html_style()
5cf55c
-        except Exception, e: ee = e; pass
5cf55c
+        except Exception as e: ee = e; pass
5cf55c
         try:   return style.xml_style()
5cf55c
-        except Exception, e: print "HtmlDocument/style", ee, e; pass
5cf55c
+        except Exception as e: print("HtmlDocument/style", ee, e); pass
5cf55c
         try:   return str(style)
5cf55c
-        except Exception, e: print "HtmlDocument/style", e; return ""
5cf55c
+        except Exception as e: print("HtmlDocument/style", e); return ""
5cf55c
     def _html_text(self, html):
5cf55c
         """ accepts adapter objects with .html_text() and .xml_text() """
5cf55c
         ee = None
5cf55c
         try:   return html.html_text()
5cf55c
-        except Exception, e: ee = e; pass
5cf55c
+        except Exception as e: ee = e; pass
5cf55c
         try:   return html.xml_text()
5cf55c
-        except Exception, e: print "HtmlDocument/text", ee, e; pass
5cf55c
+        except Exception as e: print("HtmlDocument/text", ee, e); pass
5cf55c
         try:   return str(html)
5cf55c
-        except Exception, e: print "HtmlDocument/text", e; return " "
5cf55c
+        except Exception as e: print("HtmlDocument/text", e); return " "
5cf55c
     def navigation(self):
5cf55c
         if self.navi:
5cf55c
             return self.navi
5cf55c
@@ -63,7 +65,7 @@ class HtmlDocument:
5cf55c
                 self.navi = fd.read()
5cf55c
                 fd.close()
5cf55c
                 return self.navi
5cf55c
-            except Exception, e:
5cf55c
+            except Exception as e:
5cf55c
                 pass
5cf55c
         return None
5cf55c
     def html_header(self):
5cf55c
@@ -103,15 +105,15 @@ class HtmlDocument:
5cf55c
         return filename
5cf55c
     def save(self, filename = None):
5cf55c
         filename = self._filename(filename)
5cf55c
-        print "writing '"+filename+"'"
5cf55c
+        print("writing '"+filename+"'")
5cf55c
         try:
5cf55c
             fd = open(filename, "w")
5cf55c
-            print >>fd, self.html_header()
5cf55c
+            print(self.html_header(), file=fd)
5cf55c
             for text in self.text:
5cf55c
-                print >>fd, self._html_text(text)
5cf55c
-            print >>fd, self.html_footer()
5cf55c
+                print(self._html_text(text), file=fd)
5cf55c
+            print(self.html_footer(), file=fd)
5cf55c
             fd.close()
5cf55c
             return True
5cf55c
-        except IOError, e:
5cf55c
-            print "could not open '"+filename+"'file", e
5cf55c
+        except IOError as e:
5cf55c
+            print("could not open '"+filename+"'file", e)
5cf55c
             return False
5cf55c
diff --git a/docs/zzipdoc/match.py b/docs/zzipdoc/match.py
5cf55c
index a089ec3..5f12478 100644
5cf55c
--- a/docs/zzipdoc/match.py
5cf55c
+++ b/docs/zzipdoc/match.py
5cf55c
@@ -3,7 +3,10 @@
5cf55c
 # @creator (C) 2003 Guido U. Draheim
5cf55c
 # @license http://creativecommons.org/licenses/by-nc-sa/2.0/de/
5cf55c
 
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
 import re
5cf55c
+import six
5cf55c
 
5cf55c
 # ---------------------------------------------------------- Regex Match()
5cf55c
 # beware, stupid python interprets backslashes in replace-parts only partially!
5cf55c
@@ -18,7 +21,7 @@ class MatchReplace:
5cf55c
         MatchReplace.__call__(self, matching, template, count, flags)
5cf55c
     def __call__(self, matching, template = None, count = 0, flags = None):
5cf55c
         """ other than __init__ the template may be left off to be unchanged"""
5cf55c
-        if isinstance(count, basestring): # count/flags swapped over?
5cf55c
+        if isinstance(count, six.string_types): # count/flags swapped over?
5cf55c
             flags = count; count = 0
5cf55c
         if isinstance(matching, Match):
5cf55c
             self.matching = matching
5cf55c
@@ -57,7 +60,7 @@ class Match(str):
5cf55c
     def __call__(self, pattern, flags = None):
5cf55c
         assert isinstance(pattern, str) or pattern is None
5cf55c
         assert isinstance(flags, str) or flags is None
5cf55c
-        str.__init__(self, pattern)
5cf55c
+        super(Match,self).__init__()
5cf55c
         self.replaced = 0 # set by subn() inside MatchReplace
5cf55c
         self.found = None # set by search() to a MatchObject
5cf55c
         self.pattern = pattern
5cf55c
@@ -90,14 +93,14 @@ class Match(str):
5cf55c
 if __name__ == "__main__":
5cf55c
     # matching:
5cf55c
     if "foo" & Match("oo"):
5cf55c
-        print "oo"
5cf55c
+        print("oo")
5cf55c
     x = Match()
5cf55c
     if "foo" & x("(o+)"):
5cf55c
-        print x[1]
5cf55c
+        print(x[1])
5cf55c
     # replacing:
5cf55c
     y = "fooboo" & Match("oo") >> "ee"
5cf55c
-    print y
5cf55c
+    print(y)
5cf55c
     r = Match("oo") >> "ee"
5cf55c
-    print "fooboo" & r
5cf55c
+    print("fooboo" & r)
5cf55c
     s = MatchReplace("oo", "ee")
5cf55c
-    print "fooboo" & s
5cf55c
+    print("fooboo" & s)
5cf55c
diff --git a/docs/zzipdoc/options.py b/docs/zzipdoc/options.py
5cf55c
index c6758d5..4a93bb7 100644
5cf55c
--- a/docs/zzipdoc/options.py
5cf55c
+++ b/docs/zzipdoc/options.py
5cf55c
@@ -3,13 +3,14 @@
5cf55c
 # @creator (C) 2003 Guido U. Draheim
5cf55c
 # @license http://creativecommons.org/licenses/by-nc-sa/2.0/de/
5cf55c
 
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 # use as o.optionname to check for commandline options.
5cf55c
 class Options:
5cf55c
     var = {}
5cf55c
     def __getattr__(self, name):
5cf55c
-        if not self.var.has_key(name): return None
5cf55c
+        if name not in self.var: return None
5cf55c
         return self.var[name]
5cf55c
     def __setattr__(self, name, value):
5cf55c
         self.var[name] = value
5cf55c
diff --git a/docs/zzipdoc/textfile.py b/docs/zzipdoc/textfile.py
5cf55c
index bfaff8d..9fabeac 100644
5cf55c
--- a/docs/zzipdoc/textfile.py
5cf55c
+++ b/docs/zzipdoc/textfile.py
5cf55c
@@ -1,4 +1,6 @@
5cf55c
 
5cf55c
+from __future__ import absolute_import
5cf55c
+from six.moves import range
5cf55c
 def _src_to_xml(text):
5cf55c
     return text.replace("&", "&").replace("<", "<").replace(">", "&gt")
5cf55c
 
5cf55c
@@ -17,7 +19,7 @@ class TextFile:
5cf55c
             self.src_text = fd.read()
5cf55c
             fd.close()
5cf55c
             return True
5cf55c
-        except IOError, e:
5cf55c
+        except IOError as e:
5cf55c
             pass
5cf55c
         return False
5cf55c
     def assert_src_text(self):
5cf55c
@@ -41,7 +43,7 @@ class TextFile:
5cf55c
         self._line(self.src_text, offset)
5cf55c
     def _line(self, text, offset):
5cf55c
         line = 1
5cf55c
-        for x in xrange(0,offset):
5cf55c
+        for x in range(0,offset):
5cf55c
             if x == "\n":
5cf55c
                 line += 1
5cf55c
         return line
5cf55c
diff --git a/docs/zzipdoc/textfileheader.py b/docs/zzipdoc/textfileheader.py
5cf55c
index ceaa28e..63be1e1 100644
5cf55c
--- a/docs/zzipdoc/textfileheader.py
5cf55c
+++ b/docs/zzipdoc/textfileheader.py
5cf55c
@@ -1,4 +1,6 @@
5cf55c
-from match import Match
5cf55c
+from __future__ import absolute_import
5cf55c
+from __future__ import print_function
5cf55c
+from .match import Match
5cf55c
 
5cf55c
 class TextFileHeader:
5cf55c
     """ scan for a comment block at the source file start and fill the
5cf55c
@@ -17,7 +19,7 @@ class TextFileHeader:
5cf55c
         x = Match()
5cf55c
         text = self.textfile.get_src_text()
5cf55c
         if not text:
5cf55c
-            print "nonexistent file:", self.textfile.get_filename()
5cf55c
+            print("nonexistent file:", self.textfile.get_filename())
5cf55c
             return False
5cf55c
         if text & x(r"(?s)[/][*]+(\s(?:.(?!\*\/))*.)\*\/"
5cf55c
                     r"(?:\s*\#(?:define|ifdef|endif)[ ]*\S*[ ]*\S*)*"
5cf55c
-- 
5cf55c
2.14.4
5cf55c