#! /usr/bin/env python
+
+from __future__ import print_function
+
import pygments.lexers.compiled as lexer
import optparse
import re
def run(self, filename):
filetext = open(filename).read()
for line in self.process(filetext, filename):
- print line
+ print(line)
def process(self, filetext, filename=""):
section_ruler = "-----------------------------------------"
copyright = ""
else:
if text:
yield "#### NOTES"
- print token, text.replace("\n", "\n ")
+ print(token + " " + text.replace("\n", "\n "))
if copyright:
yield section_ruler
yield "### COPYRIGHT"
+from __future__ import print_function
+
import pygments.lexers.compiled as lexer
import optparse
import re
def run(self, filename):
filetext = open(filename).read()
for line in self.process(filetext, filename):
- print line
+ print(line)
def process(self, filetext, filename=""):
for token, text in self.parse(filetext):
if token == FileInclude:
else:
if text:
yield "#### NOTES"
- print token, text.replace("\n", "\n ")
+ print(token + " " + text.replace("\n", "\n "))
def isexported_function(self):
function = self.function_text.strip().replace("\n"," ")
logg.debug("@ --------------------------------------")
#! /usr/bin/python
# -*- coding: UTF-8 -*-
+
+from __future__ import print_function
+
import sys
import re
import string
function.head = s(function.head, r"(.*)also:(.*)", lambda x
: set_seealso(function, x.group(2)) and x.group(1))
if function.seealso and None:
- print "function[",function.name,"].seealso=",function.seealso
+ print("function[" + function.name + "].seealso=" + function.seealso)
examine_head_anchors(function_list)
# =============================================================== HTML =====
warn(# ............. open(o.libhtmlfile, "w") ..............
"can not open html output file: "+o.libhtmlfile, error)
else:
- print >> F, html.page_text()
+ print(html.page_text(), file=F)
F.close()
#fi
except IOError as error:
warn("can not open docbook output file: "+o.docbookfile, error)
else:
- print >> F, doctype, '<reference><title>Manual Pages</title>'
+ print(doctype + '<reference><title>Manual Pages</title>', file=F)
for page in combined_pages:
- print >> F, page.refentry_text()
+ print(page.refentry_text(), file=F)
#od
for page in header_refpages.values():
if not page.refentry: continue
- print >> F, "\n<!-- _______ "+page.id+" _______ -->",
- print >> F, page.refentry_text()
+ print("\n<!-- _______ "+page.id+" _______ -->" + page.refentry_text(), file=F)
#od
- print >> F, "\n",'</reference>',"\n"
+ print("\n</reference>\n", file=F)
F.close()
#fi
else:
for func in function_list:
name = func.name
- print >> F, "<fn id=\""+name+"\">"+"<!-- FOR \""+name+"\" -->\n"
+ print("<fn id=\""+name+"\">"+"<!-- FOR \""+name+"\" -->\n", file=F)
for H in sorted_keys(func.dict()):
- print >> F, "<"+H+" name=\""+name+"\">",
- print >> F, str(func.dict()[H]),
- print >> F, "</"+H+">"
+ print("<"+H+" name=\""+name+"\">" + str(func.dict()[H]) + "</"+H+">", file=F)
#od
- print >> F, "</fn><!-- END \""+name+"\" -->\n\n";
+ print("</fn><!-- END \""+name+"\" -->\n\n", file=F)
#od
F.close();
#fi
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
+
+from __future__ import print_function
+
from zzipdoc.match import Match
class DocbookDocument:
def _xml_text(self, xml):
""" accepts adapter objects with .xml_text() """
try: return xml.xml_text()
- except Exception as e: print "DocbookDocument/text", e; pass
+ except Exception as e: print("DocbookDocument/text" + str(e)); pass
return str(xml)
def _fetch_rootnode(self, text):
fetch = Match(r"^[^<>]*<(\w+)\b")
return filename
def save(self, filename = None):
filename = self._filename(filename)
- print "writing '"+filename+"'"
+ print("writing '"+filename+"'")
if len(self.text) > 1:
self.save_all(filename)
else:
xml_text = self._xml_text(text)
rootnode = self._fetch_rootnode(xml_text)
doctype = self._xml_doctype(rootnode)
- print >>fd, doctype
- print >>fd, xml_text
+ print(doctype, file=fd)
+ print(xml_text, file=fd)
fd.close()
return True
except IOError as e:
- print "could not open '"+filename+"'file", e
+ print("could not open '"+filename+"'file" + str(e))
return False
def save_all(self, filename):
assert len(self.text) > 1
else:
rootnode = self.rootnode
doctype = self._xml_doctype(rootnode)
- print >>fd, doctype
+ print(doctype, file=fd)
title = self.get_title()
if title and self.rootnode in self.has_title_child:
- print >>fd, "<"+self.rootnode+'><title>'+title+'</title>'
+ print("<"+self.rootnode+'><title>'+title+'</title>', file=fd)
elif title:
- print >>fd, "<"+self.rootnode+' id="'+title+'">'
+ print("<"+self.rootnode+' id="'+title+'">', file=fd)
else:
- print >>fd, "<"+self.rootnode+'>'
+ print("<"+self.rootnode+'>', file=fd)
for text in self.text:
text = self._xml_text(text)
- print >>fd, text
- print >>fd, "</"+self.rootnode+">"
+ print(text)
+ print("</"+self.rootnode+">", file=fd)
fd.close()
return True
except IOError as e:
- print "could not open '"+filename+"'file", e
+ print("could not open '"+filename+"'file" + str(e))
return False
+from __future__ import print_function
+
from zzipdoc.options import *
from zzipdoc.match import Match
head_text = entry.head_xml_text()
body_text = entry.body_xml_text(name)
if not head_text:
- print "no head_text for", name
+ print("no head_text for " + name)
return
try:
prespec = entry.head_get_prespec()
text &= (Match("(?s)<link>(\w+)</link>")
>> (lambda x: self.resolve_internal(x.group(1))))
if len(self.not_found_in_anchors):
- print "not found in anchors: ", self.not_found_in_anchors
+ print("not found in anchors: {}".format(self.not_found_in_anchors))
return (text & Match("(?s)<link>([^<>]*)</link>")
>> "<code>\\1</code>")
def resolve_external(self, func, sect):
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
+from __future__ import print_function
+
from zzipdoc.match import Match
from zzipdoc.htm2dbk import *
description = entry.body_xml_text(name)
funcsynopsis = entry.head_xml_text()
if not funcsynopsis:
- print "no funcsynopsis for", name
+ print("no funcsynopsis for " + name)
return
if self.entry is None:
self.entry = FunctionListRefEntry(entry, self.o)
want is the docbook-to-pdf converter and similar technology being
present in the world of docbook-to-anything converters. """
+from __future__ import print_function
+
from datetime import date
from zzipdoc.match import Match
import sys
doc.add(f.read())
f.close()
except IOError:
- print >> sys.stderr, "can not open "+filename
+ print("can not open "+filename, file=sys.stderr)
return doc.value()
def html2docbook(text):
opt, args = cmdline.parse_args()
result = htm2dbk_files(args)
if not opt.into:
- print result
+ print(result)
else:
f = open(opt.into, "w")
f.write(result)
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
+from __future__ import print_function
+
from zzipdoc.match import Match
class HtmlDocument:
try: return style.html_style()
except Exception as e: ee = e; pass
try: return style.xml_style()
- except Exception as e: print "HtmlDocument/style", ee, e; pass
+ except Exception as e: print("HtmlDocument/style {} {}".format(ee, e)); pass
try: return str(style)
- except Exception as e: print "HtmlDocument/style", e; return ""
+ except Exception as e: print("HtmlDocument/style {}".format(e)); return ""
def _html_text(self, html):
""" accepts adapter objects with .html_text() and .xml_text() """
ee = None
try: return html.html_text()
except Exception as e: ee = e; pass
try: return html.xml_text()
- except Exception as e: print "HtmlDocument/text", ee, e; pass
+ except Exception as e: print("HtmlDocument/text {} {}".format(ee, e)); pass
try: return str(html)
- except Exception as e: print "HtmlDocument/text", e; return " "
+ except Exception as e: print("HtmlDocument/text {}".format(e)); return " "
def navigation(self):
if self.navi:
return self.navi
return filename
def save(self, filename = None):
filename = self._filename(filename)
- print "writing '"+filename+"'"
+ print("writing '"+filename+"'")
try:
fd = open(filename, "w")
- print >>fd, self.html_header()
+ print(self.html_header(), file=fd)
for text in self.text:
- print >>fd, self._html_text(text)
- print >>fd, self.html_footer()
+ print(self._html_text(text), file=fd)
+ print(self.html_footer(), file=fd)
fd.close()
return True
except IOError as e:
- print "could not open '"+filename+"'file", e
+ print("could not open '"+filename+"'file {}".format(e))
return False
# @creator (C) 2003 Guido U. Draheim
# @license http://creativecommons.org/licenses/by-nc-sa/2.0/de/
+from __future__ import print_function
+
import re
try:
if __name__ == "__main__":
# matching:
if "foo" & Match("oo"):
- print "oo"
+ print("oo")
x = Match()
if "foo" & x("(o+)"):
- print x[1]
+ print(x[1])
# replacing:
y = "fooboo" & Match("oo") >> "ee"
- print y
+ print(y)
r = Match("oo") >> "ee"
- print "fooboo" & r
+ print("fooboo" & r)
s = MatchReplace("oo", "ee")
- print "fooboo" & s
+ print("fooboo" & s)
+from __future__ import print_function
+
from zzipdoc.match import Match
class TextFileHeader:
x = Match()
text = self.textfile.get_src_text()
if not text:
- print "nonexistent file:", self.textfile.get_filename()
+ print("nonexistent file: " + self.textfile.get_filename())
return False
if text & x(r"(?s)[/][*]+(\s(?:.(?!\*\/))*.)\*\/"
r"(?:\s*\#(?:define|ifdef|endif)[ ]*\S*[ ]*\S*)*"