Ticket #61526: Python2-3_patches.diff
File Python2-3_patches.diff, 16.8 KB (added by ballapete (Peter "Pete" Dyballa), 4 years ago) |
---|
-
docs/makedocs.py
37 37 return None 38 38 def print_list_mainheader(self): 39 39 for t_fileheader in self.headers: 40 print t_fileheader.get_filename(), t_fileheader.src_mainheader()40 print(t_fileheader.get_filename(), t_fileheader.src_mainheader()) 41 41 42 42 class PerFunctionEntry: 43 43 def __init__(self, header, comment, prototype): … … 66 66 functionprototype) ] 67 67 def print_list_titleline(self): 68 68 for funcheader in self.headers: 69 print funcheader.get_filename(), "[=>]", funcheader.get_titleline()69 print(funcheader.get_filename(), "[=>]", funcheader.get_titleline()) 70 70 def print_list_name(self): 71 71 for funcheader in self.prototypes: 72 print funcheader.get_filename(), "[>>]", funcheader.get_name()72 print(funcheader.get_filename(), "[>>]", funcheader.get_name()) 73 73 74 74 class PerFunctionFamilyEntry: 75 75 def __init__(self, leader): … … 122 122 for name in self.retarget: 123 123 into = self.retarget[name] 124 124 if into not in name_list: 125 print 126 "' does not exist - keep alone") 125 print(("function '"+name+"' retarget into '"+into+ 126 "' does not exist - keep alone")) 127 127 if into in self.retarget: 128 128 other = self.retarget[into] 129 print 130 "' which is itself a retarget into '"+other+"'") 129 print(("function '"+name+"' retarget into '"+into+ 130 "' which is itself a retarget into '"+other+"'")) 131 131 if into not in lead_list: 132 132 lead_list += [ into ] 133 133 for func in self.functions: … … 141 141 entry.add(func) # the first 142 142 self.entries += [ entry ] 143 143 else: 144 print "head function '"+name+" has no entry"144 print("head function '"+name+" has no entry") 145 145 for func in self.functions: 146 146 name = func.get_name() 147 147 if name in self.retarget: … … 150 150 if entry is not None: 151 151 entry.add(func) # will not add duplicates 152 152 else: 153 print "into function '"+name+" has no entry"153 print("into function '"+name+" has no entry") 154 154 def print_list_name(self): 155 155 for family in self.entries: 156 156 name = family.get_name() 157 print name, ":",157 print(name, ":", end=' ') 158 158 for item in family.functions: 159 print item.get_name(), ",",160 print ""159 print(item.get_name(), ",", end=' ') 160 print("") 161 161 class HtmlManualPageAdapter: 162 162 def __init__(self, entry): 163 163 """ usually takes a PerFunctionEntry """ -
docs/zzipdoc/match.py
18 18 MatchReplace.__call__(self, matching, template, count, flags) 19 19 def __call__(self, matching, template = None, count = 0, flags = None): 20 20 """ other than __init__ the template may be left off to be unchanged""" 21 if isinstance(count, basestring): # count/flags swapped over?21 if isinstance(count, str): # count/flags swapped over? 22 22 flags = count; count = 0 23 23 if isinstance(matching, Match): 24 24 self.matching = matching … … 57 57 def __call__(self, pattern, flags = None): 58 58 assert isinstance(pattern, str) or pattern is None 59 59 assert isinstance(flags, str) or flags is None 60 str.__init__( self,pattern)60 str.__init__(pattern) 61 61 self.replaced = 0 # set by subn() inside MatchReplace 62 62 self.found = None # set by search() to a MatchObject 63 63 self.pattern = pattern … … 90 90 if __name__ == "__main__": 91 91 # matching: 92 92 if "foo" & Match("oo"): 93 print "oo"93 print("oo") 94 94 x = Match() 95 95 if "foo" & x("(o+)"): 96 print x[1]96 print(x[1]) 97 97 # replacing: 98 98 y = "fooboo" & Match("oo") >> "ee" 99 print y99 print(y) 100 100 r = Match("oo") >> "ee" 101 print "fooboo" & r101 print("fooboo" & r) 102 102 s = MatchReplace("oo", "ee") 103 print "fooboo" & s103 print("fooboo" & s) -
docs/zzipdoc/options.py
3 3 # @creator (C) 2003 Guido U. Draheim 4 4 # @license http://creativecommons.org/licenses/by-nc-sa/2.0/de/ 5 5 6 from match import Match6 from .match import Match 7 7 8 8 # use as o.optionname to check for commandline options. 9 9 class Options: 10 10 var = {} 11 11 def __getattr__(self, name): 12 if n ot self.var.has_key(name): return None12 if name not in self.var: return None 13 13 return self.var[name] 14 14 def __setattr__(self, name, value): 15 15 self.var[name] = value -
docs/zzipdoc/textfile.py
17 17 self.src_text = fd.read() 18 18 fd.close() 19 19 return True 20 except IOError ,e:20 except IOError as e: 21 21 pass 22 22 return False 23 23 def assert_src_text(self): … … 41 41 self._line(self.src_text, offset) 42 42 def _line(self, text, offset): 43 43 line = 1 44 for x in xrange(0,offset):44 for x in range(0,offset): 45 45 if x == "\n": 46 46 line += 1 47 47 return line -
docs/zzipdoc/textfileheader.py
1 from match import Match1 from .match import Match 2 2 3 3 class TextFileHeader: 4 4 """ scan for a comment block at the source file start and fill the … … 17 17 x = Match() 18 18 text = self.textfile.get_src_text() 19 19 if not text: 20 print "nonexistent file:", self.textfile.get_filename()20 print("nonexistent file:", self.textfile.get_filename()) 21 21 return False 22 22 if text & x(r"(?s)[/][*]+(\s(?:.(?!\*\/))*.)\*\/" 23 23 r"(?:\s*\#(?:define|ifdef|endif)[ ]*\S*[ ]*\S*)*" -
docs/zzipdoc/functionheader.py
1 from match import Match1 from .match import Match 2 2 3 3 class FunctionHeader: 4 4 """ parsing the comment block that is usually presented before -
docs/zzipdoc/functionprototype.py
1 from match import Match1 from .match import Match 2 2 3 3 class FunctionPrototype: 4 4 """ takes a single function prototype line (cut from some source file) -
docs/zzipdoc/commentmarkup.py
1 from match import Match1 from .match import Match 2 2 3 3 def markup_link_syntax(text): 4 4 """ markup the link-syntax ` => somewhere ` in the text block """ … … 31 31 comment = self.header.comment 32 32 try: 33 33 comment = self.header.get_otherlines() 34 except Exception ,e:34 except Exception as e: 35 35 pass 36 36 mode = "" 37 37 text = "" -
docs/zzipdoc/functionlisthtmlpage.py
1 from options import *2 from match import Match1 from .options import * 2 from .match import Match 3 3 4 4 class FunctionListHtmlPage: 5 5 """ The main part here is to create a TOC (table of contents) at the … … 35 35 head_text = entry.head_xml_text() 36 36 body_text = entry.body_xml_text(name) 37 37 if not head_text: 38 print "no head_text for", name38 print("no head_text for", name) 39 39 return 40 40 try: 41 41 prespec = entry.head_get_prespec() … … 43 43 callspec = entry.head_get_callspec() 44 44 head_text = ("<code><b><function>"+namespec+"</function></b>" 45 45 +callspec+" : "+prespec+"</code>") 46 except Exception ,e:46 except Exception as e: 47 47 pass 48 48 try: 49 49 extraline = "" … … 56 56 '<em><small>'+filename+'</small></em>'+ 57 57 '</td></table>') 58 58 body_text = extraline + body_text 59 except Exception ,e:59 except Exception as e: 60 60 pass 61 61 def link(text): 62 62 return (text & Match("<function>(\w*)</function>") … … 102 102 text &= (Match("(?s)<link>(\w+)</link>") 103 103 >> (lambda x: self.resolve_internal(x.group(1)))) 104 104 if len(self.not_found_in_anchors): 105 print "not found in anchors: ", self.not_found_in_anchors105 print("not found in anchors: ", self.not_found_in_anchors) 106 106 return (text & Match("(?s)<link>([^<>]*)</link>") 107 107 >> "<code>\\1</code>") 108 108 def resolve_external(self, func, sect): -
docs/zzipdoc/functionlistreference.py
1 1 #! /usr/bin/env python 2 2 # -*- coding: UTF-8 -*- 3 from match import Match4 from htm2dbk import *3 from .match import Match 4 from .htm2dbk import * 5 5 6 6 class FunctionListReference: 7 7 """ Creating a docbook-style <reference> list of <refentry> parts … … 19 19 description = entry.body_xml_text(name) 20 20 funcsynopsis = entry.head_xml_text() 21 21 if not funcsynopsis: 22 print "no funcsynopsis for", name22 print("no funcsynopsis for", name) 23 23 return 24 24 if self.entry is None: 25 25 self.entry = FunctionListRefEntry(entry, self.o) -
docs/zzipdoc/dbk2htm.py
1 from match import Match1 from .match import Match 2 2 import string 3 3 4 4 class dbk2htm_conversion: -
docs/zzipdoc/htmldocument.py
1 1 #! /usr/bin/env python 2 2 # -*- coding: UTF-8 -*- 3 from match import Match3 from .match import Match 4 4 5 5 class HtmlDocument: 6 6 """ binds some html content page with additional markup - in this … … 29 29 def get_title(self): 30 30 if self.title: return self.title 31 31 try: return self.text[0].get_title() 32 except Exception ,e: pass32 except Exception as e: pass 33 33 return self.title 34 34 def _html_meta(self, meta): 35 35 """ accepts adapter objects with .html_meta() """ 36 36 try: return meta.html_meta() 37 except Exception ,e: pass37 except Exception as e: pass 38 38 return str(meta) 39 39 def _html_style(self, style): 40 40 """ accepts adapter objects with .html_style() and .xml_style() """ 41 41 ee = None 42 42 try: return style.html_style() 43 except Exception ,e: ee = e; pass43 except Exception as e: ee = e; pass 44 44 try: return style.xml_style() 45 except Exception , e: print "HtmlDocument/style", ee, e; pass45 except Exception as e: print("HtmlDocument/style", ee, e); pass 46 46 try: return str(style) 47 except Exception , e: print "HtmlDocument/style", e; return ""47 except Exception as e: print("HtmlDocument/style", e); return "" 48 48 def _html_text(self, html): 49 49 """ accepts adapter objects with .html_text() and .xml_text() """ 50 50 ee = None 51 51 try: return html.html_text() 52 except Exception ,e: ee = e; pass52 except Exception as e: ee = e; pass 53 53 try: return html.xml_text() 54 except Exception , e: print "HtmlDocument/text", ee, e; pass54 except Exception as e: print("HtmlDocument/text", ee, e); pass 55 55 try: return str(html) 56 except Exception , e: print "HtmlDocument/text", e; return " "56 except Exception as e: print("HtmlDocument/text", e); return " " 57 57 def navigation(self): 58 58 if self.navi: 59 59 return self.navi … … 63 63 self.navi = fd.read() 64 64 fd.close() 65 65 return self.navi 66 except Exception ,e:66 except Exception as e: 67 67 pass 68 68 return None 69 69 def html_header(self): … … 103 103 return filename 104 104 def save(self, filename = None): 105 105 filename = self._filename(filename) 106 print "writing '"+filename+"'"106 print("writing '"+filename+"'") 107 107 try: 108 108 fd = open(filename, "w") 109 print >>fd, self.html_header()109 print(self.html_header(), file=fd) 110 110 for text in self.text: 111 print >>fd, self._html_text(text)112 print >>fd, self.html_footer()111 print(self._html_text(text), file=fd) 112 print(self.html_footer(), file=fd) 113 113 fd.close() 114 114 return True 115 except IOError ,e:116 print "could not open '"+filename+"'file", e115 except IOError as e: 116 print("could not open '"+filename+"'file", e) 117 117 return False -
docs/zzipdoc/docbookdocument.py
1 1 #! /usr/bin/env python 2 2 # -*- coding: UTF-8 -*- 3 from match import Match3 from .match import Match 4 4 5 5 class DocbookDocument: 6 6 """ binds some xml content page with additional markup - in this … … 23 23 def get_title(self): 24 24 if self.title: return title 25 25 try: return self.text[0].get_title() 26 except Exception ,e: pass26 except Exception as e: pass 27 27 return self.title 28 28 def _xml_doctype(self, rootnode): 29 29 return "<!DOCTYPE "+rootnode+self.docbook_dtd+">" 30 30 def _xml_text(self, xml): 31 31 """ accepts adapter objects with .xml_text() """ 32 32 try: return xml.xml_text() 33 except Exception , e: print "DocbookDocument/text", e; pass33 except Exception as e: print("DocbookDocument/text", e); pass 34 34 return str(xml) 35 35 def _fetch_rootnode(self, text): 36 36 fetch = Match(r"^[^<>]*<(\w+)\b") … … 47 47 return filename 48 48 def save(self, filename = None): 49 49 filename = self._filename(filename) 50 print "writing '"+filename+"'"50 print("writing '"+filename+"'") 51 51 if len(self.text) > 1: 52 52 self.save_all(filename) 53 53 else: … … 58 58 xml_text = self._xml_text(text) 59 59 rootnode = self._fetch_rootnode(xml_text) 60 60 doctype = self._xml_doctype(rootnode) 61 print >>fd, doctype62 print >>fd, xml_text61 print(doctype, file=fd) 62 print(xml_text, file=fd) 63 63 fd.close() 64 64 return True 65 except IOError ,e:66 print "could not open '"+filename+"'file", e65 except IOError as e: 66 print("could not open '"+filename+"'file", e) 67 67 return False 68 68 def save_all(self, filename): 69 69 assert len(self.text) > 1 … … 76 76 else: 77 77 rootnode = self.rootnode 78 78 doctype = self._xml_doctype(rootnode) 79 print >>fd, doctype79 print(doctype, file=fd) 80 80 title = self.get_title() 81 81 if title and self.rootnode in self.has_title_child: 82 print >>fd, "<"+self.rootnode+'><title>'+title+'</title>'82 print("<"+self.rootnode+'><title>'+title+'</title>', file=fd) 83 83 elif title: 84 print >>fd, "<"+self.rootnode+' id="'+title+'">'84 print("<"+self.rootnode+' id="'+title+'">', file=fd) 85 85 else: 86 print >>fd, "<"+self.rootnode+'>'86 print("<"+self.rootnode+'>', file=fd) 87 87 for text in self.text: 88 88 text = self._xml_text(text) 89 print >>fd, text90 print >>fd, "</"+self.rootnode+">"89 print(text, file=fd) 90 print("</"+self.rootnode+">", file=fd) 91 91 fd.close() 92 92 return True 93 except IOError ,e:94 print "could not open '"+filename+"'file", e93 except IOError as e: 94 print("could not open '"+filename+"'file", e) 95 95 return False -
docs/zzipdoc/htm2dbk.py
7 7 present in the world of docbook-to-anything converters. """ 8 8 9 9 from datetime import date 10 import match10 from . import match 11 11 import sys 12 12 13 13 m = match.Match … … 146 146 doc.filename = filename 147 147 doc.add(f.read()) 148 148 f.close() 149 except IOError ,e:150 print >> sys.stderr, "can not open "+filename149 except IOError as e: 150 print("can not open "+filename, file=sys.stderr) 151 151 return doc.value() 152 152 153 153 def html2docbook(text): … … 155 155 return htm2dbk_conversion().convert2(text) 156 156 157 157 if __name__ == "__main__": 158 print htm2dbk_files(sys.argv[1:])158 print(htm2dbk_files(sys.argv[1:]))