Ticket #61530: Python2-3_patches_too.diff
File Python2-3_patches_too.diff, 26.4 KB (added by ballapete (Peter "Pete" Dyballa), 4 years ago) |
---|
-
lib/contrib/debian/errorhandler.py
88 88 warn_msgs.append('For image conversion Debian package inkscape is' 89 89 + ' needed') 90 90 if warn_msgs: 91 print >> sys.stderr, "\n" + "\n".join(warn_msgs) + "\n"91 print("\n" + "\n".join(warn_msgs) + "\n", file=sys.stderr) 92 92 return True 93 93 else: 94 94 return False … … 119 119 nulldev1.close() 120 120 121 121 if rc == 3 or rc == 4: 122 print >> sys.stderr123 print >> sys.stderr, 'A possible reason for transformation',124 print >> sys.stderr, 'failure is invalid DocBook'125 print >> sys.stderr, '(as reported by xmllint)'126 print >> sys.stderr122 print(file=sys.stderr) 123 print('A possible reason for transformation', end=' ', file=sys.stderr) 124 print('failure is invalid DocBook', file=sys.stderr) 125 print('(as reported by xmllint)', file=sys.stderr) 126 print(file=sys.stderr) 127 127 return True 128 128 else: 129 129 return False … … 157 157 warn_msgs.append('For utf8 encoding Debian package ' 158 158 + debian_pkg + ' is needed') 159 159 if warn_msgs: 160 print >> sys.stderr, "\n" + "\n".join(warn_msgs) + "\n"160 print("\n" + "\n".join(warn_msgs) + "\n", file=sys.stderr) 161 161 return True 162 162 else: 163 163 return False … … 182 182 for log_entry in obj.runtex.texer.tex.log.get_errors(): 183 183 if (log_entry['text'] 184 184 == r'Undefined control sequence \cyrchar.'): 185 print >> sys.stderr186 print >> sys.stderr, 'Transformation failure',187 print >> sys.stderr, 'might be caused by handling a',188 print >> sys.stderr, 'cyrillic document'189 print >> sys.stderr, 'without the XeTeX backend'190 print >> sys.stderr185 print(file=sys.stderr) 186 print('Transformation failure', end=' ', file=sys.stderr) 187 print('might be caused by handling a', end=' ', file=sys.stderr) 188 print('cyrillic document', file=sys.stderr) 189 print('without the XeTeX backend', file=sys.stderr) 190 print(file=sys.stderr) 191 191 return True 192 192 except: 193 193 pass -
lib/dbtexmf/core/txtparser.py
96 96 continue 97 97 key = m.group(1) 98 98 value = m.group(2).strip() 99 if not self.conf_mapping.has_key(key):99 if key not in self.conf_mapping: 100 100 continue 101 101 o = self.conf_mapping[key] 102 102 -
lib/dbtexmf/core/error.py
49 49 50 50 def failure_track(msg): 51 51 global _dump_stack 52 print >>sys.stderr, (msg)52 print((msg), file=sys.stderr) 53 53 if _dump_stack: 54 54 traceback.print_exc() 55 55 -
lib/dbtexmf/dblatex/xetex/fcmanager.py
169 169 170 170 def get_font_handling(self, char, all=False, family_type=""): 171 171 if not(family_type): 172 font_family = self.fonts.values()172 font_family = list(self.fonts.values()) 173 173 else: 174 174 font_family = self.fonts_family.get(family_type, None) 175 175 -
lib/dbtexmf/dblatex/grubber/bibtopic.py
1 1 2 from plugins import TexModule3 from bibtex import BibTex2 from .plugins import TexModule 3 from .bibtex import BibTex 4 4 5 5 6 6 class BibSect(BibTex): -
lib/dbtexmf/dblatex/grubber/index.py
45 45 import xml.dom.minidom 46 46 47 47 from subprocess import Popen, PIPE 48 from msg import _, msg49 from plugins import TexModule50 from util import md5_file48 from .msg import _, msg 49 from .plugins import TexModule 50 from .util import md5_file 51 51 52 52 53 53 class Xindy: … … 514 514 index = self.indices[name] = Index(self.doc, idx, ind, ilg) 515 515 for cmd in self.defaults: 516 516 index.command(*cmd) 517 if self.commands.has_key(name):517 if name in self.commands: 518 518 for cmd in self.commands[name]: 519 519 index.command(*cmd) 520 520 … … 546 546 args = args[1:] 547 547 if names is None: 548 548 self.defaults.append([cmd, args]) 549 names = indices.keys()549 names = list(indices.keys()) 550 550 for index in names: 551 if ind ices.has_key(index):551 if index in indices: 552 552 indices[index].command(cmd, args[1:]) 553 elif self.commands.has_key(index):553 elif index in self.commands: 554 554 self.commands[index].append([cmd, args]) 555 555 else: 556 556 self.commands[index] = [[cmd, args]] 557 557 558 558 def post_compile (self): 559 for index in self.indices.values():559 for index in list(self.indices.values()): 560 560 if index.post_compile(): 561 561 return 1 562 562 return 0 563 563 564 564 def clean (self): 565 for index in self.indices.values():565 for index in list(self.indices.values()): 566 566 index.clean() 567 567 return 0 568 568 -
lib/dbtexmf/dblatex/grubber/ps2pdf.py
7 7 import sys 8 8 import os 9 9 10 from msg import _, msg11 from maker import DependShell12 from plugins import TexModule10 from .msg import _, msg 11 from .maker import DependShell 12 from .plugins import TexModule 13 13 14 14 15 15 class Module (TexModule): -
lib/dbtexmf/dblatex/grubber/dvips.py
13 13 from os.path import * 14 14 import subprocess 15 15 16 from msg import _ , msg17 from plugins import TexModule18 from maker import Depend16 from .msg import _ , msg 17 from .plugins import TexModule 18 from .maker import Depend 19 19 20 20 class Dep (Depend): 21 21 def __init__ (self, doc, target, source, node): -
lib/dbtexmf/dblatex/grubber/makeidx.py
24 24 """ 25 25 import sys 26 26 27 from index import Index27 from .index import Index 28 28 29 29 class Module (Index): 30 30 def __init__ (self, doc, dict): -
lib/dbtexmf/dblatex/grubber/xr-hyper.py
9 9 """ 10 10 import os 11 11 12 from msg import _, msg13 from plugins import TexModule14 from latex import Latex12 from .msg import _, msg 13 from .plugins import TexModule 14 from .latex import Latex 15 15 16 16 class Module(TexModule): 17 17 def __init__ (self, doc, dict): … … 23 23 # remember the engine used to build the main latex document 24 24 self.texmodules = [] 25 25 for m in ("pdftex", "xetex"): 26 if doc.modules.has_key(m):26 if m in doc.modules: 27 27 self.texmodules.append(m) 28 28 29 29 # want to track each external document whose .aux is required -
lib/dbtexmf/dblatex/grubber/bibtex.py
12 12 """ 13 13 14 14 # Stop python 2.2 from calling "yield" statements syntax errors. 15 from __future__ import generators 15 16 16 17 17 import os, sys 18 18 from os.path import * … … 21 21 22 22 #from grubber import _ 23 23 #from grubber import * 24 from msg import _, msg25 from plugins import TexModule24 from .msg import _, msg 25 from .plugins import TexModule 26 26 27 27 re_bibdata = re.compile(r"\\bibdata{(?P<data>.*)}") 28 28 re_citation = re.compile(r"\\citation{(?P<cite>.*)}") … … 111 111 """ 112 112 if self.style: 113 113 old_bst = self.style + ".bst" 114 if exists(old_bst) and self.doc.sources.has_key(old_bst):114 if exists(old_bst) and old_bst in self.doc.sources: 115 115 del self.doc.sources[old_bst] 116 116 117 117 self.style = style … … 168 168 return 1 169 169 170 170 dtime = getmtime(self.blgfile) 171 for db in self.db.values():171 for db in list(self.db.values()): 172 172 if getmtime(db) > dtime: 173 173 msg.log(_("bibliography database %s was modified") % db, 174 174 pkg="bibtex") … … 207 207 m = re_citation.match(line) 208 208 if m: 209 209 cite = m.group("cite") 210 if not cites.has_key(cite):210 if cite not in cites: 211 211 last = last + 1 212 212 cites[cite] = last 213 213 continue … … 218 218 dbs.sort() 219 219 220 220 if self.sorted: 221 list = cites.keys()221 list = list(cites.keys()) 222 222 list.sort() 223 223 return list, dbs 224 224 else: 225 list = [(n,c) for (c,n) in cites.items()]225 list = [(n,c) for (c,n) in list(cites.items())] 226 226 list.sort() 227 227 return [c for (n,c) in list], dbs 228 228 … … 235 235 match = re_undef.match(line) 236 236 if match: 237 237 cites[match.group("cite")] = None 238 list = cites.keys()238 list = list(cites.keys()) 239 239 list.sort() 240 240 return list 241 241 … … 400 400 file = d["file"] 401 401 if file[-4:] == ".bib": 402 402 file = file[:-4] 403 if self.db.has_key(file):403 if file in self.db: 404 404 d["file"] = self.db[file] 405 elif self.db.has_key(file + ".bib"):405 elif file + ".bib" in self.db: 406 406 d["file"] = self.db[file + ".bib"] 407 407 yield d 408 408 last_line = line -
lib/dbtexmf/dblatex/grubber/xetex.py
2 2 XeTeX support for Rubber. 3 3 """ 4 4 5 from plugins import TexModule5 from .plugins import TexModule 6 6 7 7 class Module (TexModule): 8 8 def __init__ (self, doc, dict): -
lib/dbtexmf/dblatex/grubber/pdftex.py
14 14 import subprocess 15 15 from subprocess import Popen, PIPE 16 16 17 from msg import _, msg18 from plugins import TexModule17 from .msg import _, msg 18 from .plugins import TexModule 19 19 20 20 21 21 class Module (TexModule): -
lib/dbtexmf/xslt/xsltproc.py
26 26 if self.use_catalogs and self.catalogs: 27 27 cmd.append("--catalogs") 28 28 if params: 29 for param, value in params.items():29 for param, value in list(params.items()): 30 30 cmd += ["--param", param, "'%s'" % value] 31 31 if opts: 32 32 cmd += opts -
lib/dbtexmf/xslt/xsltconf.py
52 52 return args 53 53 54 54 param_args = [] 55 for param, value in params.items():55 for param, value in list(params.items()): 56 56 param_args.append(self.param_format % {"param_name": param, 57 57 "param_value": value}) 58 58 -
lib/dbtexmf/xslt/saxon.py
22 22 cmd += opts 23 23 cmd += [xmlfile, xslfile] 24 24 if params: 25 for param, value in params.items():25 for param, value in list(params.items()): 26 26 cmd += ["%s=%s" % (param, "'%s'" % value)] 27 27 self.system(cmd) 28 28 -
tools/dblatex_config.py
104 104 (options, args) = parser.parse_args() 105 105 106 106 if len(args) != 2: 107 print >> sys.stderr, "Invalid argument count: expected 2"107 print("Invalid argument count: expected 2", file=sys.stderr) 108 108 parser.parse_args(["-h"]) 109 109 110 110 txt_file = args[0] -
tools/paramcheck.py
104 104 sr = set(reffiles) 105 105 106 106 torem_from_syn = ss - sp 107 print "==========="108 print "In param list, missing in %s:\n" % (synopdir), sp - ss109 print "\nIn param list, missing in refentries:\n", sp - sr110 print "\nIn synopsis, not in param list:\n", torem_from_syn111 print "\nIn synopsis, missing in refentries:\n", ss - sr - torem_from_syn112 print "\nIn refentries, missing in %s:\n" % (synopdir), sr - ss107 print("===========") 108 print("In param list, missing in %s:\n" % (synopdir), sp - ss) 109 print("\nIn param list, missing in refentries:\n", sp - sr) 110 print("\nIn synopsis, not in param list:\n", torem_from_syn) 111 print("\nIn synopsis, missing in refentries:\n", ss - sr - torem_from_syn) 112 print("\nIn refentries, missing in %s:\n" % (synopdir), sr - ss) 113 113 114 114 115 115 if __name__ == "__main__": -
tools/utfdump.py
17 17 o = encode(uchar)[0] 18 18 except: 19 19 o = "?" 20 print "U%04X: %s" % (ord(uchar), o)20 print("U%04X: %s" % (ord(uchar), o)) 21 21 outline += o 22 print "Line %3d: %s" % (lineno, outline)22 print("Line %3d: %s" % (lineno, outline)) 23 23 24 24 25 25 if __name__ == "__main__": -
tools/pdfscan.py
40 40 41 41 def failure_track(self, msg, rc=1): 42 42 self.rc = rc 43 print >>sys.stderr, (msg)43 print((msg), file=sys.stderr) 44 44 if self._dump_stack: 45 45 traceback.print_exc() 46 46 … … 329 329 self.unresolved = [] 330 330 331 331 def count(self): 332 return len( self.pdfobjects.values())332 return len(list(self.pdfobjects.values())) 333 333 334 334 def types(self): 335 return self.objtypes.keys()335 return list(self.objtypes.keys()) 336 336 337 337 def add_object(self, pdfobject): 338 338 self.pdfobjects[pdfobject.ident()] = pdfobject … … 359 359 self.unresolved = unresolved 360 360 361 361 def stream_decode(self): 362 for pdfobj in self.pdfobjects.values():362 for pdfobj in list(self.pdfobjects.values()): 363 363 pdfobj.stream_decode() 364 364 365 365 … … 873 873 return self.params.get(param, default) 874 874 875 875 def values(self): 876 return self.params.values()876 return list(self.params.values()) 877 877 878 878 def keys(self): 879 return self.params.keys()879 return list(self.params.keys()) 880 880 881 881 def infos(self): 882 882 return self.params … … 889 889 890 890 def link_to(self, pdfobjects): 891 891 unresolved = 0 892 for param, value in self.params.items():892 for param, value in list(self.params.items()): 893 893 # Point to something else than a string? Skip it 894 894 if not(isinstance(value, str)): 895 895 continue … … 960 960 shutil.rmtree(self.cache_dirname) 961 961 else: 962 962 for fname in self.cache_files: 963 print "shutil.remove(", fname963 print("shutil.remove(", fname) 964 964 965 965 def cache(self, **kwargs): 966 966 if self.cache_method == "file": … … 1253 1253 1254 1254 def dump(self): 1255 1255 s = self._level * " " + "q '" + self._data + "'" 1256 print s1256 print(s) 1257 1257 for q in self._children: 1258 1258 q.dump() 1259 1259 s = self._level * " " + "Q" 1260 print s1260 print(s) 1261 1261 1262 1262 1263 1263 class PDFTextObject: … … 1445 1445 return textdata 1446 1446 if (self.font.tounicode): 1447 1447 textdata = self._re_textunicode.findall(self.data) 1448 s = u" ".join(self.font.tounicode.decode(textdata))1448 s = " ".join(self.font.tounicode.decode(textdata)) 1449 1449 return self.encode(s, "substitute")[0] 1450 1450 else: 1451 1451 return "" … … 1456 1456 @classmethod 1457 1457 def _encode_subs(cls, exc): 1458 1458 if not isinstance(exc, UnicodeEncodeError): 1459 return u""1459 return "" 1460 1460 l = [] 1461 1461 for c in exc.object[exc.start:exc.end]: 1462 l.append( u"&#x%x;" % ord(c))1463 return ( u"".join(l), exc.end)1462 l.append("&#x%x;" % ord(c)) 1463 return ("".join(l), exc.end) 1464 1464 1465 1465 1466 1466 class PDFFont: … … 1494 1494 1495 1495 def get_pdffont(self, fontobj, fontsize): 1496 1496 key = fontobj.descriptor.get("/BaseFont")+"/"+"%6.2f" % fontsize 1497 if self.fontused.has_key(key):1497 if key in self.fontused: 1498 1498 return self.fontused.get(key) 1499 1499 elif self.global_fontmgr: 1500 1500 pdffont = self.global_fontmgr.get_pdffont(fontobj, fontsize) … … 1517 1517 1518 1518 def _get_tounicode(self, pdfobject): 1519 1519 key = pdfobject.ident() 1520 if self.tounicode.has_key(key):1520 if key in self.tounicode: 1521 1521 tuc = self.tounicode.get(key) 1522 1522 else: 1523 1523 tuc = ToUnicode(pdfobject) … … 1531 1531 return self.get_pdffont(fontobj, size) 1532 1532 1533 1533 def get_used(self): 1534 return self.fontused.values()1534 return list(self.fontused.values()) 1535 1535 1536 1536 1537 1537 class ToUnicode(PDFStreamHandler): … … 1609 1609 for i in range(0, len(data), 4): 1610 1610 s = data[i:i+4] 1611 1611 #print s 1612 ul.append( unichr(self.get_uccode(int(s,16))))1613 return u"".join(ul)1612 ul.append(chr(self.get_uccode(int(s,16)))) 1613 return "".join(ul) 1614 1614 1615 1615 def decode(self, data): 1616 1616 if isinstance(data, list): … … 1696 1696 for page in pdf_pages: 1697 1697 fonts_used = page.find_fonts() 1698 1698 fonts_used.sort() 1699 print "\nPage %d fonts used:" % page.pagenum1699 print("\nPage %d fonts used:" % page.pagenum) 1700 1700 for i, font in enumerate(fonts_used): 1701 print 1702 self.pt_factor*font.size()) 1703 1704 print "\nPage %d layout:" % page.pagenum1701 print("[%d] %-40s %6.2f pt" % (i, font.name(), 1702 self.pt_factor*font.size())) 1703 1704 print("\nPage %d layout:" % page.pagenum) 1705 1705 content_stream = page.streams[0] 1706 1706 xp, yp = 0., 0. 1707 print self.header1708 print self.headline1707 print(self.header) 1708 print(self.headline) 1709 1709 for textobject in content_stream.textobjects: 1710 1710 xp, yp = self._print_textobject_layout(textobject, xp, yp, 1711 1711 fonts_used) … … 1728 1728 font_line.append(idx) 1729 1729 1730 1730 m2 = line[0].matrix * m2 1731 if self.show_matrix: print "%s" % m21731 if self.show_matrix: print("%s" % m2) 1732 1732 1733 1733 x, y = m2.tx(), m2.ty() 1734 1734 x, y = float(x/72), float(y/72) … … 1742 1742 textw = textwrap.wrap(text, wraplen) 1743 1743 1744 1744 if textw: 1745 print "%s%s" % (info, textw[0])1745 print("%s%s" % (info, textw[0])) 1746 1746 for txt in textw[1:]: 1747 print "%s%s" % (self.padding, txt)1747 print("%s%s" % (self.padding, txt)) 1748 1748 1749 1749 xp, yp = x, y 1750 1750 for l in line[1:]: … … 1765 1765 page_num = i+page_first 1766 1766 contents = page.descriptor.get("/Contents") 1767 1767 resources = page.descriptor.get("/Resources") 1768 print 1769 (page_num, page, contents, resources) 1770 print 1768 print("Page %d %s: contents: %s, resources: %s" % \ 1769 (page_num, page, contents, resources)) 1770 print() 1771 1771 1772 1772 class PdfObjectCmd(BasicCmd): 1773 1773 """ … … 1804 1804 def _sanitize_objref(self, ident): 1805 1805 flds = ident.split() 1806 1806 if len(flds) != 2: 1807 print 1808 "'number generation'" 1807 print("Invalid object reference: must be in the form "\ 1808 "'number generation'") 1809 1809 return "" 1810 1810 else: 1811 1811 return "%s %s" % (flds[0], flds[1]) … … 1813 1813 def show_dictionnary(self, ident): 1814 1814 pdfobject = self.scanner.pdf.get_object(ident) 1815 1815 if not(pdfobject): 1816 print "PDF Object '%s' not found" % ident1816 print("PDF Object '%s' not found" % ident) 1817 1817 return 1818 1818 if pdfobject.stream: 1819 print "PDF Object '%s' has a stream. Its dictionnary:" % ident1819 print("PDF Object '%s' has a stream. Its dictionnary:" % ident) 1820 1820 else: 1821 print "PDF Object '%s' dictionnary:" % ident1821 print("PDF Object '%s' dictionnary:" % ident) 1822 1822 self._print_dictionnary(pdfobject.descriptor) 1823 1823 1824 1824 def _print_dictionnary(self, descriptor, level=1): 1825 1825 indent = " "*level 1826 print "%s<<" % indent1827 for p, v in descriptor.infos().items():1826 print("%s<<" % indent) 1827 for p, v in list(descriptor.infos().items()): 1828 1828 if isinstance(v, PDFDescriptor): 1829 print "%s%s:" % (indent, p)1829 print("%s%s:" % (indent, p)) 1830 1830 self._print_dictionnary(v, level=level+1) 1831 1831 else: 1832 print "%s%s: %s" % (indent, p, v)1833 print "%s>>" % indent1832 print("%s%s: %s" % (indent, p, v)) 1833 print("%s>>" % indent) 1834 1834 1835 1835 def list_pdfobjects(self): 1836 1836 pdfobjects = self.scanner.pdf.pdfobjects 1837 print "Found %s PDFObjects" % pdfobjects.count()1838 print "Found the following PDFObject types:"1837 print("Found %s PDFObjects" % pdfobjects.count()) 1838 print("Found the following PDFObject types:") 1839 1839 types = pdfobjects.types() 1840 1840 types.sort() 1841 1841 total = 0 1842 1842 for typ in types: 1843 1843 n_type = len(pdfobjects.get_objects_by_type(typ)) 1844 print " %20s: %5d objects" % (typ, n_type)1844 print(" %20s: %5d objects" % (typ, n_type)) 1845 1845 total = total + n_type 1846 print " %20s: %5d objects" % ("TOTAL", total)1846 print(" %20s: %5d objects" % ("TOTAL", total)) 1847 1847 1848 1848 def dump_stream(self, ident, outfile): 1849 1849 pdfobject = self.scanner.pdf.get_object(ident) 1850 1850 if not(pdfobject): 1851 print "PDF Object '%s' not found" % ident1851 print("PDF Object '%s' not found" % ident) 1852 1852 return 1853 1853 if not(pdfobject.stream): 1854 print "PDF Object '%s' has no stream. Give up." % ident1854 print("PDF Object '%s' has no stream. Give up." % ident) 1855 1855 return 1856 1856 pdfobject.stream_decode() 1857 1857 f = open(outfile, "wb") 1858 1858 f.write(pdfobject.stream_text()) 1859 1859 f.close() 1860 print "PDF Object '%s' stream written to file %s" % (ident, outfile)1860 print("PDF Object '%s' stream written to file %s" % (ident, outfile)) 1861 1861 1862 1862 1863 1863 … … 1895 1895 1896 1896 def print_fonts_in_pages(self, pdf_pages, show=True): 1897 1897 if show: 1898 print self.header_fmt % ("PAGE", "FONT", "SIZE")1899 print self.header_fmt % (4*"-", 40*"-", 10*"-")1898 print(self.header_fmt % ("PAGE", "FONT", "SIZE")) 1899 print(self.header_fmt % (4*"-", 40*"-", 10*"-")) 1900 1900 1901 1901 for page in pdf_pages: 1902 1902 fonts_used = page.find_fonts() 1903 1903 fonts_used.sort() 1904 1904 for font in fonts_used: 1905 1905 if show: 1906 print 1907 self.pt_factor * font.size(), self.font_unit) 1908 if show: print self.header_fmt % (4*"-", 40*"-", 10*"-")1906 print("%4d %-40s %6.2f %s" % (page.pagenum, font.name(), 1907 self.pt_factor * font.size(), self.font_unit)) 1908 if show: print(self.header_fmt % (4*"-", 40*"-", 10*"-")) 1909 1909 1910 1910 def print_font_summary(self): 1911 1911 pages = [] … … 1917 1917 s += "-%d" % (pg[-1].pagenum) 1918 1918 pages.append(s) 1919 1919 1920 print "\nFonts used in pages %s:" % (",".join(pages))1920 print("\nFonts used in pages %s:" % (",".join(pages))) 1921 1921 fonts_used = self.scanner.pdf.fontmgr.get_used() 1922 1922 fonts_used.sort() 1923 1923 for font in fonts_used: 1924 print 1925 (font.name(), self.pt_factor*font.size(), self.font_unit) 1924 print("%-40s %6.2f %s" % \ 1925 (font.name(), self.pt_factor*font.size(), self.font_unit)) 1926 1926 1927 1927 1928 1928 class PDFScannerCommand: … … 2067 2067 if not(verbose): 2068 2068 return log_groups 2069 2069 2070 groups = l og_groups.keys()2070 groups = list(log_groups.keys()) 2071 2071 for verbose_opt in verbose: 2072 2072 group, level = ("all:" + verbose_opt).split(":")[-2:] 2073 2073 if not(level in log_levels): 2074 print "Invalid verbose level: '%s'" % level2074 print("Invalid verbose level: '%s'" % level) 2075 2075 continue 2076 2076 if group == "all": 2077 2077 for group in groups: … … 2079 2079 elif group in groups: 2080 2080 log_groups[group] = level 2081 2081 else: 2082 print "Invalid verbose group: '%s'" % group2082 print("Invalid verbose group: '%s'" % group) 2083 2083 continue 2084 2084 return log_groups 2085 2085 … … 2108 2108 elif cache_dirname: 2109 2109 cache_dirname = os.path.realpath(cache_dirname) 2110 2110 if not(os.path.exists(cache_dirname)): 2111 print 2112 cache_dirname 2111 print("Invalid cache dir: '%s'. Temporary dir used instead" % \ 2112 cache_dirname) 2113 2113 return None 2114 2114 mgr = StreamManager(cache_method="file", 2115 2115 cache_dirname=cache_dirname, … … 2129 2129 fmt = logging.Formatter("%(message)s") 2130 2130 console.setFormatter(fmt) 2131 2131 2132 for group, level in l og_groups.items():2132 for group, level in list(log_groups.items()): 2133 2133 log = logging.getLogger("pdfscan.%s" % group) 2134 2134 log.setLevel(loglevels.get(level, logging.INFO)-1) 2135 2135 log.addHandler(console) … … 2154 2154 argslist.append(args) 2155 2155 2156 2156 if not(remain_args) or remain_args[0] in scanner.commands(): 2157 print "Missing the PDF File"2157 print("Missing the PDF File") 2158 2158 parser.parse_args(["-h"]) 2159 2159 2160 2160 error = ErrorHandler() … … 2163 2163 try: 2164 2164 pdffile = remain_args[0] 2165 2165 scanner.run(parser, options, argslist, pdffile) 2166 except Exception ,e:2166 except Exception as e: 2167 2167 error.failure_track("Error: '%s'" % (e)) 2168 2168 2169 2169 scanner.cleanup()