Ticket #61530: Python2-3_patches.diff

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

Patches to translate Python 2 code to Python 3 code

  • setup.py

     
    8383        self._catalogs = install.catalogs
    8484        self._style = install.style
    8585        self._use_py_path = install.use_python_path
    86         print self._package_base
     86        print(self._package_base)
    8787
    8888        # Build the command line script
    8989        self.build_script()
     
    162162        script = self.SHELL_SCRIPT % script_args
    163163        script_name = os.path.basename(script_name)
    164164        outfile = os.path.join(self.build_dir, script_name)
    165         fd = os.open(outfile, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0755)
     165        fd = os.open(outfile, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0o755)
    166166        os.write(fd, script)
    167167        os.close(fd)
    168168
     
    260260        # First, check non critical graphic tools
    261261        found, missed = find_programs(("epstopdf", "convert", "fig2dev"))
    262262        for util in found:
    263             print "+checking %s... yes" % util
     263            print("+checking %s... yes" % util)
    264264        for util in missed:
    265             print "+checking %s... no" % util
     265            print("+checking %s... no" % util)
    266266        if missed:
    267             print("warning: not found: %s" % ", ".join(missed))
     267            print(("warning: not found: %s" % ", ".join(missed)))
    268268
    269269        # Now, be serious
    270270        found, missed = find_programs(("latex", "makeindex",
    271271                                       "pdflatex", "kpsewhich"))
    272272        for util in found:
    273             print "+checking %s... yes" % util
     273            print("+checking %s... yes" % util)
    274274        for util in missed:
    275             print "+checking %s... no" % util
     275            print("+checking %s... no" % util)
    276276        if missed:
    277277            raise OSError("not found: %s" % ", ".join(missed))
    278278
     
    292292        for (mod, deplist) in deplists:
    293293            if not(deplist):
    294294                xslt_found.append(mod)
    295                 print "+checking XSLT %s... yes" % mod
     295                print("+checking XSLT %s... yes" % mod)
    296296                continue
    297297            found, missed = find_programs(deplist)
    298298            if missed:
    299299                xslt_missed.append(mod)
    300                 print "+checking XSLT %s... no (missing %s)" % \
    301                       (mod, ", ".join(missed))
     300                print("+checking XSLT %s... no (missing %s)" % \
     301                      (mod, ", ".join(missed)))
    302302            else:
    303303                xslt_found.append(mod)
    304                 print "+checking XSLT %s... yes" % mod
     304                print("+checking XSLT %s... yes" % mod)
    305305
    306306        if not(xslt_found):
    307307            raise OSError("XSLT not installed: %s" % ", ".join(xslt_missed))
    308308        elif xslt_missed:
    309             print "warning: XSLT not found: %s" % ", ".join(xslt_missed)
     309            print("warning: XSLT not found: %s" % ", ".join(xslt_missed))
    310310
    311311    def check_latex_dependencies(self):
    312312        # Find the Latex files from the package
     
    353353            if sty in own_stys:
    354354                status += "found in package"
    355355                found_stys.append(sty)
    356                 print status
     356                print(status)
    357357                continue
    358358            stypath = kpsewhich("%s.sty" % sty)
    359359            if stypath:
     
    362362            else:
    363363                status += "no"
    364364                mis_stys.append(sty)
    365             print status
     365            print(status)
    366366           
    367367        if mis_stys:
    368368            raise OSError("not found: %s" % ", ".join(mis_stys))
     
    378378                self.check_xslt_dependencies()
    379379                self.check_util_dependencies()
    380380                self.check_latex_dependencies()
    381             except Exception, e:
    382                 print >>sys.stderr, "Error: %s" % e
     381            except Exception as e:
     382                print("Error: %s" % e, file=sys.stderr)
    383383                sys.exit(1)
    384384
    385385        if db: db.adapt_paths()
  • lib/dbtexmf/core/dbtex.py

     
    88import shlex
    99import tempfile
    1010import shutil
    11 import urllib
     11import urllib.request, urllib.parse, urllib.error
    1212import glob
    1313import imp
    1414from optparse import OptionParser
     
    2929
    3030def path_to_uri(path):
    3131    if os.name == 'nt':
    32         return 'file:' + urllib.pathname2url(path).replace('|', ':', 1)
     32        return 'file:' + urllib.request.pathname2url(path).replace('|', ':', 1)
    3333    else:
    34         return urllib.pathname2url(path)
     34        return urllib.request.pathname2url(path)
    3535
    3636
    3737class Document:
     
    395395        self.update_texinputs()
    396396
    397397        # For easy debug
    398         if self.debug and os.environ.has_key("TEXINPUTS"):
     398        if self.debug and "TEXINPUTS" in os.environ:
    399399            if os.name != "nt":
    400400                f = file("env_tex", "w")
    401401                f.write("TEXINPUTS=%s\nexport TEXINPUTS\n" % \
     
    544544        if options.format:
    545545            try:
    546546                run.set_format(options.format)
    547             except Exception, e:
     547            except Exception as e:
    548548                failed_exit("Error: %s" % e)
    549549
    550550        # Always set the XSLT (default or not)
    551551        try:
    552552            run.set_xslt(options.xslt)
    553         except Exception, e:
     553        except Exception as e:
    554554            failed_exit("Error: %s" % e)
    555555
    556556        if options.xslopts:
     
    575575        if options.texstyle:
    576576            try:
    577577                xslparam, texpath = texstyle_parse(options.texstyle)
    578             except Exception, e:
     578            except Exception as e:
    579579                failed_exit("Error: %s" % e)
    580580            run.xslparams.append(xslparam)
    581581            if texpath: run.texinputs.append(texpath)
     
    630630            if not(os.path.exists(options.tmpdir)):
    631631                try:
    632632                    os.mkdir(options.tmpdir)
    633                 except Exception, e:
     633                except Exception as e:
    634634                    failed_exit("Error: %s" % e)
    635635            run.tmpdir_user = os.path.abspath(options.tmpdir)
    636636
     
    665665
    666666        if options.version:
    667667            version = run.get_version()
    668             print "%s version %s" % (self.prog, version)
     668            print("%s version %s" % (self.prog, version))
    669669            if not(args):
    670670                sys.exit(0)
    671671
     
    682682            try:
    683683                conf.paths = self.get_config_paths()
    684684                conf.fromstyle(options.style)
    685             except Exception, e:
     685            except Exception as e:
    686686                failed_exit("Error: %s" % e)
    687687           
    688688        if options.config:
    689689            try:
    690690                for config in options.config:
    691691                    conf.fromfile(config)
    692             except Exception, e:
     692            except Exception as e:
    693693                failed_exit("Error: %s" % e)
    694694
    695695        if conf.options:
     
    735735        # Try to buid the file
    736736        try:
    737737            run.compile()
    738         except Exception, e:
     738        except Exception as e:
    739739            signal_error(self, e)
    740740            failed_exit("Error: %s" % e)
    741741
  • lib/dbtexmf/core/confparser.py

     
    11import os
    22import sys
    33from xml.etree.ElementTree import ParseError
    4 from xmlparser import XmlConfig
    5 from txtparser import TextConfig
    6 from imagedata import ImageConverterPool, ImageConverter
    7 from imagedata import ImageFormatPool, FormatRule
    8 from imagedata import image_setup
     4from .xmlparser import XmlConfig
     5from .txtparser import TextConfig
     6from .imagedata import ImageConverterPool, ImageConverter
     7from .imagedata import ImageFormatPool, FormatRule
     8from .imagedata import image_setup
    99from dbtexmf.xslt.xsltconf import XsltCommandPool, XsltEngine
    1010from dbtexmf.xslt import xslt_setup
    1111
     
    7676        self.style_exts = ["", ".xml", ".specs", ".conf"]
    7777
    7878    def warn(self, text):
    79         print >>sys.stderr, text
     79        print(text, file=sys.stderr)
    8080
    8181    def fromfile(self, filename):
    8282        try:
    8383            self.fromxmlfile(filename)
    84         except ParseError, e:
     84        except ParseError as e:
    8585            self.warn("Text configuration files are deprecated. "\
    8686                      "Use the XML format instead")
    8787            self.fromtxtfile(filename)
    88         except Exception, e:
     88        except Exception as e:
    8989            raise e
    9090
    9191    def fromxmlfile(self, filename):
  • lib/dbtexmf/core/xmlparser.py

     
    11import os
    22import re
    33import xml.etree.ElementTree as ET
    4 from txtparser import texinputs_parse
     4from .txtparser import texinputs_parse
    55
    66class BaseOption:
    77    def __init__(self, config, optname):
     
    207207
    208208    def options(self):
    209209        opts = []
    210         for parsers in self.infos.values():
     210        for parsers in list(self.infos.values()):
    211211            for parser in parsers:
    212212                opts.extend(parser.options())
    213213        return opts
    214214
    215215    def modules(self):
    216216        mods = {}
    217         for parsers in self.infos.values():
     217        for parsers in list(self.infos.values()):
    218218            for parser in parsers:
    219219                mods.update(parser.modules())
    220220        return mods
     
    282282
    283283    def options(self):
    284284        opts = []
    285         for parser in self.infos.values():
     285        for parser in list(self.infos.values()):
    286286            opts.extend(parser.options())
    287287        return opts
    288288
    289289    def modules(self):
    290290        mods = {}
    291         for parser in self.infos.values():
     291        for parser in list(self.infos.values()):
    292292            mods.update(parser.modules())
    293293        return mods
    294294
  • lib/dbtexmf/core/imagedata.py

     
    33import re
    44import shutil
    55import logging
    6 import urllib
     6import urllib.request, urllib.parse, urllib.error
    77from dbtexmf.core.error import signal_error
    8 from commander import CommandRunner
     8from .commander import CommandRunner
    99
    1010class ObjectFilter:
    1111    """
     
    2626        return "("+searched+")"
    2727
    2828    def select(self, object_list, **filter_criterions):
    29         for criterion, value in filter_criterions.items():
     29        for criterion, value in list(filter_criterions.items()):
    3030            filter_criterions[criterion] = self._re_multi_or_star(value)
    3131
    3232        founds = []
    3333        for obj in object_list:
    3434            object_criterions = obj.criterions()
    35             for criterion, re_expr in filter_criterions.items():
     35            for criterion, re_expr in list(filter_criterions.items()):
    3636                data = object_criterions.get(criterion, "")
    3737                m = re.search(re_expr, data)
    3838                #print "Lookup2:", criterion, re_expr, data, not(m is None)
     
    259259
    260260    def convert(self, fig):
    261261        # Translate the URL to an actual local path
    262         fig = urllib.url2pathname(fig)
     262        fig = urllib.request.url2pathname(fig)
    263263
    264264        # Always use '/' in path: work even on windows and is required by tex
    265265        if os.path.sep != '/': fig = fig.replace(os.path.sep, '/')
     
    273273            return fig
    274274
    275275        # Check if this image has been already converted
    276         if self.converted.has_key(realfig):
     276        if realfig in self.converted:
    277277            self.log.info("Image '%s' already converted as %s" % \
    278278                  (fig, self.converted[realfig]))
    279279            return self.converted[realfig]
  • lib/dbtexmf/dblatex/dblatex.py

     
    77from dbtexmf.core.sgmlxml import Osx
    88from dbtexmf.core.dbtex import DbTex, DbTexCommand
    99
    10 from rawtex import RawLatex
    11 from runtex import RunLatex
     10from .rawtex import RawLatex
     11from .runtex import RunLatex
    1212
    1313
    1414class DbLatex(DbTex):
  • lib/dbtexmf/dblatex/rawtex.py

     
    88import os
    99import re
    1010
    11 from rawparse import RawLatexParser, RawUtfParser
    12 from rawverb import VerbParser
    13 from rawlabel import RawLabelParser
    14 from xetex.codec import XetexCodec
     11from .rawparse import RawLatexParser, RawUtfParser
     12from .rawverb import VerbParser
     13from .rawlabel import RawLabelParser
     14from .xetex.codec import XetexCodec
    1515from dbtexmf.core.imagedata import *
    1616
    1717
  • lib/dbtexmf/dblatex/rawparse.py

     
    11import re
    22
    3 from texcodec import LatexCodec, TexCodec
    4 from texhyphen import BasicHyphenator, UrlHyphenator
     3from .texcodec import LatexCodec, TexCodec
     4from .texhyphen import BasicHyphenator, UrlHyphenator
    55
    66
    77def utf8(u):
     
    1616
    1717class RawLatexParser:
    1818    def __init__(self,
    19                  key_in=utf8(u"\u0370t"), key_out=utf8(u"\u0371t"),
     19                 key_in=utf8("\u0370t"), key_out=utf8("\u0371t"),
    2020                 codec=None, output_encoding="latin-1"):
    2121        self.key_in = RawKey(key_in, 1)
    2222        self.key_out = RawKey(key_out, -1)
     
    2727        self.hyphenator = UrlHyphenator(codec=self.codec)
    2828       
    2929        # hyphenation patterns
    30         self.hypon = re.compile(utf8(u"\u0370h"))
    31         self.hypof = re.compile(utf8(u"\u0371h"))
     30        self.hypon = re.compile(utf8("\u0370h"))
     31        self.hypof = re.compile(utf8("\u0371h"))
    3232
    3333    def parse(self, line):
    3434        lout = ""
     
    7979
    8080    def __init__(self, codec=None, output_encoding="latin-1"):
    8181        texcodec = codec or TexCodec(output_encoding=output_encoding)
    82         RawLatexParser.__init__(self, utf8(u"\u0370u"), utf8(u"\u0371u"),
     82        RawLatexParser.__init__(self, utf8("\u0370u"), utf8("\u0371u"),
    8383                                texcodec)
    8484
    8585    def translate(self, text):
  • lib/dbtexmf/dblatex/texcodec.py

     
    44#
    55import re
    66import codecs
    7 import unient
     7from . import unient
    88
    99# Dictionnary of the handlers installed
    1010tex_handler_installed = {}
     
    2121        try:
    2222            l.append(unient.unicode_map[ord(c)])
    2323        except KeyError:
    24             print "Missing character &#x%x;" % ord(c)
    25             l.append(u"\&\#x%x;" % ord(c))
     24            print("Missing character &#x%x;" % ord(c))
     25            l.append("\&\#x%x;" % ord(c))
    2626        if post: l.append(post)
    2727        n = n + 1
    2828    tex_handler_counter[name] = n
    29     return (u"".join(l), exc.end)
     29    return ("".join(l), exc.end)
    3030
    3131
    3232class TexCodec:
     
    6363            self.charmap = {}
    6464            return
    6565
    66         if not(tex_handler_installed.has_key(self._errors)):
     66        if not(self._errors in tex_handler_installed):
    6767            f = self.build_error_func(pre, post, errors)
    6868            codecs.register_error(self._errors, f)
    6969            tex_handler_installed[self._errors] = f
     
    8383
    8484    def encode(self, text):
    8585        text = self._encode(text, self._errors)[0]
    86         for c, v in self.charmap.items():
     86        for c, v in list(self.charmap.items()):
    8787            text = text.replace(c, v)
    8888        return text
    8989 
     
    120120        text = self._encode(text, self._errors)[0]
    121121
    122122        # Special Character Mapping
    123         for c, v in self.charmap.items():
     123        for c, v in list(self.charmap.items()):
    124124            text = text.replace(c, v)
    125125
    126126        # Things are done, complete with {}
  • lib/dbtexmf/dblatex/texhyphen.py

     
    9696    url = "http://www.fg/foobar fun#fght/fkkkf.tz?id=123"
    9797    h1 = BasicHyphenator()
    9898    h2 = UrlHyphenator()
    99     print h1.hyphenate(url)
    100     print h2.hyphenate(url)
     99    print(h1.hyphenate(url))
     100    print(h2.hyphenate(url))
  • lib/dbtexmf/dblatex/rawverb.py

     
    1111#
    1212import re
    1313
    14 from texcodec import TexCodec
    15 from texcodec import tex_handler_counter
    16 from rawparse import RawUtfParser
     14from .texcodec import TexCodec
     15from .texcodec import tex_handler_counter
     16from .rawparse import RawUtfParser
    1717
    1818
    1919class VerbCodec(TexCodec):
  • lib/dbtexmf/dblatex/rawlabel.py

     
    1 from texcodec import TexCodec
    2 from texcodec import tex_handler_counter
    3 from rawparse import RawLatexParser, utf8
     1from .texcodec import TexCodec
     2from .texcodec import tex_handler_counter
     3from .rawparse import RawLatexParser, utf8
    44
    55
    66def label_char_replace(exc, pre, post, errors):
     
    1616        if post: l.append(post)
    1717        n = n + 1
    1818    tex_handler_counter[errors] = n
    19     return (u"".join(l), exc.end)
     19    return ("".join(l), exc.end)
    2020
    2121
    2222class LabelCodec(TexCodec):
     
    6060    """
    6161    def __init__(self, codec=None, output_encoding="latin-1"):
    6262        texcodec = codec or LabelCodec(output_encoding=output_encoding)
    63         RawLatexParser.__init__(self, utf8(u"\u0370l"), utf8(u"\u0371l"),
     63        RawLatexParser.__init__(self, utf8("\u0370l"), utf8("\u0371l"),
    6464                                texcodec)
    6565
    6666    def translate(self, text):
  • lib/dbtexmf/dblatex/xetex/codec.py

     
    33import codecs
    44
    55from dbtexmf.dblatex.texcodec import LatexCodec
    6 from fsencoder import FontSpecEncoder
     6from .fsencoder import FontSpecEncoder
    77
    88
    99class XetexCodec(LatexCodec):
  • lib/dbtexmf/dblatex/xetex/fsencoder.py

     
    1111import re
    1212import xml.dom.minidom
    1313
    14 from fontspec import UnicodeInterval
    15 from fsconfig import FontSpecConfig
     14from .fontspec import UnicodeInterval
     15from .fsconfig import FontSpecConfig
    1616
    1717
    1818class FontSpecEncoder:
     
    6868        """
    6969        fontspec = self._cur_fontspec or self._conf.default_fontspec
    7070
    71         print >>sys.stderr, "Current:", fontspec.id
     71        print("Current:", fontspec.id, file=sys.stderr)
    7272        fontspec = fontspec.match(char)
    7373        while not(fontspec):
    7474            leaf = self._ref_stack.pop()
  • lib/dbtexmf/dblatex/xetex/fontspec.py

     
    4949        if m:
    5050            return int(m.group(1), 16)
    5151        else:
    52             raise RuntimeError, 'Not a unicode codepoint: ' + codepoint
     52            raise RuntimeError('Not a unicode codepoint: ' + codepoint)
    5353
    5454    def from_char(self, char):
    5555        """Interval for a single character"""
     
    167167                    intervals.append(
    168168                        UnicodeInterval().from_codepoint(m.group(1)))
    169169                else:
    170                     raise RuntimeError, 'Unable to parse range: "' + range + '"'
     170                    raise RuntimeError('Unable to parse range: "' + range + '"')
    171171        return intervals
    172172
    173173    def _parse_transitions(self, node, transition_type):
     
    194194        specified font types.
    195195        """
    196196        s = ''
    197         for type, font in fonts.items():
     197        for type, font in list(fonts.items()):
    198198            s += '\switch%sfont{%s}' % (type, font)
    199199        if s:
    200200            s = r"\savefamily" + s + r"\loadfamily{}"
  • lib/dbtexmf/dblatex/xetex/fsconfig.py

     
    1212import xml.dom.minidom
    1313import logging
    1414
    15 from fcfallback import FcFallbackFontSpec, DefaultFontSpec
    16 from fontspec import FontSpec, _indent
     15from .fcfallback import FcFallbackFontSpec, DefaultFontSpec
     16from .fontspec import FontSpec, _indent
    1717
    1818
    1919class FontSpecConfig:
  • lib/dbtexmf/dblatex/xetex/fcfallback.py

     
    1 from fontspec import FontSpec
    2 from fcmanager import FcManager
     1from .fontspec import FontSpec
     2from .fcmanager import FcManager
    33
    44
    55class DefaultFontSpec(FontSpec):
     
    5454        for fontspec in self.fontspecs:
    5555
    5656            if fontspec in self.fcmissed:
    57                 print "Specified font '%s' is missing in the system!" % \
    58                       (fontspec.mainfont())
     57                print("Specified font '%s' is missing in the system!" % \
     58                      (fontspec.mainfont()))
    5959                continue
    6060
    6161            fcfont = self.fccache.get(fontspec.mainfont()) or \
     
    9797        fontspec.add_char(char)
    9898        fontspec.add_ignored(self._ignored)
    9999        # Register the font and its related fontconfig object
    100         for fcfont in fcfonts.values():
     100        for fcfont in list(fcfonts.values()):
    101101            self.fccache[fcfont.name] = fcfont
    102102        self.add_subfont(fontspec)
    103103        return fontspec
  • lib/dbtexmf/dblatex/runtex.py

     
    55import re
    66import shutil
    77
    8 from grubber.texbuilder import LatexBuilder
     8from .grubber.texbuilder import LatexBuilder
    99
    1010
    1111class RunLatex:
  • lib/dbtexmf/dblatex/grubber/texbuilder.py

     
    99import subprocess
    1010import os
    1111import shlex
    12 from msg import _, msg
    13 from maker import Maker
    14 from latex import Latex
     12from .msg import _, msg
     13from .maker import Maker
     14from .latex import Latex
    1515
    1616
    1717class IndexBuilder:
     
    9090        self.tex.prepare()
    9191
    9292        # Set the index configuration
    93         if self.tex.modules.has_key("makeidx"):
     93        if "makeidx" in self.tex.modules:
    9494            idx = self.tex.modules["makeidx"]
    9595            if self.index.style: idx.do_style(self.index.style)
    9696            if self.index.tool: idx.do_tool(self.index.tool)
  • lib/dbtexmf/dblatex/grubber/msg.py

     
    3737            self.stdout = None
    3838
    3939    def write_stdout(self, text, level=0):
    40         print text
     40        print(text)
    4141    def write_stderr(self, text, level=0):
    42         print >>sys.stderr, text
     42        print(text, file=sys.stderr)
    4343
    4444    def push_pos (self, pos):
    4545        self.pos.append(pos)
     
    6666            if text[0:13] == "LaTeX Error: ":
    6767                text = text[13:]
    6868            self._log.error(self.format_pos(info, text))
    69             if info.has_key("code") and info["code"] and not self.short:
     69            if "code" in info and info["code"] and not self.short:
    7070                self._log.error(self.format_pos(info,
    7171                    _("leading text: ") + info["code"]))
    7272
     
    100100        the dictionary given as first argument.
    101101        """
    102102        if len(self.pos) > 0:
    103             if where is None or not where.has_key("file"):
     103            if where is None or "file" not in where:
    104104                where = self.pos[-1]
    105105        elif where is None or where == {}:
    106106            return text
    107107
    108         if where.has_key("file") and where["file"] is not None:
     108        if "file" in where and where["file"] is not None:
    109109            pos = self.simplify(where["file"])
    110             if where.has_key("line") and where["line"]:
     110            if "line" in where and where["line"]:
    111111                pos = "%s:%d" % (pos, int(where["line"]))
    112                 if where.has_key("last"):
     112                if "last" in where:
    113113                    if where["last"] != where["line"]:
    114114                        pos = "%s-%d" % (pos, int(where["last"]))
    115115            pos = pos + ": "
    116116        else:
    117117            pos = ""
    118         if where.has_key("page"):
     118        if "page" in where:
    119119            text = "%s (page %d)" % (text, int(where["page"]))
    120         if where.has_key("pkg"):
     120        if "pkg" in where:
    121121            text = "[%s] %s" % (where["pkg"], text)
    122122        return pos + text
    123123
  • lib/dbtexmf/dblatex/grubber/maker.py

     
    88import time
    99import subprocess
    1010
    11 from msg import _, msg
     11from .msg import _, msg
    1212
    1313class Depend (object): #{{{2
    1414    """
     
    5151                # We set the node's date to that of the most recently modified
    5252                # product file, assuming all other files were up to date then
    5353                # (though not necessarily modified).
    54                 self.date = max(map(os.path.getmtime, self.prods))
     54                self.date = max(list(map(os.path.getmtime, self.prods)))
    5555            except OSError:
    5656                # If some product file does not exist, set the last
    5757                # modification date to None.
     
    6464        """
    6565        if not self.date:
    6666            return 1
    67         for src in self.sources.values():
     67        for src in list(self.sources.values()):
    6868            if src.date > self.date:
    6969                return 1
    7070        return 0
     
    8181          on this one have to be remade)
    8282        """
    8383        if self.making:
    84             print "FIXME: cyclic make"
     84            print("FIXME: cyclic make")
    8585            return 1
    8686        self.making = 1
    8787
    8888        # Make the sources
    8989        self.failed_dep = None
    9090        must_make = force
    91         for src in self.sources.values():
     91        for src in list(self.sources.values()):
    9292            ret = src.make()
    9393            if ret == 0:
    9494                self.making = 0
     
    152152            if os.path.exists(file):
    153153                msg.log(_("removing %s") % file)
    154154                os.unlink(file)
    155         for src in self.sources.values():
     155        for src in list(self.sources.values()):
    156156            src.clean()
    157157        self.date = None
    158158
     
    170170        if self.sources == {}:
    171171            return self.prods
    172172        ret = []
    173         for dep in self.sources.values():
     173        for dep in list(self.sources.values()):
    174174            ret.extend(dep.leaves())
    175175        return ret
    176176
  • lib/dbtexmf/dblatex/grubber/latex.py

     
    1111import time
    1212import subprocess
    1313
    14 from msg import _, msg
    15 from util import Watcher
    16 from logparser import LogParser
    17 from texparser import TexParser
    18 from plugins import Modules
    19 from maker import Depend
     14from .msg import _, msg
     15from .util import Watcher
     16from .logparser import LogParser
     17from .texparser import TexParser
     18from .plugins import Modules
     19from .maker import Depend
    2020
    2121
    2222class Latex(Depend):
     
    175175            self.watcher.watch(self.srcbase + "." + ext)
    176176
    177177        msg.log(_("building additional files..."))
    178         for mod in self.modules.objects.values():
     178        for mod in list(self.modules.objects.values()):
    179179            if mod.pre_compile():
    180180                self.failed_module = mod
    181181                return 1
     
    188188        """
    189189        msg.log(_("running post-compilation scripts..."))
    190190
    191         for mod in self.modules.objects.values():
     191        for mod in list(self.modules.objects.values()):
    192192            if mod.post_compile():
    193193                self.failed_module = mod
    194194                return 1
     
    201201        """
    202202        msg.log(_("running last-compilation scripts..."))
    203203
    204         for mod in self.modules.objects.values():
     204        for mod in list(self.modules.objects.values()):
    205205            if mod.last_compile():
    206206                self.failed_module = mod
    207207                return 1
     
    233233        # for dep in self.sources.values():
    234234        #     dep.clean()
    235235
    236         for mod in self.modules.objects.values():
     236        for mod in list(self.modules.objects.values()):
    237237            mod.clean()
    238238
    239239    def remove_suffixes (self, list):
  • lib/dbtexmf/dblatex/grubber/util.py

     
    1111    # Fallback for python 2.4:
    1212    import md5 as hashlib
    1313import os
    14 from msg import _, msg
     14from .msg import _, msg
    1515
    1616
    1717def md5_file(fname):
     
    4545        of the files that changed, or None of they didn't change.
    4646        """
    4747        changed = []
    48         for file in self.files.keys():
     48        for file in list(self.files.keys()):
    4949            if os.path.exists(file):
    5050                new = md5_file(file)
    5151                if self.files[file] != new:
  • lib/dbtexmf/dblatex/grubber/logparser.py

     
    55
    66This module defines the class that parses the LaTeX log files.
    77"""
    8 from __future__ import generators
     8
    99
    1010import re
    1111
    12 from msg import _, msg
     12from .msg import _, msg
    1313
    1414class LogParser:
    1515    """
     
    188188                        m = self.re_ignored.search(error)
    189189                        if m:
    190190                            d["file"] = last_file
    191                             if d.has_key("code"):
     191                            if "code" in d:
    192192                                del d["code"]
    193193                            d.update( m.groupdict() )
    194194                        elif pos[-1] is None:
  • lib/dbtexmf/dblatex/grubber/plugins.py

     
    77import imp
    88
    99from os.path import *
    10 from msg import _, msg
     10from .msg import _, msg
    1111
    1212import sys
    1313
     
    106106        dictionary. Return 0 if no module was found, 1 if a module was found
    107107        and loaded, and 2 if the module was found but already loaded.
    108108        """
    109         if self.modules.has_key(name):
     109        if name in self.modules:
    110110            return 2
    111111        try:
    112112            file, path, descr = imp.find_module(name, [""])
     
    155155        """
    156156        Check if a given module is loaded.
    157157        """
    158         return self.objects.has_key(name)
     158        return name in self.objects
    159159
    160160    def register (self, name, dict={}):
    161161        """
     
    165165        delayed commands for this module. The dictionary describes the
    166166        command that caused the registration.
    167167        """
    168         if self.has_key(name):
     168        if name in self:
    169169            msg.debug(_("module %s already registered") % name)
    170170            return 2
    171171
     
    191191
    192192        # Run any delayed commands.
    193193
    194         if self.commands.has_key(name):
     194        if name in self.commands:
    195195            for (cmd, args, vars) in self.commands[name]:
    196196                msg.push_pos(vars)
    197197                try:
     
    219219        Send a command to a particular module. If this module is not loaded,
    220220        store the command so that it will be sent when the module is register.
    221221        """
    222         if self.objects.has_key(mod):
     222        if mod in self.objects:
    223223            self.objects[mod].command(cmd, args)
    224224        else:
    225             if not self.commands.has_key(mod):
     225            if mod not in self.commands:
    226226                self.commands[mod] = []
    227227            self.commands[mod].append((cmd, args, self.env.vars.copy()))
    228228
  • lib/dbtexmf/core/dbtex.py

     
    183183        self.flags &= ~what
    184184
    185185    def get_version(self):
    186         f = file(os.path.join(self.topdir, "xsl", "version.xsl"))
     186        f = open(os.path.join(self.topdir, "xsl", "version.xsl"))
    187187        versions = re.findall("<xsl:variable[^>]*>([^<]*)<", f.read())
    188188        f.close()
    189189        if versions:
     
    196196            self.xslbuild = self.xslmain
    197197            return
    198198
    199         f = file(wrapper, "w")
     199        f = open(wrapper, "w")
    200200        f.write(self.xsl_header)
    201201        f.write('<xsl:import href="%s"/>\n' % path_to_uri(self.xslmain))
    202202        for xsluser in self.xslusers:
     
    231231                              self.listings, opts=self.xslopts, params=param)
    232232        else:
    233233            self.log.info("No external file support")
    234             f = file(self.listings, "w")
     234            f = open(self.listings, "w")
    235235            f.write("<listings/>\n")
    236236            f.close()
    237237
     
    268268        # set list
    269269        self.log.info("Build the book set list...")
    270270        xslset = "doclist.xsl"
    271         f = file(xslset, "w")
     271        f = open(xslset, "w")
    272272        f.write(self.xsl_header)
    273273        f.write('<xsl:import href="%s"/>\n' % path_to_uri(self.xslbuild))
    274274        f.write('<xsl:import href="%s"/>\n' % path_to_uri(self.xslset))
     
    397397        # For easy debug
    398398        if self.debug and "TEXINPUTS" in os.environ:
    399399            if os.name != "nt":
    400                 f = file("env_tex", "w")
     400                f = open("env_tex", "w")
    401401                f.write("TEXINPUTS=%s\nexport TEXINPUTS\n" % \
    402402                        os.environ["TEXINPUTS"])
    403403                f.close()
    404404            else:
    405                 f = file("env_tex.bat", "w")
     405                f = open("env_tex.bat", "w")
    406406                f.write("set TEXINPUTS=%s\n" % os.environ["TEXINPUTS"])
    407407                f.close()
    408408