Ticket #61530: Python2-3_patches_too.diff

File Python2-3_patches_too.diff, 26.4 KB (added by ballapete (Peter "Pete" Dyballa), 3 years ago)

Patches Python files to be installed from version 2 to version 3

  • lib/contrib/debian/errorhandler.py

     
    8888            warn_msgs.append('For image conversion Debian package inkscape is'
    8989                             + ' needed')
    9090        if warn_msgs:
    91             print >> sys.stderr, "\n" + "\n".join(warn_msgs) + "\n"
     91            print("\n" + "\n".join(warn_msgs) + "\n", file=sys.stderr)
    9292            return True
    9393        else:
    9494            return False
     
    119119        nulldev1.close()
    120120
    121121        if rc == 3 or rc == 4:
    122             print >> sys.stderr
    123             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.stderr
     122            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)
    127127            return True
    128128        else:
    129129            return False
     
    157157                warn_msgs.append('For utf8 encoding Debian package '
    158158                                 + debian_pkg + ' is needed')
    159159        if warn_msgs:
    160             print >> sys.stderr, "\n" + "\n".join(warn_msgs) + "\n"
     160            print("\n" + "\n".join(warn_msgs) + "\n", file=sys.stderr)
    161161            return True
    162162        else:
    163163            return False
     
    182182            for log_entry in obj.runtex.texer.tex.log.get_errors():
    183183                if (log_entry['text']
    184184                    == r'Undefined control sequence \cyrchar.'):
    185                     print >> sys.stderr
    186                     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.stderr
     185                    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)
    191191                    return True
    192192        except:
    193193            pass
  • lib/dbtexmf/core/txtparser.py

     
    9696                continue
    9797            key = m.group(1)
    9898            value = m.group(2).strip()
    99             if not self.conf_mapping.has_key(key):
     99            if key not in self.conf_mapping:
    100100                continue
    101101            o = self.conf_mapping[key]
    102102
  • lib/dbtexmf/core/error.py

     
    4949
    5050def failure_track(msg):
    5151    global _dump_stack
    52     print >>sys.stderr, (msg)
     52    print((msg), file=sys.stderr)
    5353    if _dump_stack:
    5454        traceback.print_exc()
    5555
  • lib/dbtexmf/dblatex/xetex/fcmanager.py

     
    169169
    170170    def get_font_handling(self, char, all=False, family_type=""):
    171171        if not(family_type):
    172             font_family = self.fonts.values()
     172            font_family = list(self.fonts.values())
    173173        else:
    174174            font_family = self.fonts_family.get(family_type, None)
    175175       
  • lib/dbtexmf/dblatex/grubber/bibtopic.py

     
    11
    2 from plugins import TexModule
    3 from bibtex import BibTex
     2from .plugins import TexModule
     3from .bibtex import BibTex
    44
    55
    66class BibSect(BibTex):
  • lib/dbtexmf/dblatex/grubber/index.py

     
    4545import xml.dom.minidom
    4646
    4747from subprocess import Popen, PIPE
    48 from msg import _, msg
    49 from plugins import TexModule
    50 from util import md5_file
     48from .msg import _, msg
     49from .plugins import TexModule
     50from .util import md5_file
    5151
    5252
    5353class Xindy:
     
    514514        index = self.indices[name] = Index(self.doc, idx, ind, ilg)
    515515        for cmd in self.defaults:
    516516            index.command(*cmd)
    517         if self.commands.has_key(name):
     517        if name in self.commands:
    518518            for cmd in self.commands[name]:
    519519                index.command(*cmd)
    520520
     
    546546                args = args[1:]
    547547        if names is None:
    548548            self.defaults.append([cmd, args])
    549             names = indices.keys()
     549            names = list(indices.keys())
    550550        for index in names:
    551             if indices.has_key(index):
     551            if index in indices:
    552552                indices[index].command(cmd, args[1:])
    553             elif self.commands.has_key(index):
     553            elif index in self.commands:
    554554                self.commands[index].append([cmd, args])
    555555            else:
    556556                self.commands[index] = [[cmd, args]]
    557557
    558558    def post_compile (self):
    559         for index in self.indices.values():
     559        for index in list(self.indices.values()):
    560560            if index.post_compile():
    561561                return 1
    562562        return 0
    563563
    564564    def clean (self):
    565         for index in self.indices.values():
     565        for index in list(self.indices.values()):
    566566            index.clean()
    567567        return 0
    568568
  • lib/dbtexmf/dblatex/grubber/ps2pdf.py

     
    77import sys
    88import os
    99
    10 from msg import _, msg
    11 from maker import DependShell
    12 from plugins import TexModule
     10from .msg import _, msg
     11from .maker import DependShell
     12from .plugins import TexModule
    1313
    1414
    1515class Module (TexModule):
  • lib/dbtexmf/dblatex/grubber/dvips.py

     
    1313from os.path import *
    1414import subprocess
    1515
    16 from msg import _ , msg
    17 from plugins import TexModule
    18 from maker import Depend
     16from .msg import _ , msg
     17from .plugins import TexModule
     18from .maker import Depend
    1919
    2020class Dep (Depend):
    2121    def __init__ (self, doc, target, source, node):
  • lib/dbtexmf/dblatex/grubber/makeidx.py

     
    2424"""
    2525import sys
    2626
    27 from index import Index
     27from .index import Index
    2828
    2929class Module (Index):
    3030    def __init__ (self, doc, dict):
  • lib/dbtexmf/dblatex/grubber/xr-hyper.py

     
    99"""
    1010import os
    1111
    12 from msg import _, msg
    13 from plugins import TexModule
    14 from latex import Latex
     12from .msg import _, msg
     13from .plugins import TexModule
     14from .latex import Latex
    1515
    1616class Module(TexModule):
    1717    def __init__ (self, doc, dict):
     
    2323        # remember the engine used to build the main latex document
    2424        self.texmodules = []
    2525        for m in ("pdftex", "xetex"):
    26             if doc.modules.has_key(m):
     26            if m in doc.modules:
    2727                self.texmodules.append(m)
    2828
    2929        # want to track each external document whose .aux is required
  • lib/dbtexmf/dblatex/grubber/bibtex.py

     
    1212"""
    1313
    1414# Stop python 2.2 from calling "yield" statements syntax errors.
    15 from __future__ import generators
     15
    1616
    1717import os, sys
    1818from os.path import *
     
    2121
    2222#from grubber import _
    2323#from grubber import *
    24 from msg import _, msg
    25 from plugins import TexModule
     24from .msg import _, msg
     25from .plugins import TexModule
    2626
    2727re_bibdata = re.compile(r"\\bibdata{(?P<data>.*)}")
    2828re_citation = re.compile(r"\\citation{(?P<cite>.*)}")
     
    111111        """
    112112        if self.style:
    113113            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:
    115115                del self.doc.sources[old_bst]
    116116
    117117        self.style = style
     
    168168            return 1
    169169
    170170        dtime = getmtime(self.blgfile)
    171         for db in self.db.values():
     171        for db in list(self.db.values()):
    172172            if getmtime(db) > dtime:
    173173                msg.log(_("bibliography database %s was modified") % db,
    174174                        pkg="bibtex")
     
    207207                m = re_citation.match(line)
    208208                if m:
    209209                    cite = m.group("cite")
    210                     if not cites.has_key(cite):
     210                    if cite not in cites:
    211211                        last = last + 1
    212212                        cites[cite] = last
    213213                    continue
     
    218218        dbs.sort()
    219219
    220220        if self.sorted:
    221             list = cites.keys()
     221            list = list(cites.keys())
    222222            list.sort()
    223223            return list, dbs
    224224        else:
    225             list = [(n,c) for (c,n) in cites.items()]
     225            list = [(n,c) for (c,n) in list(cites.items())]
    226226            list.sort()
    227227            return [c for (n,c) in list], dbs
    228228
     
    235235            match = re_undef.match(line)
    236236            if match:
    237237                cites[match.group("cite")] = None
    238         list = cites.keys()
     238        list = list(cites.keys())
    239239        list.sort()
    240240        return list
    241241
     
    400400                file = d["file"]
    401401                if file[-4:] == ".bib":
    402402                    file = file[:-4]
    403                 if self.db.has_key(file):
     403                if file in self.db:
    404404                    d["file"] = self.db[file]
    405                 elif self.db.has_key(file + ".bib"):
     405                elif file + ".bib" in self.db:
    406406                    d["file"] = self.db[file + ".bib"]
    407407                yield d
    408408            last_line = line
  • lib/dbtexmf/dblatex/grubber/xetex.py

     
    22XeTeX support for Rubber.
    33"""
    44
    5 from plugins import TexModule
     5from .plugins import TexModule
    66
    77class Module (TexModule):
    88    def __init__ (self, doc, dict):
  • lib/dbtexmf/dblatex/grubber/pdftex.py

     
    1414import subprocess
    1515from subprocess import Popen, PIPE
    1616
    17 from msg import _, msg
    18 from plugins import TexModule
     17from .msg import _, msg
     18from .plugins import TexModule
    1919
    2020
    2121class Module (TexModule):
  • lib/dbtexmf/xslt/xsltproc.py

     
    2626        if self.use_catalogs and self.catalogs:
    2727            cmd.append("--catalogs")
    2828        if params:
    29             for param, value in params.items():
     29            for param, value in list(params.items()):
    3030                cmd += ["--param", param, "'%s'" % value]
    3131        if opts:
    3232            cmd += opts
  • lib/dbtexmf/xslt/xsltconf.py

     
    5252            return args
    5353
    5454        param_args = []
    55         for param, value in params.items():
     55        for param, value in list(params.items()):
    5656            param_args.append(self.param_format % {"param_name": param,
    5757                                                   "param_value": value})
    5858
  • lib/dbtexmf/xslt/saxon.py

     
    2222            cmd += opts
    2323        cmd += [xmlfile, xslfile]
    2424        if params:
    25             for param, value in params.items():
     25            for param, value in list(params.items()):
    2626                cmd += ["%s=%s" % (param, "'%s'" % value)]
    2727        self.system(cmd)
    2828
  • tools/dblatex_config.py

     
    104104    (options, args) = parser.parse_args()
    105105
    106106    if len(args) != 2:
    107         print >> sys.stderr, "Invalid argument count: expected 2"
     107        print("Invalid argument count: expected 2", file=sys.stderr)
    108108        parser.parse_args(["-h"])
    109109
    110110    txt_file = args[0]
  • tools/paramcheck.py

     
    104104    sr = set(reffiles)
    105105
    106106    torem_from_syn = ss - sp
    107     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
     107    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)
    113113
    114114
    115115if __name__ == "__main__":
  • tools/utfdump.py

     
    1717                o = encode(uchar)[0]
    1818            except:
    1919                o = "?"
    20             print "U%04X: %s" % (ord(uchar), o)
     20            print("U%04X: %s" % (ord(uchar), o))
    2121            outline += o
    22         print "Line %3d: %s" % (lineno, outline)
     22        print("Line %3d: %s" % (lineno, outline))
    2323
    2424
    2525if __name__ == "__main__":
  • tools/pdfscan.py

     
    4040
    4141    def failure_track(self, msg, rc=1):
    4242        self.rc = rc
    43         print >>sys.stderr, (msg)
     43        print((msg), file=sys.stderr)
    4444        if self._dump_stack:
    4545            traceback.print_exc()
    4646
     
    329329        self.unresolved = []
    330330
    331331    def count(self):
    332         return len(self.pdfobjects.values())
     332        return len(list(self.pdfobjects.values()))
    333333
    334334    def types(self):
    335         return self.objtypes.keys()
     335        return list(self.objtypes.keys())
    336336
    337337    def add_object(self, pdfobject):
    338338        self.pdfobjects[pdfobject.ident()] = pdfobject
     
    359359        self.unresolved = unresolved
    360360
    361361    def stream_decode(self):
    362         for pdfobj in self.pdfobjects.values():
     362        for pdfobj in list(self.pdfobjects.values()):
    363363            pdfobj.stream_decode()
    364364
    365365
     
    873873        return self.params.get(param, default)
    874874   
    875875    def values(self):
    876         return self.params.values()
     876        return list(self.params.values())
    877877
    878878    def keys(self):
    879         return self.params.keys()
     879        return list(self.params.keys())
    880880
    881881    def infos(self):
    882882        return self.params
     
    889889
    890890    def link_to(self, pdfobjects):
    891891        unresolved = 0
    892         for param, value in self.params.items():
     892        for param, value in list(self.params.items()):
    893893            # Point to something else than a string? Skip it
    894894            if not(isinstance(value, str)):
    895895                continue
     
    960960            shutil.rmtree(self.cache_dirname)
    961961        else:
    962962            for fname in self.cache_files:
    963                 print "shutil.remove(", fname
     963                print("shutil.remove(", fname)
    964964
    965965    def cache(self, **kwargs):
    966966        if self.cache_method == "file":
     
    12531253
    12541254    def dump(self):
    12551255        s = self._level * "  " + "q '" + self._data + "'"
    1256         print s
     1256        print(s)
    12571257        for q in self._children:
    12581258            q.dump()
    12591259        s = self._level * "  " + "Q"
    1260         print s
     1260        print(s)
    12611261
    12621262
    12631263class PDFTextObject:
     
    14451445            return textdata
    14461446        if (self.font.tounicode):
    14471447            textdata = self._re_textunicode.findall(self.data)
    1448             s = u" ".join(self.font.tounicode.decode(textdata))
     1448            s = " ".join(self.font.tounicode.decode(textdata))
    14491449            return self.encode(s, "substitute")[0]
    14501450        else:
    14511451            return ""
     
    14561456    @classmethod
    14571457    def _encode_subs(cls, exc):
    14581458        if not isinstance(exc, UnicodeEncodeError):
    1459             return u""
     1459            return ""
    14601460        l = []
    14611461        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)
    14641464
    14651465
    14661466class PDFFont:
     
    14941494
    14951495    def get_pdffont(self, fontobj, fontsize):
    14961496        key = fontobj.descriptor.get("/BaseFont")+"/"+"%6.2f" % fontsize
    1497         if self.fontused.has_key(key):
     1497        if key in self.fontused:
    14981498            return self.fontused.get(key)
    14991499        elif self.global_fontmgr:
    15001500            pdffont = self.global_fontmgr.get_pdffont(fontobj, fontsize)
     
    15171517
    15181518    def _get_tounicode(self, pdfobject):
    15191519        key = pdfobject.ident()
    1520         if self.tounicode.has_key(key):
     1520        if key in self.tounicode:
    15211521            tuc = self.tounicode.get(key)
    15221522        else:
    15231523            tuc = ToUnicode(pdfobject)
     
    15311531        return self.get_pdffont(fontobj, size)
    15321532
    15331533    def get_used(self):
    1534         return self.fontused.values()
     1534        return list(self.fontused.values())
    15351535
    15361536
    15371537class ToUnicode(PDFStreamHandler):
     
    16091609        for i in range(0, len(data), 4):
    16101610            s = data[i:i+4]
    16111611            #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)
    16141614
    16151615    def decode(self, data):
    16161616        if isinstance(data, list):
     
    16961696        for page in pdf_pages:
    16971697            fonts_used = page.find_fonts()
    16981698            fonts_used.sort()
    1699             print "\nPage %d fonts used:" % page.pagenum
     1699            print("\nPage %d fonts used:" % page.pagenum)
    17001700            for i, font in enumerate(fonts_used):
    1701                 print "[%d] %-40s %6.2f pt" % (i, font.name(),
    1702                                                self.pt_factor*font.size())
    1703 
    1704             print "\nPage %d layout:" % page.pagenum
     1701                print("[%d] %-40s %6.2f pt" % (i, font.name(),
     1702                                               self.pt_factor*font.size()))
     1703
     1704            print("\nPage %d layout:" % page.pagenum)
    17051705            content_stream = page.streams[0]
    17061706            xp, yp = 0., 0.
    1707             print self.header
    1708             print self.headline
     1707            print(self.header)
     1708            print(self.headline)
    17091709            for textobject in content_stream.textobjects:
    17101710                xp, yp = self._print_textobject_layout(textobject, xp, yp,
    17111711                                                       fonts_used)
     
    17281728                        font_line.append(idx)
    17291729
    17301730            m2 = line[0].matrix * m2
    1731             if self.show_matrix: print "%s" % m2
     1731            if self.show_matrix: print("%s" % m2)
    17321732
    17331733            x, y = m2.tx(), m2.ty()
    17341734            x, y = float(x/72), float(y/72)
     
    17421742            textw = textwrap.wrap(text, wraplen)
    17431743
    17441744            if textw:
    1745                 print "%s%s" % (info, textw[0])
     1745                print("%s%s" % (info, textw[0]))
    17461746                for txt in textw[1:]:
    1747                     print "%s%s" % (self.padding, txt)
     1747                    print("%s%s" % (self.padding, txt))
    17481748
    17491749            xp, yp = x, y
    17501750            for l in line[1:]:
     
    17651765            page_num = i+page_first
    17661766            contents = page.descriptor.get("/Contents")
    17671767            resources = page.descriptor.get("/Resources")
    1768             print "Page %d %s: contents: %s, resources: %s" % \
    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()
    17711771
    17721772class PdfObjectCmd(BasicCmd):
    17731773    """
     
    18041804    def _sanitize_objref(self, ident):
    18051805        flds = ident.split()
    18061806        if len(flds) != 2:
    1807             print "Invalid object reference: must be in the form "\
    1808                   "'number generation'"
     1807            print("Invalid object reference: must be in the form "\
     1808                  "'number generation'")
    18091809            return ""
    18101810        else:
    18111811            return "%s %s" % (flds[0], flds[1])
     
    18131813    def show_dictionnary(self, ident):
    18141814        pdfobject = self.scanner.pdf.get_object(ident)
    18151815        if not(pdfobject):
    1816             print "PDF Object '%s' not found" % ident
     1816            print("PDF Object '%s' not found" % ident)
    18171817            return
    18181818        if pdfobject.stream:
    1819             print "PDF Object '%s' has a stream. Its dictionnary:" % ident
     1819            print("PDF Object '%s' has a stream. Its dictionnary:" % ident)
    18201820        else:
    1821             print "PDF Object '%s' dictionnary:" % ident
     1821            print("PDF Object '%s' dictionnary:" % ident)
    18221822        self._print_dictionnary(pdfobject.descriptor)
    18231823
    18241824    def _print_dictionnary(self, descriptor, level=1):
    18251825        indent = "  "*level
    1826         print "%s<<" % indent
    1827         for p, v in descriptor.infos().items():
     1826        print("%s<<" % indent)
     1827        for p, v in list(descriptor.infos().items()):
    18281828            if isinstance(v, PDFDescriptor):
    1829                 print "%s%s:" % (indent, p)
     1829                print("%s%s:" % (indent, p))
    18301830                self._print_dictionnary(v, level=level+1)
    18311831            else:
    1832                 print "%s%s: %s" % (indent, p, v)
    1833         print "%s>>" % indent
     1832                print("%s%s: %s" % (indent, p, v))
     1833        print("%s>>" % indent)
    18341834
    18351835    def list_pdfobjects(self):
    18361836        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:")
    18391839        types = pdfobjects.types()
    18401840        types.sort()
    18411841        total = 0
    18421842        for typ in types:
    18431843            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))
    18451845            total = total + n_type
    1846         print " %20s: %5d objects" % ("TOTAL", total)
     1846        print(" %20s: %5d objects" % ("TOTAL", total))
    18471847
    18481848    def dump_stream(self, ident, outfile):
    18491849        pdfobject = self.scanner.pdf.get_object(ident)
    18501850        if not(pdfobject):
    1851             print "PDF Object '%s' not found" % ident
     1851            print("PDF Object '%s' not found" % ident)
    18521852            return
    18531853        if not(pdfobject.stream):
    1854             print "PDF Object '%s' has no stream. Give up." % ident
     1854            print("PDF Object '%s' has no stream. Give up." % ident)
    18551855            return
    18561856        pdfobject.stream_decode()
    18571857        f = open(outfile, "wb")
    18581858        f.write(pdfobject.stream_text())
    18591859        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))
    18611861
    18621862
    18631863
     
    18951895
    18961896    def print_fonts_in_pages(self, pdf_pages, show=True):
    18971897        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*"-"))
    19001900
    19011901        for page in pdf_pages:
    19021902            fonts_used = page.find_fonts()
    19031903            fonts_used.sort()
    19041904            for font in fonts_used:
    19051905                if show:
    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*"-")
     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*"-"))
    19091909
    19101910    def print_font_summary(self):
    19111911        pages = []
     
    19171917                s += "-%d" % (pg[-1].pagenum)
    19181918            pages.append(s)
    19191919
    1920         print "\nFonts used in pages %s:" % (",".join(pages))
     1920        print("\nFonts used in pages %s:" % (",".join(pages)))
    19211921        fonts_used = self.scanner.pdf.fontmgr.get_used()
    19221922        fonts_used.sort()
    19231923        for font in fonts_used:
    1924             print "%-40s %6.2f %s" % \
    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))
    19261926
    19271927
    19281928class PDFScannerCommand:
     
    20672067        if not(verbose):
    20682068            return log_groups
    20692069
    2070         groups = log_groups.keys()
     2070        groups = list(log_groups.keys())
    20712071        for verbose_opt in verbose:
    20722072            group, level = ("all:" + verbose_opt).split(":")[-2:]
    20732073            if not(level in log_levels):
    2074                 print "Invalid verbose level: '%s'" % level
     2074                print("Invalid verbose level: '%s'" % level)
    20752075                continue
    20762076            if group == "all":
    20772077                for group in groups:
     
    20792079            elif group in groups:
    20802080                log_groups[group] = level
    20812081            else:
    2082                 print "Invalid verbose group: '%s'" % group
     2082                print("Invalid verbose group: '%s'" % group)
    20832083                continue
    20842084        return log_groups
    20852085
     
    21082108        elif cache_dirname:
    21092109            cache_dirname = os.path.realpath(cache_dirname)
    21102110            if not(os.path.exists(cache_dirname)):
    2111                 print "Invalid cache dir: '%s'. Temporary dir used instead" % \
    2112                       cache_dirname
     2111                print("Invalid cache dir: '%s'. Temporary dir used instead" % \
     2112                      cache_dirname)
    21132113                return None
    21142114            mgr = StreamManager(cache_method="file",
    21152115                                cache_dirname=cache_dirname,
     
    21292129        fmt = logging.Formatter("%(message)s")
    21302130        console.setFormatter(fmt)
    21312131
    2132         for group, level in log_groups.items():
     2132        for group, level in list(log_groups.items()):
    21332133            log = logging.getLogger("pdfscan.%s" % group)
    21342134            log.setLevel(loglevels.get(level, logging.INFO)-1)
    21352135            log.addHandler(console)
     
    21542154        argslist.append(args)
    21552155
    21562156    if not(remain_args) or remain_args[0] in scanner.commands():
    2157         print "Missing the PDF File"
     2157        print("Missing the PDF File")
    21582158        parser.parse_args(["-h"])
    21592159
    21602160    error = ErrorHandler()
     
    21632163    try:
    21642164        pdffile = remain_args[0]
    21652165        scanner.run(parser, options, argslist, pdffile)
    2166     except Exception, e:
     2166    except Exception as e:
    21672167        error.failure_track("Error: '%s'" % (e))
    21682168
    21692169    scanner.cleanup()