Ticket #61530: Python2-3_patches.2.diff
File Python2-3_patches.2.diff, 34.3 KB (added by ballapete (Peter "Pete" Dyballa), 4 years ago) |
---|
-
setup.py
83 83 self._catalogs = install.catalogs 84 84 self._style = install.style 85 85 self._use_py_path = install.use_python_path 86 print self._package_base86 print(self._package_base) 87 87 88 88 # Build the command line script 89 89 self.build_script() … … 162 162 script = self.SHELL_SCRIPT % script_args 163 163 script_name = os.path.basename(script_name) 164 164 outfile = os.path.join(self.build_dir, script_name) 165 fd = os.open(outfile, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0 755)165 fd = os.open(outfile, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0o755) 166 166 os.write(fd, script) 167 167 os.close(fd) 168 168 … … 260 260 # First, check non critical graphic tools 261 261 found, missed = find_programs(("epstopdf", "convert", "fig2dev")) 262 262 for util in found: 263 print "+checking %s... yes" % util263 print("+checking %s... yes" % util) 264 264 for util in missed: 265 print "+checking %s... no" % util265 print("+checking %s... no" % util) 266 266 if missed: 267 print( "warning: not found: %s" % ", ".join(missed))267 print(("warning: not found: %s" % ", ".join(missed))) 268 268 269 269 # Now, be serious 270 270 found, missed = find_programs(("latex", "makeindex", 271 271 "pdflatex", "kpsewhich")) 272 272 for util in found: 273 print "+checking %s... yes" % util273 print("+checking %s... yes" % util) 274 274 for util in missed: 275 print "+checking %s... no" % util275 print("+checking %s... no" % util) 276 276 if missed: 277 277 raise OSError("not found: %s" % ", ".join(missed)) 278 278 … … 292 292 for (mod, deplist) in deplists: 293 293 if not(deplist): 294 294 xslt_found.append(mod) 295 print "+checking XSLT %s... yes" % mod295 print("+checking XSLT %s... yes" % mod) 296 296 continue 297 297 found, missed = find_programs(deplist) 298 298 if missed: 299 299 xslt_missed.append(mod) 300 print 301 (mod, ", ".join(missed)) 300 print("+checking XSLT %s... no (missing %s)" % \ 301 (mod, ", ".join(missed))) 302 302 else: 303 303 xslt_found.append(mod) 304 print "+checking XSLT %s... yes" % mod304 print("+checking XSLT %s... yes" % mod) 305 305 306 306 if not(xslt_found): 307 307 raise OSError("XSLT not installed: %s" % ", ".join(xslt_missed)) 308 308 elif xslt_missed: 309 print "warning: XSLT not found: %s" % ", ".join(xslt_missed)309 print("warning: XSLT not found: %s" % ", ".join(xslt_missed)) 310 310 311 311 def check_latex_dependencies(self): 312 312 # Find the Latex files from the package … … 353 353 if sty in own_stys: 354 354 status += "found in package" 355 355 found_stys.append(sty) 356 print status356 print(status) 357 357 continue 358 358 stypath = kpsewhich("%s.sty" % sty) 359 359 if stypath: … … 362 362 else: 363 363 status += "no" 364 364 mis_stys.append(sty) 365 print status365 print(status) 366 366 367 367 if mis_stys: 368 368 raise OSError("not found: %s" % ", ".join(mis_stys)) … … 378 378 self.check_xslt_dependencies() 379 379 self.check_util_dependencies() 380 380 self.check_latex_dependencies() 381 except Exception ,e:382 print >>sys.stderr, "Error: %s" % e381 except Exception as e: 382 print("Error: %s" % e, file=sys.stderr) 383 383 sys.exit(1) 384 384 385 385 if db: db.adapt_paths() -
lib/dbtexmf/core/dbtex.py
8 8 import shlex 9 9 import tempfile 10 10 import shutil 11 import urllib 11 import urllib.request, urllib.parse, urllib.error 12 12 import glob 13 13 import imp 14 14 from optparse import OptionParser … … 29 29 30 30 def path_to_uri(path): 31 31 if os.name == 'nt': 32 return 'file:' + urllib. pathname2url(path).replace('|', ':', 1)32 return 'file:' + urllib.request.pathname2url(path).replace('|', ':', 1) 33 33 else: 34 return urllib. pathname2url(path)34 return urllib.request.pathname2url(path) 35 35 36 36 37 37 class Document: … … 395 395 self.update_texinputs() 396 396 397 397 # For easy debug 398 if self.debug and os.environ.has_key("TEXINPUTS"):398 if self.debug and "TEXINPUTS" in os.environ: 399 399 if os.name != "nt": 400 400 f = file("env_tex", "w") 401 401 f.write("TEXINPUTS=%s\nexport TEXINPUTS\n" % \ … … 544 544 if options.format: 545 545 try: 546 546 run.set_format(options.format) 547 except Exception ,e:547 except Exception as e: 548 548 failed_exit("Error: %s" % e) 549 549 550 550 # Always set the XSLT (default or not) 551 551 try: 552 552 run.set_xslt(options.xslt) 553 except Exception ,e:553 except Exception as e: 554 554 failed_exit("Error: %s" % e) 555 555 556 556 if options.xslopts: … … 575 575 if options.texstyle: 576 576 try: 577 577 xslparam, texpath = texstyle_parse(options.texstyle) 578 except Exception ,e:578 except Exception as e: 579 579 failed_exit("Error: %s" % e) 580 580 run.xslparams.append(xslparam) 581 581 if texpath: run.texinputs.append(texpath) … … 630 630 if not(os.path.exists(options.tmpdir)): 631 631 try: 632 632 os.mkdir(options.tmpdir) 633 except Exception ,e:633 except Exception as e: 634 634 failed_exit("Error: %s" % e) 635 635 run.tmpdir_user = os.path.abspath(options.tmpdir) 636 636 … … 665 665 666 666 if options.version: 667 667 version = run.get_version() 668 print "%s version %s" % (self.prog, version)668 print("%s version %s" % (self.prog, version)) 669 669 if not(args): 670 670 sys.exit(0) 671 671 … … 682 682 try: 683 683 conf.paths = self.get_config_paths() 684 684 conf.fromstyle(options.style) 685 except Exception ,e:685 except Exception as e: 686 686 failed_exit("Error: %s" % e) 687 687 688 688 if options.config: 689 689 try: 690 690 for config in options.config: 691 691 conf.fromfile(config) 692 except Exception ,e:692 except Exception as e: 693 693 failed_exit("Error: %s" % e) 694 694 695 695 if conf.options: … … 735 735 # Try to buid the file 736 736 try: 737 737 run.compile() 738 except Exception ,e:738 except Exception as e: 739 739 signal_error(self, e) 740 740 failed_exit("Error: %s" % e) 741 741 -
lib/dbtexmf/core/confparser.py
1 1 import os 2 2 import sys 3 3 from xml.etree.ElementTree import ParseError 4 from xmlparser import XmlConfig5 from txtparser import TextConfig6 from imagedata import ImageConverterPool, ImageConverter7 from imagedata import ImageFormatPool, FormatRule8 from imagedata import image_setup4 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 9 9 from dbtexmf.xslt.xsltconf import XsltCommandPool, XsltEngine 10 10 from dbtexmf.xslt import xslt_setup 11 11 … … 76 76 self.style_exts = ["", ".xml", ".specs", ".conf"] 77 77 78 78 def warn(self, text): 79 print >>sys.stderr, text79 print(text, file=sys.stderr) 80 80 81 81 def fromfile(self, filename): 82 82 try: 83 83 self.fromxmlfile(filename) 84 except ParseError ,e:84 except ParseError as e: 85 85 self.warn("Text configuration files are deprecated. "\ 86 86 "Use the XML format instead") 87 87 self.fromtxtfile(filename) 88 except Exception ,e:88 except Exception as e: 89 89 raise e 90 90 91 91 def fromxmlfile(self, filename): -
lib/dbtexmf/core/xmlparser.py
1 1 import os 2 2 import re 3 3 import xml.etree.ElementTree as ET 4 from txtparser import texinputs_parse4 from .txtparser import texinputs_parse 5 5 6 6 class BaseOption: 7 7 def __init__(self, config, optname): … … 207 207 208 208 def options(self): 209 209 opts = [] 210 for parsers in self.infos.values():210 for parsers in list(self.infos.values()): 211 211 for parser in parsers: 212 212 opts.extend(parser.options()) 213 213 return opts 214 214 215 215 def modules(self): 216 216 mods = {} 217 for parsers in self.infos.values():217 for parsers in list(self.infos.values()): 218 218 for parser in parsers: 219 219 mods.update(parser.modules()) 220 220 return mods … … 282 282 283 283 def options(self): 284 284 opts = [] 285 for parser in self.infos.values():285 for parser in list(self.infos.values()): 286 286 opts.extend(parser.options()) 287 287 return opts 288 288 289 289 def modules(self): 290 290 mods = {} 291 for parser in self.infos.values():291 for parser in list(self.infos.values()): 292 292 mods.update(parser.modules()) 293 293 return mods 294 294 -
lib/dbtexmf/core/imagedata.py
3 3 import re 4 4 import shutil 5 5 import logging 6 import urllib 6 import urllib.request, urllib.parse, urllib.error 7 7 from dbtexmf.core.error import signal_error 8 from commander import CommandRunner8 from .commander import CommandRunner 9 9 10 10 class ObjectFilter: 11 11 """ … … 26 26 return "("+searched+")" 27 27 28 28 def select(self, object_list, **filter_criterions): 29 for criterion, value in filter_criterions.items():29 for criterion, value in list(filter_criterions.items()): 30 30 filter_criterions[criterion] = self._re_multi_or_star(value) 31 31 32 32 founds = [] 33 33 for obj in object_list: 34 34 object_criterions = obj.criterions() 35 for criterion, re_expr in filter_criterions.items():35 for criterion, re_expr in list(filter_criterions.items()): 36 36 data = object_criterions.get(criterion, "") 37 37 m = re.search(re_expr, data) 38 38 #print "Lookup2:", criterion, re_expr, data, not(m is None) … … 259 259 260 260 def convert(self, fig): 261 261 # Translate the URL to an actual local path 262 fig = urllib. url2pathname(fig)262 fig = urllib.request.url2pathname(fig) 263 263 264 264 # Always use '/' in path: work even on windows and is required by tex 265 265 if os.path.sep != '/': fig = fig.replace(os.path.sep, '/') … … 273 273 return fig 274 274 275 275 # Check if this image has been already converted 276 if self.converted.has_key(realfig):276 if realfig in self.converted: 277 277 self.log.info("Image '%s' already converted as %s" % \ 278 278 (fig, self.converted[realfig])) 279 279 return self.converted[realfig] -
lib/dbtexmf/dblatex/dblatex.py
7 7 from dbtexmf.core.sgmlxml import Osx 8 8 from dbtexmf.core.dbtex import DbTex, DbTexCommand 9 9 10 from rawtex import RawLatex11 from runtex import RunLatex10 from .rawtex import RawLatex 11 from .runtex import RunLatex 12 12 13 13 14 14 class DbLatex(DbTex): -
lib/dbtexmf/dblatex/rawtex.py
8 8 import os 9 9 import re 10 10 11 from rawparse import RawLatexParser, RawUtfParser12 from rawverb import VerbParser13 from rawlabel import RawLabelParser14 from xetex.codec import XetexCodec11 from .rawparse import RawLatexParser, RawUtfParser 12 from .rawverb import VerbParser 13 from .rawlabel import RawLabelParser 14 from .xetex.codec import XetexCodec 15 15 from dbtexmf.core.imagedata import * 16 16 17 17 -
lib/dbtexmf/dblatex/rawparse.py
1 1 import re 2 2 3 from texcodec import LatexCodec, TexCodec4 from texhyphen import BasicHyphenator, UrlHyphenator3 from .texcodec import LatexCodec, TexCodec 4 from .texhyphen import BasicHyphenator, UrlHyphenator 5 5 6 6 7 7 def utf8(u): … … 16 16 17 17 class RawLatexParser: 18 18 def __init__(self, 19 key_in=utf8( u"\u0370t"), key_out=utf8(u"\u0371t"),19 key_in=utf8("\u0370t"), key_out=utf8("\u0371t"), 20 20 codec=None, output_encoding="latin-1"): 21 21 self.key_in = RawKey(key_in, 1) 22 22 self.key_out = RawKey(key_out, -1) … … 27 27 self.hyphenator = UrlHyphenator(codec=self.codec) 28 28 29 29 # 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")) 32 32 33 33 def parse(self, line): 34 34 lout = "" … … 79 79 80 80 def __init__(self, codec=None, output_encoding="latin-1"): 81 81 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"), 83 83 texcodec) 84 84 85 85 def translate(self, text): -
lib/dbtexmf/dblatex/texcodec.py
4 4 # 5 5 import re 6 6 import codecs 7 import unient7 from . import unient 8 8 9 9 # Dictionnary of the handlers installed 10 10 tex_handler_installed = {} … … 21 21 try: 22 22 l.append(unient.unicode_map[ord(c)]) 23 23 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)) 26 26 if post: l.append(post) 27 27 n = n + 1 28 28 tex_handler_counter[name] = n 29 return ( u"".join(l), exc.end)29 return ("".join(l), exc.end) 30 30 31 31 32 32 class TexCodec: … … 63 63 self.charmap = {} 64 64 return 65 65 66 if not( tex_handler_installed.has_key(self._errors)):66 if not(self._errors in tex_handler_installed): 67 67 f = self.build_error_func(pre, post, errors) 68 68 codecs.register_error(self._errors, f) 69 69 tex_handler_installed[self._errors] = f … … 83 83 84 84 def encode(self, text): 85 85 text = self._encode(text, self._errors)[0] 86 for c, v in self.charmap.items():86 for c, v in list(self.charmap.items()): 87 87 text = text.replace(c, v) 88 88 return text 89 89 … … 120 120 text = self._encode(text, self._errors)[0] 121 121 122 122 # Special Character Mapping 123 for c, v in self.charmap.items():123 for c, v in list(self.charmap.items()): 124 124 text = text.replace(c, v) 125 125 126 126 # Things are done, complete with {} -
lib/dbtexmf/dblatex/texhyphen.py
96 96 url = "http://www.fg/foobar fun#fght/fkkkf.tz?id=123" 97 97 h1 = BasicHyphenator() 98 98 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
11 11 # 12 12 import re 13 13 14 from texcodec import TexCodec15 from texcodec import tex_handler_counter16 from rawparse import RawUtfParser14 from .texcodec import TexCodec 15 from .texcodec import tex_handler_counter 16 from .rawparse import RawUtfParser 17 17 18 18 19 19 class VerbCodec(TexCodec): -
lib/dbtexmf/dblatex/rawlabel.py
1 from texcodec import TexCodec2 from texcodec import tex_handler_counter3 from rawparse import RawLatexParser, utf81 from .texcodec import TexCodec 2 from .texcodec import tex_handler_counter 3 from .rawparse import RawLatexParser, utf8 4 4 5 5 6 6 def label_char_replace(exc, pre, post, errors): … … 16 16 if post: l.append(post) 17 17 n = n + 1 18 18 tex_handler_counter[errors] = n 19 return ( u"".join(l), exc.end)19 return ("".join(l), exc.end) 20 20 21 21 22 22 class LabelCodec(TexCodec): … … 60 60 """ 61 61 def __init__(self, codec=None, output_encoding="latin-1"): 62 62 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"), 64 64 texcodec) 65 65 66 66 def translate(self, text): -
lib/dbtexmf/dblatex/xetex/codec.py
3 3 import codecs 4 4 5 5 from dbtexmf.dblatex.texcodec import LatexCodec 6 from fsencoder import FontSpecEncoder6 from .fsencoder import FontSpecEncoder 7 7 8 8 9 9 class XetexCodec(LatexCodec): -
lib/dbtexmf/dblatex/xetex/fsencoder.py
11 11 import re 12 12 import xml.dom.minidom 13 13 14 from fontspec import UnicodeInterval15 from fsconfig import FontSpecConfig14 from .fontspec import UnicodeInterval 15 from .fsconfig import FontSpecConfig 16 16 17 17 18 18 class FontSpecEncoder: … … 68 68 """ 69 69 fontspec = self._cur_fontspec or self._conf.default_fontspec 70 70 71 print >>sys.stderr, "Current:", fontspec.id71 print("Current:", fontspec.id, file=sys.stderr) 72 72 fontspec = fontspec.match(char) 73 73 while not(fontspec): 74 74 leaf = self._ref_stack.pop() -
lib/dbtexmf/dblatex/xetex/fontspec.py
49 49 if m: 50 50 return int(m.group(1), 16) 51 51 else: 52 raise RuntimeError , 'Not a unicode codepoint: ' + codepoint52 raise RuntimeError('Not a unicode codepoint: ' + codepoint) 53 53 54 54 def from_char(self, char): 55 55 """Interval for a single character""" … … 167 167 intervals.append( 168 168 UnicodeInterval().from_codepoint(m.group(1))) 169 169 else: 170 raise RuntimeError , 'Unable to parse range: "' + range + '"'170 raise RuntimeError('Unable to parse range: "' + range + '"') 171 171 return intervals 172 172 173 173 def _parse_transitions(self, node, transition_type): … … 194 194 specified font types. 195 195 """ 196 196 s = '' 197 for type, font in fonts.items():197 for type, font in list(fonts.items()): 198 198 s += '\switch%sfont{%s}' % (type, font) 199 199 if s: 200 200 s = r"\savefamily" + s + r"\loadfamily{}" -
lib/dbtexmf/dblatex/xetex/fsconfig.py
12 12 import xml.dom.minidom 13 13 import logging 14 14 15 from fcfallback import FcFallbackFontSpec, DefaultFontSpec16 from fontspec import FontSpec, _indent15 from .fcfallback import FcFallbackFontSpec, DefaultFontSpec 16 from .fontspec import FontSpec, _indent 17 17 18 18 19 19 class FontSpecConfig: -
lib/dbtexmf/dblatex/xetex/fcfallback.py
1 from fontspec import FontSpec2 from fcmanager import FcManager1 from .fontspec import FontSpec 2 from .fcmanager import FcManager 3 3 4 4 5 5 class DefaultFontSpec(FontSpec): … … 54 54 for fontspec in self.fontspecs: 55 55 56 56 if fontspec in self.fcmissed: 57 print 58 (fontspec.mainfont()) 57 print("Specified font '%s' is missing in the system!" % \ 58 (fontspec.mainfont())) 59 59 continue 60 60 61 61 fcfont = self.fccache.get(fontspec.mainfont()) or \ … … 97 97 fontspec.add_char(char) 98 98 fontspec.add_ignored(self._ignored) 99 99 # Register the font and its related fontconfig object 100 for fcfont in fcfonts.values():100 for fcfont in list(fcfonts.values()): 101 101 self.fccache[fcfont.name] = fcfont 102 102 self.add_subfont(fontspec) 103 103 return fontspec -
lib/dbtexmf/dblatex/runtex.py
5 5 import re 6 6 import shutil 7 7 8 from grubber.texbuilder import LatexBuilder8 from .grubber.texbuilder import LatexBuilder 9 9 10 10 11 11 class RunLatex: -
lib/dbtexmf/dblatex/grubber/texbuilder.py
9 9 import subprocess 10 10 import os 11 11 import shlex 12 from msg import _, msg13 from maker import Maker14 from latex import Latex12 from .msg import _, msg 13 from .maker import Maker 14 from .latex import Latex 15 15 16 16 17 17 class IndexBuilder: … … 90 90 self.tex.prepare() 91 91 92 92 # Set the index configuration 93 if self.tex.modules.has_key("makeidx"):93 if "makeidx" in self.tex.modules: 94 94 idx = self.tex.modules["makeidx"] 95 95 if self.index.style: idx.do_style(self.index.style) 96 96 if self.index.tool: idx.do_tool(self.index.tool) -
lib/dbtexmf/dblatex/grubber/msg.py
37 37 self.stdout = None 38 38 39 39 def write_stdout(self, text, level=0): 40 print text40 print(text) 41 41 def write_stderr(self, text, level=0): 42 print >>sys.stderr, text42 print(text, file=sys.stderr) 43 43 44 44 def push_pos (self, pos): 45 45 self.pos.append(pos) … … 66 66 if text[0:13] == "LaTeX Error: ": 67 67 text = text[13:] 68 68 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: 70 70 self._log.error(self.format_pos(info, 71 71 _("leading text: ") + info["code"])) 72 72 … … 100 100 the dictionary given as first argument. 101 101 """ 102 102 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: 104 104 where = self.pos[-1] 105 105 elif where is None or where == {}: 106 106 return text 107 107 108 if where.has_key("file")and where["file"] is not None:108 if "file" in where and where["file"] is not None: 109 109 pos = self.simplify(where["file"]) 110 if where.has_key("line")and where["line"]:110 if "line" in where and where["line"]: 111 111 pos = "%s:%d" % (pos, int(where["line"])) 112 if where.has_key("last"):112 if "last" in where: 113 113 if where["last"] != where["line"]: 114 114 pos = "%s-%d" % (pos, int(where["last"])) 115 115 pos = pos + ": " 116 116 else: 117 117 pos = "" 118 if where.has_key("page"):118 if "page" in where: 119 119 text = "%s (page %d)" % (text, int(where["page"])) 120 if where.has_key("pkg"):120 if "pkg" in where: 121 121 text = "[%s] %s" % (where["pkg"], text) 122 122 return pos + text 123 123 -
lib/dbtexmf/dblatex/grubber/maker.py
8 8 import time 9 9 import subprocess 10 10 11 from msg import _, msg11 from .msg import _, msg 12 12 13 13 class Depend (object): #{{{2 14 14 """ … … 51 51 # We set the node's date to that of the most recently modified 52 52 # product file, assuming all other files were up to date then 53 53 # (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))) 55 55 except OSError: 56 56 # If some product file does not exist, set the last 57 57 # modification date to None. … … 64 64 """ 65 65 if not self.date: 66 66 return 1 67 for src in self.sources.values():67 for src in list(self.sources.values()): 68 68 if src.date > self.date: 69 69 return 1 70 70 return 0 … … 81 81 on this one have to be remade) 82 82 """ 83 83 if self.making: 84 print "FIXME: cyclic make"84 print("FIXME: cyclic make") 85 85 return 1 86 86 self.making = 1 87 87 88 88 # Make the sources 89 89 self.failed_dep = None 90 90 must_make = force 91 for src in self.sources.values():91 for src in list(self.sources.values()): 92 92 ret = src.make() 93 93 if ret == 0: 94 94 self.making = 0 … … 152 152 if os.path.exists(file): 153 153 msg.log(_("removing %s") % file) 154 154 os.unlink(file) 155 for src in self.sources.values():155 for src in list(self.sources.values()): 156 156 src.clean() 157 157 self.date = None 158 158 … … 170 170 if self.sources == {}: 171 171 return self.prods 172 172 ret = [] 173 for dep in self.sources.values():173 for dep in list(self.sources.values()): 174 174 ret.extend(dep.leaves()) 175 175 return ret 176 176 -
lib/dbtexmf/dblatex/grubber/latex.py
11 11 import time 12 12 import subprocess 13 13 14 from msg import _, msg15 from util import Watcher16 from logparser import LogParser17 from texparser import TexParser18 from plugins import Modules19 from maker import Depend14 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 20 20 21 21 22 22 class Latex(Depend): … … 175 175 self.watcher.watch(self.srcbase + "." + ext) 176 176 177 177 msg.log(_("building additional files...")) 178 for mod in self.modules.objects.values():178 for mod in list(self.modules.objects.values()): 179 179 if mod.pre_compile(): 180 180 self.failed_module = mod 181 181 return 1 … … 188 188 """ 189 189 msg.log(_("running post-compilation scripts...")) 190 190 191 for mod in self.modules.objects.values():191 for mod in list(self.modules.objects.values()): 192 192 if mod.post_compile(): 193 193 self.failed_module = mod 194 194 return 1 … … 201 201 """ 202 202 msg.log(_("running last-compilation scripts...")) 203 203 204 for mod in self.modules.objects.values():204 for mod in list(self.modules.objects.values()): 205 205 if mod.last_compile(): 206 206 self.failed_module = mod 207 207 return 1 … … 233 233 # for dep in self.sources.values(): 234 234 # dep.clean() 235 235 236 for mod in self.modules.objects.values():236 for mod in list(self.modules.objects.values()): 237 237 mod.clean() 238 238 239 239 def remove_suffixes (self, list): -
lib/dbtexmf/dblatex/grubber/util.py
11 11 # Fallback for python 2.4: 12 12 import md5 as hashlib 13 13 import os 14 from msg import _, msg14 from .msg import _, msg 15 15 16 16 17 17 def md5_file(fname): … … 45 45 of the files that changed, or None of they didn't change. 46 46 """ 47 47 changed = [] 48 for file in self.files.keys():48 for file in list(self.files.keys()): 49 49 if os.path.exists(file): 50 50 new = md5_file(file) 51 51 if self.files[file] != new: -
lib/dbtexmf/dblatex/grubber/logparser.py
5 5 6 6 This module defines the class that parses the LaTeX log files. 7 7 """ 8 from __future__ import generators 8 9 9 10 10 import re 11 11 12 from msg import _, msg12 from .msg import _, msg 13 13 14 14 class LogParser: 15 15 """ … … 188 188 m = self.re_ignored.search(error) 189 189 if m: 190 190 d["file"] = last_file 191 if d.has_key("code"):191 if "code" in d: 192 192 del d["code"] 193 193 d.update( m.groupdict() ) 194 194 elif pos[-1] is None: -
lib/dbtexmf/dblatex/grubber/plugins.py
7 7 import imp 8 8 9 9 from os.path import * 10 from msg import _, msg10 from .msg import _, msg 11 11 12 12 import sys 13 13 … … 106 106 dictionary. Return 0 if no module was found, 1 if a module was found 107 107 and loaded, and 2 if the module was found but already loaded. 108 108 """ 109 if self.modules.has_key(name):109 if name in self.modules: 110 110 return 2 111 111 try: 112 112 file, path, descr = imp.find_module(name, [""]) … … 155 155 """ 156 156 Check if a given module is loaded. 157 157 """ 158 return self.objects.has_key(name)158 return name in self.objects 159 159 160 160 def register (self, name, dict={}): 161 161 """ … … 165 165 delayed commands for this module. The dictionary describes the 166 166 command that caused the registration. 167 167 """ 168 if self.has_key(name):168 if name in self: 169 169 msg.debug(_("module %s already registered") % name) 170 170 return 2 171 171 … … 191 191 192 192 # Run any delayed commands. 193 193 194 if self.commands.has_key(name):194 if name in self.commands: 195 195 for (cmd, args, vars) in self.commands[name]: 196 196 msg.push_pos(vars) 197 197 try: … … 219 219 Send a command to a particular module. If this module is not loaded, 220 220 store the command so that it will be sent when the module is register. 221 221 """ 222 if self.objects.has_key(mod):222 if mod in self.objects: 223 223 self.objects[mod].command(cmd, args) 224 224 else: 225 if not self.commands.has_key(mod):225 if mod not in self.commands: 226 226 self.commands[mod] = [] 227 227 self.commands[mod].append((cmd, args, self.env.vars.copy())) 228 228 -
lib/dbtexmf/core/dbtex.py
183 183 self.flags &= ~what 184 184 185 185 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")) 187 187 versions = re.findall("<xsl:variable[^>]*>([^<]*)<", f.read()) 188 188 f.close() 189 189 if versions: … … 196 196 self.xslbuild = self.xslmain 197 197 return 198 198 199 f = file(wrapper, "w")199 f = open(wrapper, "w") 200 200 f.write(self.xsl_header) 201 201 f.write('<xsl:import href="%s"/>\n' % path_to_uri(self.xslmain)) 202 202 for xsluser in self.xslusers: … … 231 231 self.listings, opts=self.xslopts, params=param) 232 232 else: 233 233 self.log.info("No external file support") 234 f = file(self.listings, "w")234 f = open(self.listings, "w") 235 235 f.write("<listings/>\n") 236 236 f.close() 237 237 … … 268 268 # set list 269 269 self.log.info("Build the book set list...") 270 270 xslset = "doclist.xsl" 271 f = file(xslset, "w")271 f = open(xslset, "w") 272 272 f.write(self.xsl_header) 273 273 f.write('<xsl:import href="%s"/>\n' % path_to_uri(self.xslbuild)) 274 274 f.write('<xsl:import href="%s"/>\n' % path_to_uri(self.xslset)) … … 397 397 # For easy debug 398 398 if self.debug and "TEXINPUTS" in os.environ: 399 399 if os.name != "nt": 400 f = file("env_tex", "w")400 f = open("env_tex", "w") 401 401 f.write("TEXINPUTS=%s\nexport TEXINPUTS\n" % \ 402 402 os.environ["TEXINPUTS"]) 403 403 f.close() 404 404 else: 405 f = file("env_tex.bat", "w")405 f = open("env_tex.bat", "w") 406 406 f.write("set TEXINPUTS=%s\n" % os.environ["TEXINPUTS"]) 407 407 f.close() 408 408 -
lib/contrib/which/which.py
old new 90 90 if sys.platform.startswith('win'): 91 91 if os.path.splitext(exeName)[1].lower() != '.exe': 92 92 exeName += '.exe' 93 import _winreg93 import winreg 94 94 try: 95 95 key = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" +\ 96 96 exeName 97 value = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, key)97 value = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, key) 98 98 registered = (value, "from HKLM\\"+key) 99 except _winreg.error:99 except winreg.error: 100 100 pass 101 101 if registered and not os.path.exists(registered[0]): 102 102 registered = None … … 243 243 If no match is found for the command, a WhichError is raised. 244 244 """ 245 245 try: 246 match = whichgen(command, path, verbose, exts).next()246 match = next(whichgen(command, path, verbose, exts)) 247 247 except StopIteration: 248 248 raise WhichError("Could not find '%s' on the path." % command) 249 249 return match … … 278 278 altpath = None 279 279 exts = None 280 280 try: 281 opt list, args = getopt.getopt(argv[1:], 'haVvqp:e:',281 opts, args = getopt.getopt(argv[1:], 'haVvqp:e:', 282 282 ['help', 'all', 'version', 'verbose', 'quiet', 'path=', 'exts=']) 283 except getopt.GetoptError ,msg:283 except getopt.GetoptError as msg: 284 284 sys.stderr.write("which: error: %s. Your invocation was: %s\n"\ 285 285 % (msg, argv)) 286 286 sys.stderr.write("Try 'which --help'.\n") 287 287 return 1 288 288 for opt, optarg in optlist: 289 289 if opt in ('-h', '--help'): 290 print _cmdlnUsage290 print(_cmdlnUsage) 291 291 return 0 292 292 elif opt in ('-V', '--version'): 293 print "which %s" % __version__293 print("which %s" % __version__) 294 294 return 0 295 295 elif opt in ('-a', '--all'): 296 296 all = 1 … … 318 318 nmatches = 0 319 319 for match in whichgen(arg, path=altpath, verbose=verbose, exts=exts): 320 320 if verbose: 321 print "%s (%s)" % match321 print("%s (%s)" % match) 322 322 else: 323 print match323 print(match) 324 324 nmatches += 1 325 325 if not all: 326 326 break