<86>May 7 09:26:17 userdel[2518549]: delete user 'rooter' <86>May 7 09:26:17 userdel[2518549]: removed group 'rooter' owned by 'rooter' <86>May 7 09:26:17 userdel[2518549]: removed shadow group 'rooter' owned by 'rooter' <86>May 7 09:26:17 groupadd[2518577]: group added to /etc/group: name=rooter, GID=1350 <86>May 7 09:26:17 groupadd[2518577]: group added to /etc/gshadow: name=rooter <86>May 7 09:26:17 groupadd[2518577]: new group: name=rooter, GID=1350 <86>May 7 09:26:17 useradd[2518593]: new user: name=rooter, UID=1350, GID=1350, home=/root, shell=/bin/bash <86>May 7 09:26:17 userdel[2518629]: delete user 'builder' <86>May 7 09:26:17 userdel[2518629]: removed group 'builder' owned by 'builder' <86>May 7 09:26:17 groupadd[2518677]: group added to /etc/group: name=builder, GID=1351 <86>May 7 09:26:17 groupadd[2518677]: group added to /etc/gshadow: name=builder <86>May 7 09:26:17 groupadd[2518677]: new group: name=builder, GID=1351 <86>May 7 09:26:17 useradd[2518706]: new user: name=builder, UID=1351, GID=1351, home=/usr/src, shell=/bin/bash <13>May 7 09:26:19 rpmi: libgdbm-1.8.3-alt10 1454943313 installed <13>May 7 09:26:19 rpmi: libexpat-2.4.3-alt1 p9+293696.100.1.1 1643124786 installed <13>May 7 09:26:19 rpmi: libp11-kit-0.23.15-alt2 p9+254920.2400.19.1 1601385869 installed <13>May 7 09:26:19 rpmi: libtasn1-4.14-alt1 p9+235792.100.2.1 1565425233 installed <13>May 7 09:26:19 rpmi: rpm-macros-alternatives-0.5.1-alt1 sisyphus+226946.100.1.1 1554830426 installed <13>May 7 09:26:19 rpmi: alternatives-0.5.1-alt1 sisyphus+226946.100.1.1 1554830426 installed <13>May 7 09:26:19 rpmi: ca-certificates-2021.10.06-alt1 p9+289862.100.1.1 1637033643 installed <13>May 7 09:26:19 rpmi: ca-trust-0.1.2-alt1 p9+233349.100.1.1 1561655062 installed <13>May 7 09:26:19 rpmi: p11-kit-trust-0.23.15-alt2 p9+254920.2400.19.1 1601385869 installed <13>May 7 09:26:19 rpmi: libcrypto1.1-1.1.1t-alt1 p9+314826.100.5.1 1676897865 installed <13>May 7 09:26:19 rpmi: libssl1.1-1.1.1t-alt1 p9+314826.100.5.1 1676897865 installed <13>May 7 09:26:19 rpmi: python3-3.7.11-alt1 p9+273501.10.37.1 1629720188 installed <13>May 7 09:26:19 rpmi: libpython3-3.7.11-alt1 p9+273501.10.37.1 1629720188 installed <13>May 7 09:26:19 rpmi: python3-base-3.7.11-alt1 p9+273501.10.37.1 1629720188 installed <13>May 7 09:26:19 rpmi: tests-for-installed-python3-pkgs-0.1.13.1-alt2 1535450458 installed <13>May 7 09:26:19 rpmi: rpm-build-python3-0.1.13.1-alt2 1535450458 installed <13>May 7 09:26:21 rpmi: python3-module-pkg_resources-1:40.8.0-alt2 sisyphus+229158.200.2.1 1557735221 installed <13>May 7 09:26:21 rpmi: python-modules-curses-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: libtinfo-devel-6.1.20180407-alt2 sisyphus+222164.200.1.1 1550686221 installed <13>May 7 09:26:21 rpmi: libncurses-devel-6.1.20180407-alt2 sisyphus+222164.200.1.1 1550686221 installed <13>May 7 09:26:21 rpmi: python3-dev-3.7.11-alt1 p9+273501.10.37.1 1629720188 installed <13>May 7 09:26:21 rpmi: libverto-0.3.0-alt1_7 sisyphus+225932.100.1.1 1553994917 installed <13>May 7 09:26:21 rpmi: libkeyutils-1.6-alt2 sisyphus+226520.100.2.1 1554512088 installed <13>May 7 09:26:21 rpmi: libcom_err-1.44.6-alt1 sisyphus+224154.100.1.1 1552091653 installed <86>May 7 09:26:21 groupadd[2542604]: group added to /etc/group: name=_keytab, GID=499 <86>May 7 09:26:21 groupadd[2542604]: group added to /etc/gshadow: name=_keytab <86>May 7 09:26:21 groupadd[2542604]: new group: name=_keytab, GID=499 <13>May 7 09:26:21 rpmi: libkrb5-1.17.2-alt4 p9+310094.100.3.1 1669309764 installed <13>May 7 09:26:21 rpmi: libtirpc-1.0.3-alt1 1532008015 installed <13>May 7 09:26:21 rpmi: libnsl2-1.1.0-alt1_1 1511548748 installed <13>May 7 09:26:21 rpmi: python-modules-compiler-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-email-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-unittest-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-encodings-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-nis-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-ctypes-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-multiprocessing-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-logging-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-tools-2to3-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-xml-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-hotshot-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-bsddb-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-modules-distutils-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-module-pkg_resources-1:40.8.0-alt2 sisyphus+229158.200.2.1 1557735221 installed <13>May 7 09:26:21 rpmi: libnsl2-devel-1.1.0-alt1_1 1511548748 installed <13>May 7 09:26:21 rpmi: python-dev-2.7.16-alt1.M90P.2 p9+260393.40.3.1 1604003646 installed <13>May 7 09:26:21 rpmi: python-module-setuptools-1:40.8.0-alt2 sisyphus+229158.200.2.1 1557735221 installed <13>May 7 09:26:21 rpmi: python3-module-setuptools-1:40.8.0-alt2 sisyphus+229158.200.2.1 1557735221 installed Building target platforms: x86_64 Building for target x86_64 Wrote: /usr/src/in/nosrpm/python-module-xhtml2pdf-0.0.6-alt1.git20140628.2.nosrc.rpm (w1.gzdio) Installing python-module-xhtml2pdf-0.0.6-alt1.git20140628.2.src.rpm Building target platforms: x86_64 Building for target x86_64 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.75506 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + rm -rf python-module-xhtml2pdf-0.0.6 + echo 'Source #0 (python-module-xhtml2pdf-0.0.6.tar):' Source #0 (python-module-xhtml2pdf-0.0.6.tar): + /bin/tar -xf /usr/src/RPM/SOURCES/python-module-xhtml2pdf-0.0.6.tar + cd python-module-xhtml2pdf-0.0.6 + /bin/chmod -c -Rf u+rwX,go-w . + cp -fR . ../python3 + mv ../python3/test/witherror.py ../python3/test/witherror.bak ++ find ../python3 -type f -name '*.py' + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/xhtml2pdf_reportlab.py file: ../python3/xhtml2pdf/xhtml2pdf_reportlab.py + 2to3 -w -n ../python3/xhtml2pdf/xhtml2pdf_reportlab.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/xhtml2pdf_reportlab.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/xhtml2pdf_reportlab.py --- ../python3/xhtml2pdf/xhtml2pdf_reportlab.py (original) +++ ../python3/xhtml2pdf/xhtml2pdf_reportlab.py (refactored) @@ -27,7 +27,7 @@ from xhtml2pdf.reportlab_paragraph import Paragraph from xhtml2pdf.util import getUID, getBorderStyle from types import StringType, TupleType, ListType, IntType -import StringIO +import io import cgi import copy import logging @@ -224,7 +224,7 @@ if self.pisaBackground.mimetype.startswith("image/"): try: - img = PmlImageReader(StringIO.StringIO(self.pisaBackground.getData())) + img = PmlImageReader(io.StringIO(self.pisaBackground.getData())) iw, ih = img.getSize() pw, ph = canvas._pagesize @@ -316,7 +316,7 @@ else: try: self.fp = open_for_read(fileName, 'b') - if isinstance(self.fp, StringIO.StringIO().__class__): + if isinstance(self.fp, io.StringIO().__class__): imageReaderFlags = 0 # avoid messing with already internal files if imageReaderFlags > 0: # interning data = self.fp.read() @@ -332,7 +332,7 @@ data = self._cache.setdefault(md5(data).digest(), data) self.fp = getStringIO(data) - elif imageReaderFlags == - 1 and isinstance(fileName, (str, unicode)): + elif imageReaderFlags == - 1 and isinstance(fileName, str): #try Ralf Schmitt's re-opening technique of avoiding too many open files self.fp.close() del self.fp # will become a property in the next statement @@ -359,7 +359,7 @@ if hasattr(ev, 'args'): a = str(ev.args[- 1]) + (' fileName=%r' % fileName) ev.args = ev.args[: - 1] + (a,) - raise et, ev, tb + raise et(ev).with_traceback(tb) else: raise @@ -449,7 +449,7 @@ # 8-bit PNGs could give an empty string as transparency value, so # we have to be careful here. try: - return map(ord, palette[transparency:transparency + 3]) + return list(map(ord, palette[transparency:transparency + 3])) except: return None else: @@ -498,7 +498,7 @@ return self.dWidth, self.dHeight def getImage(self): - img = PmlImageReader(StringIO.StringIO(self._imgdata)) + img = PmlImageReader(io.StringIO(self._imgdata)) return img def draw(self): + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/wsgi.py file: ../python3/xhtml2pdf/wsgi.py + 2to3 -w -n ../python3/xhtml2pdf/wsgi.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/wsgi.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/wsgi.py --- ../python3/xhtml2pdf/wsgi.py (original) +++ ../python3/xhtml2pdf/wsgi.py (refactored) @@ -15,7 +15,7 @@ # limitations under the License. import xhtml2pdf.pisa as pisa -import StringIO +import io import logging @@ -31,7 +31,7 @@ script_name = environ.get('SCRIPT_NAME', '') path_info = environ.get('PATH_INFO', '') sent = [] - written_response = StringIO.StringIO() + written_response = io.StringIO() def replacement_start_response(status, headers, exc_info=None): if not self.should_filter(status, headers): @@ -77,7 +77,7 @@ def filter(self, script_name, path_info, environ, status, headers, body): topdf = environ.get("pisa.topdf", "") if topdf: - dst = StringIO.StringIO() + dst = io.StringIO() pisa.CreatePDF(body, dst, show_error_as_pdf=True) headers = [ ("content-type", "application/pdf"), + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/w3c/cssSpecial.py file: ../python3/xhtml2pdf/w3c/cssSpecial.py + 2to3 -w -n ../python3/xhtml2pdf/w3c/cssSpecial.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/w3c/cssSpecial.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/w3c/cssSpecial.py --- ../python3/xhtml2pdf/w3c/cssSpecial.py (original) +++ ../python3/xhtml2pdf/w3c/cssSpecial.py (refactored) @@ -45,7 +45,7 @@ def toList(value): - if type(value) != types.ListType: + if type(value) != list: return [value] return value @@ -156,7 +156,7 @@ def isSize(value): - return value and ((type(value) is types.TupleType) or value == "0") + return value and ((type(value) is tuple) or value == "0") def splitBorder(parts): @@ -250,7 +250,7 @@ if 0: part = getNextPart(parts) or oparts - print ("~", part, parts, oparts, declarations) + print(("~", part, parts, oparts, declarations)) # Color if part and (not part.startswith("url")): dd.append(("background-color", part, last)) @@ -414,8 +414,8 @@ log.debug("CSS special OUT:\n%s", "\n".join([repr(d) for d in dd])) if 0: #declarations!=dd: - print ("###", declarations) - print ("#->", dd) + print(("###", declarations)) + print(("#->", dd)) # CSS MODIFY! END return dd + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/w3c/cssParser.py file: ../python3/xhtml2pdf/w3c/cssParser.py + 2to3 -w -n ../python3/xhtml2pdf/w3c/cssParser.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/w3c/cssParser.py --- ../python3/xhtml2pdf/w3c/cssParser.py (original) +++ ../python3/xhtml2pdf/w3c/cssParser.py (refactored) @@ -33,7 +33,7 @@ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ import re -import cssSpecial +from . import cssSpecial #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~ Definitions @@ -327,9 +327,9 @@ _orRule = lambda *args: '|'.join(args) _reflags = re.I | re.M | re.U i_hex = '[0-9a-fA-F]' - i_nonascii = u'[\200-\377]' + i_nonascii = '[\200-\377]' i_unicode = '\\\\(?:%s){1,6}\s?' % i_hex - i_escape = _orRule(i_unicode, u'\\\\[ -~\200-\377]') + i_escape = _orRule(i_unicode, '\\\\[ -~\200-\377]') # i_nmstart = _orRule('[A-Za-z_]', i_nonascii, i_escape) i_nmstart = _orRule('\-[^0-9]|[A-Za-z_]', i_nonascii, i_escape) # XXX Added hyphen, http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier @@ -349,25 +349,25 @@ re_hash = re.compile(i_hash, _reflags) i_rgbcolor = '(#%s{6}|#%s{3})' % (i_hex, i_hex) re_rgbcolor = re.compile(i_rgbcolor, _reflags) - i_nl = u'\n|\r\n|\r|\f' - i_escape_nl = u'\\\\(?:%s)' % i_nl - i_string_content = _orRule(u'[\t !#$%&(-~]', i_escape_nl, i_nonascii, i_escape) - i_string1 = u'\"((?:%s|\')*)\"' % i_string_content - i_string2 = u'\'((?:%s|\")*)\'' % i_string_content + i_nl = '\n|\r\n|\r|\f' + i_escape_nl = '\\\\(?:%s)' % i_nl + i_string_content = _orRule('[\t !#$%&(-~]', i_escape_nl, i_nonascii, i_escape) + i_string1 = '\"((?:%s|\')*)\"' % i_string_content + i_string2 = '\'((?:%s|\")*)\'' % i_string_content i_string = _orRule(i_string1, i_string2) re_string = re.compile(i_string, _reflags) - i_uri = (u'url\\(\s*(?:(?:%s)|((?:%s)+))\s*\\)' + i_uri = ('url\\(\s*(?:(?:%s)|((?:%s)+))\s*\\)' % (i_string, _orRule('[!#$%&*-~]', i_nonascii, i_escape))) # XXX For now # i_uri = u'(url\\(.*?\\))' re_uri = re.compile(i_uri, _reflags) - i_num = u'(([-+]?[0-9]+(?:\\.[0-9]+)?)|([-+]?\\.[0-9]+))' # XXX Added out paranthesis, because e.g. .5em was not parsed correctly + i_num = '(([-+]?[0-9]+(?:\\.[0-9]+)?)|([-+]?\\.[0-9]+))' # XXX Added out paranthesis, because e.g. .5em was not parsed correctly re_num = re.compile(i_num, _reflags) i_unit = '(%%|%s)?' % i_ident re_unit = re.compile(i_unit, _reflags) i_function = i_ident + '\\(' re_function = re.compile(i_function, _reflags) - i_functionterm = u'[-+]?' + i_function + i_functionterm = '[-+]?' + i_function re_functionterm = re.compile(i_functionterm, _reflags) i_unicoderange1 = "(?:U\\+%s{1,6}-%s{1,6})" % (i_hex, i_hex) i_unicoderange2 = "(?:U\\+\?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h}))))))" @@ -376,9 +376,9 @@ # i_comment = u'(?:\/\*[^*]*\*+([^/*][^*]*\*+)*\/)|(?://.*)' # gabriel: only C convention for comments is allowed in CSS - i_comment = u'(?:\/\*[^*]*\*+([^/*][^*]*\*+)*\/)' + i_comment = '(?:\/\*[^*]*\*+([^/*][^*]*\*+)*\/)' re_comment = re.compile(i_comment, _reflags) - i_important = u'!\s*(important)' + i_important = '!\s*(important)' re_important = re.compile(i_important, _reflags) del _orRule @@ -471,7 +471,7 @@ try: properties = [] try: - for propertyName, src in kwAttributes.iteritems(): + for propertyName, src in kwAttributes.items(): src, property = self._parseDeclarationProperty(src.strip(), propertyName) properties.append(property) @@ -511,7 +511,7 @@ ; """ # Get rid of the comments - src = self.re_comment.sub(u'', src) + src = self.re_comment.sub('', src) # [ CHARSET_SYM S* STRING S* ';' ]? src = self._parseAtCharset(src) @@ -678,7 +678,7 @@ if medium is NonRefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/w3c/cssParser.py e: raise self.ParseError('@media rule expected media identifier', src, ctxsrc) # make "and ... {" work - if medium == u'and': + if medium == 'and': # strip up to curly bracket pattern = re.compile('.*({.*)') match = re.match(pattern, src) @@ -1168,7 +1168,7 @@ rexpression = self.re_string result = rexpression.match(src) if result: - strres = filter(None, result.groups()) + strres = [_f for _f in result.groups() if _f] if strres: strres = strres[0] else: + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py file: ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py + 2to3 -w -n ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py --- ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py (original) +++ ../python3/xhtml2pdf/w3c/cssDOMElementInterface.py (refactored) @@ -13,7 +13,7 @@ #~ Imports #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import css +from . import css #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~ Definitions + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/w3c/css.py file: ../python3/xhtml2pdf/w3c/css.py + 2to3 -w -n ../python3/xhtml2pdf/w3c/css.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/w3c/css.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/w3c/css.py --- ../python3/xhtml2pdf/w3c/css.py (original) +++ ../python3/xhtml2pdf/w3c/css.py (refactored) @@ -54,8 +54,8 @@ set except NameError: from sets import Set as set -import cssParser -import cssSpecial +from . import cssParser +from . import cssSpecial #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~ Constants / Variables / Etc. @@ -172,7 +172,7 @@ """ rules = self.findCSSRulesForEach(element, attrNames) return [(attrName, self._extractStyleForRule(rule, attrName, default)) - for attrName, rule in rules.iteritems()] + for attrName, rule in rules.items()] def findCSSRulesFor(self, element, attrName): @@ -211,10 +211,10 @@ inline = element.getInlineStyle() for ruleset in self.iterCSSRulesets(inline): - for attrName, attrRules in rules.iteritems(): + for attrName, attrRules in rules.items(): attrRules += ruleset.findCSSRuleFor(element, attrName) - for attrRules in rules.itervalues(): + for attrRules in rules.values(): attrRules.sort() return rules @@ -665,7 +665,7 @@ class CSSRuleset(dict): def findCSSRulesFor(self, element, attrName): - ruleResults = [(nodeFilter, declarations) for nodeFilter, declarations in self.iteritems() if + ruleResults = [(nodeFilter, declarations) for nodeFilter, declarations in self.items() if (attrName in declarations) and (nodeFilter.matches(element))] ruleResults.sort() return ruleResults @@ -679,7 +679,7 @@ def mergeStyles(self, styles): " XXX Bugfix for use in PISA " - for k, v in styles.iteritems(): + for k, v in styles.items(): if k in self and self[k]: self[k] = copy.copy(self[k]) self[k].update(v) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/w3c/__init__.py file: ../python3/xhtml2pdf/w3c/__init__.py + 2to3 -w -n ../python3/xhtml2pdf/w3c/__init__.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No files need to be modified. + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/version.py file: ../python3/xhtml2pdf/version.py + 2to3 -w -n ../python3/xhtml2pdf/version.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/xhtml2pdf/version.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/xhtml2pdf/version.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/util.py file: ../python3/xhtml2pdf/util.py + 2to3 -w -n ../python3/xhtml2pdf/util.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/util.py --- ../python3/xhtml2pdf/util.py (original) +++ ../python3/xhtml2pdf/util.py (refactored) @@ -4,7 +4,7 @@ from reportlab.lib.units import inch, cm import base64 try: - import httplib + import http.client except ImportError: import http.client as httplib import logging @@ -17,13 +17,13 @@ import sys import tempfile import types -import urllib +import urllib.request, urllib.parse, urllib.error try: - import urllib2 + import urllib.request, urllib.error, urllib.parse except ImportError: import urllib.request as urllib2 try: - import urlparse + import urllib.parse except ImportError: import urllib.parse as urlparse @@ -53,10 +53,10 @@ log = logging.getLogger("xhtml2pdf") try: - import cStringIO as io + import io as io except: try: - import StringIO as io + import io as io except ImportError: import io @@ -102,7 +102,7 @@ def __call__(self, *args, **kwargs): # Make sure the following line is not actually slower than what you're # trying to memoize - args_plus = tuple(kwargs.iteritems()) + args_plus = tuple(kwargs.items()) key = (args, args_plus) try: if key not in self.cache: @@ -131,7 +131,7 @@ def toList(value): - if type(value) not in (types.ListType, types.TupleType): + if type(value) not in (list, tuple): return [value] return list(value) @@ -223,11 +223,11 @@ original = value if value is None: return relative - elif type(value) is types.FloatType: + elif type(value) is float: return value elif isinstance(value, int): return float(value) - elif type(value) in (types.TupleType, types.ListType): + elif type(value) in (tuple, list): value = "".join(value) value = str(value).strip().lower().replace(",", ".") if value[-2:] == 'cm': @@ -545,17 +545,17 @@ else: # Check if we have an external scheme - if basepath and not urlparse.urlparse(uri).scheme: - urlParts = urlparse.urlparse(basepath) + if basepath and not urllib.parse.urlparse(uri).scheme: + urlParts = urllib.parse.urlparse(basepath) else: - urlParts = urlparse.urlparse(uri) + urlParts = urllib.parse.urlparse(uri) log.debug("URLParts: %r", urlParts) if urlParts.scheme == 'file': if basepath and uri.startswith('/'): - uri = urlparse.urljoin(basepath, uri[1:]) - urlResponse = urllib2.urlopen(uri) + uri = urllib.parse.urljoin(basepath, uri[1:]) + urlResponse = urllib.request.urlopen(uri) self.mimetype = urlResponse.info().get( "Content-Type", '').split(";")[0] self.uri = urlResponse.geturl() @@ -567,17 +567,17 @@ # External data if basepath: - uri = urlparse.urljoin(basepath, uri) + uri = urllib.parse.urljoin(basepath, uri) #path = urlparse.urlsplit(url)[2] #mimetype = getMimeType(path) # Using HTTPLIB - server, path = urllib.splithost(uri[uri.find("//"):]) + server, path = urllib.parse.splithost(uri[uri.find("//"):]) if uri.startswith("https://"): - conn = httplib.HTTPSConnection(server) + conn = http.client.HTTPSConnection(server) else: - conn = httplib.HTTPConnection(server) + conn = http.client.HTTPConnection(server) conn.request("GET", path) r1 = conn.getresponse() # log.debug("HTTP %r %r %r %r", server, path, uri, r1) @@ -588,10 +588,10 @@ if r1.getheader("content-encoding") == "gzip": import gzip RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/util.py try: - import cStringIO as io + import io as io except: try: - import StringIO as io + import io as io except ImportError: import io @@ -601,8 +601,8 @@ self.file = r1 else: try: - urlResponse = urllib2.urlopen(uri) - except urllib2.HTTPError: + urlResponse = urllib.request.urlopen(uri) + except urllib.error.HTTPError: return self.mimetype = urlResponse.info().get( "Content-Type", '').split(";")[0] + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/turbogears.py file: ../python3/xhtml2pdf/turbogears.py + 2to3 -w -n ../python3/xhtml2pdf/turbogears.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/turbogears.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/turbogears.py --- ../python3/xhtml2pdf/turbogears.py (original) +++ ../python3/xhtml2pdf/turbogears.py (refactored) @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from turbogears.decorator import weak_signature_decorator +from .turbogears.decorator import weak_signature_decorator import xhtml2pdf.pisa as pisa -import StringIO +import io import cherrypy @@ -24,9 +24,9 @@ def entangle(func): def decorated(func, *args, **kw): output = func(*args, **kw) - dst = StringIO.StringIO() + dst = io.StringIO() result = pisa.CreatePDF( - StringIO.StringIO(output), + io.StringIO(output), dst ) if not result.err: + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/tags.py file: ../python3/xhtml2pdf/tags.py + 2to3 -w -n ../python3/xhtml2pdf/tags.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/tags.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/tags.py --- ../python3/xhtml2pdf/tags.py (original) +++ ../python3/xhtml2pdf/tags.py (refactored) @@ -180,13 +180,13 @@ def listDecimal(c): c.listCounter += 1 - return unicode("%d." % c.listCounter) - - -roman_numeral_map = zip( + return str("%d." % c.listCounter) + + +roman_numeral_map = list(zip( (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1), ('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I') -) +)) def int_to_roman(i): @@ -201,7 +201,7 @@ def listUpperRoman(c): c.listCounter += 1 roman = int_to_roman(c.listCounter) - return unicode("%s." % roman) + return str("%s." % roman) def listLowerRoman(c): @@ -218,16 +218,16 @@ # this will probably fail for anything past the 2nd time alpha = string.ascii_uppercase[index - 26] alpha *= 2 - return unicode("%s." % alpha) + return str("%s." % alpha) def listLowerAlpha(c): return listUpperAlpha(c).lower() -_bullet = u"\u2022" +_bullet = "\u2022" _list_style_type = { - "none": u"", + "none": "", "disc": _bullet, "circle": _bullet, # XXX PDF has no equivalent "square": _bullet, # XXX PDF has no equivalent @@ -273,7 +273,7 @@ self.offset = 0 if frag.listStyleImage is not None: - frag.text = u"" + frag.text = "" f = frag.listStyleImage if f and (not f.notFound()): img = PmlImage( @@ -288,7 +288,7 @@ frag.image = img self.offset = max(0, img.drawHeight - c.frag.fontSize) else: - if type(lst) == type(u""): + if type(lst) == type(""): frag.text = lst else: # XXX This should be the recent font, but it throws errors in Reportlab! + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/tables.py file: ../python3/xhtml2pdf/tables.py + 2to3 -w -n ../python3/xhtml2pdf/tables.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/tables.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/tables.py --- ../python3/xhtml2pdf/tables.py (original) +++ ../python3/xhtml2pdf/tables.py (refactored) @@ -172,9 +172,9 @@ for i, row in enumerate(data): data[i] += [''] * (maxcols - len(row)) - cols_with_no_width = len(filter(lambda col: col is None, tdata.colw)) + cols_with_no_width = len([col for col in tdata.colw if col is None]) if cols_with_no_width: # any col width not defined - bad_cols = filter(lambda tup: tup[1] is None, enumerate(tdata.colw)) + bad_cols = [tup for tup in enumerate(tdata.colw) if tup[1] is None] fair_division = str(100 / float(cols_with_no_width)) + '%' # get fair % for i, _ in bad_cols: tdata.colw[i] = fair_division # fix empty with fair % @@ -262,8 +262,8 @@ if begin != end: #~ print begin, end tdata.add_style(('SPAN', begin, end)) - for x in xrange(begin[0], end[0] + 1): - for y in xrange(begin[1], end[1] + 1): + for x in range(begin[0], end[0] + 1): + for y in range(begin[1], end[1] + 1): if x != begin[0] or y != begin[1]: tdata.add_empty(x, y) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/reportlab_paragraph.py file: ../python3/xhtml2pdf/reportlab_paragraph.py + 2to3 -w -n ../python3/xhtml2pdf/reportlab_paragraph.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/reportlab_paragraph.py --- ../python3/xhtml2pdf/reportlab_paragraph.py (original) +++ ../python3/xhtml2pdf/reportlab_paragraph.py (refactored) @@ -20,36 +20,36 @@ LEADING_FACTOR = 1.0 _wsc_re_split = re.compile('[%s]+' % re.escape(''.join(( - u'\u0009', # HORIZONTAL TABULATION - u'\u000A', # LINE FEED - u'\u000B', # VERTICAL TABULATION - u'\u000C', # FORM FEED - u'\u000D', # CARRIAGE RETURN - u'\u001C', # FILE SEPARATOR - u'\u001D', # GROUP SEPARATOR - u'\u001E', # RECORD SEPARATOR - u'\u001F', # UNIT SEPARATOR - u'\u0020', # SPACE - u'\u0085', # NEXT LINE + '\u0009', # HORIZONTAL TABULATION + '\u000A', # LINE FEED + '\u000B', # VERTICAL TABULATION + '\u000C', # FORM FEED + '\u000D', # CARRIAGE RETURN + '\u001C', # FILE SEPARATOR + '\u001D', # GROUP SEPARATOR + '\u001E', # RECORD SEPARATOR + '\u001F', # UNIT SEPARATOR + '\u0020', # SPACE + '\u0085', # NEXT LINE #u'\u00A0', # NO-BREAK SPACE - u'\u1680', # OGHAM SPACE MARK - u'\u2000', # EN QUAD - u'\u2001', # EM QUAD - u'\u2002', # EN SPACE - u'\u2003', # EM SPACE - u'\u2004', # THREE-PER-EM SPACE - u'\u2005', # FOUR-PER-EM SPACE - u'\u2006', # SIX-PER-EM SPACE - u'\u2007', # FIGURE SPACE - u'\u2008', # PUNCTUATION SPACE - u'\u2009', # THIN SPACE - u'\u200A', # HAIR SPACE - u'\u200B', # ZERO WIDTH SPACE - u'\u2028', # LINE SEPARATOR - u'\u2029', # PARAGRAPH SEPARATOR - u'\u202F', # NARROW NO-BREAK SPACE - u'\u205F', # MEDIUM MATHEMATICAL SPACE - u'\u3000', # IDEOGRAPHIC SPACE + '\u1680', # OGHAM SPACE MARK + '\u2000', # EN QUAD + '\u2001', # EM QUAD + '\u2002', # EN SPACE + '\u2003', # EM SPACE + '\u2004', # THREE-PER-EM SPACE + '\u2005', # FOUR-PER-EM SPACE + '\u2006', # SIX-PER-EM SPACE + '\u2007', # FIGURE SPACE + '\u2008', # PUNCTUATION SPACE + '\u2009', # THIN SPACE + '\u200A', # HAIR SPACE + '\u200B', # ZERO WIDTH SPACE + '\u2028', # LINE SEPARATOR + '\u2029', # PARAGRAPH SEPARATOR + '\u202F', # NARROW NO-BREAK SPACE + '\u205F', # MEDIUM MATHEMATICAL SPACE + '\u3000', # IDEOGRAPHIC SPACE )))).split @@ -58,7 +58,7 @@ text = text.decode('utf8') if type(delim) is str: delim = delim.decode('utf8') - elif delim is None and u'\xa0' in text: + elif delim is None and '\xa0' in text: return [uword.encode('utf8') for uword in _wsc_re_split(text)] return [uword.encode('utf8') for uword in text.split(delim)] @@ -98,14 +98,14 @@ def _lineClean(L): - return join(filter(truth, split(strip(L)))) + return join(list(filter(truth, split(strip(L))))) def cleanBlockQuotedText(text, joiner=' '): """This is an internal utility which takes triple- quoted text form within the document and returns (hopefully) the paragraph the user intended originally.""" - L = filter(truth, map(_lineClean, split(text, '\n'))) + L = list(filter(truth, list(map(_lineClean, split(text, '\n'))))) return join(L, joiner) @@ -520,7 +520,7 @@ tx2 = canvas.beginText(style.bulletIndent, cur_y + getattr(style, "bulletOffsetY", 0)) tx2.setFont(style.bulletFontName, style.bulletFontSize) tx2.setFillColor(hasattr(style, 'bulletColor') and style.bulletColor or style.textColor) - if isinstance(bulletText, basestring): + if isinstance(bulletText, str): tx2.textOut(bulletText) else: for f in bulletText: @@ -554,7 +554,7 @@ work out bullet width and adjust maxWidths[0] if neccessary """ if bulletText: - if isinstance(bulletText, basestring): + if isinstance(bulletText, str): bulletWidth = stringWidth(bulletText, style.bulletFontName, style.bulletFontSize) else: #it's a list of fragments @@ -641,7 +641,7 @@ def _doLink(tx, link, rect): - if isinstance(link, unicode): + if isinstance(link, str): link = link.encode('utf8') parts = link.split(':', 1) scheme = len(parts) == 2 and parts[0].lower() or '' @@ -743,11 +743,11 @@ if tt: tt = tt.lower() if tt == 'lowercase': - tt = unicode.lower + tt = str.lower elif tt == 'uppercase': - tt = unicode.upper + tt = str.upper elif tt == 'capitalize': - tt = unicode.title + tt = str.title elif tt == 'none': return else: @@ -756,19 +756,19 @@ if n == 1: #single fragment the easy case frags[0].text = tt(frags[0].text.decode('utf8')).encode('utf8') - elif tt is unicode.title: + elif tt is str.title: pb = True for f in frags: t = f.text if not t: continue u = t.decode('utf8') - if u.startswith(u' ') or pb: + if u.startswith(' ') or pb: u = tt(u) else: - i = u.find(u' ') + i = u.find(' ') if i >= 0: u = u[:i] + tt(u[i:]) - pb = u.endswith(u' ') + pb = u.endswith(' ') f.text = u.encode('utf8') else: for f in frags: @@ -777,13 +777,13 @@ f.text = tt(t.decode('utf8')).encode('utf8') -class cjkU(unicode): +class cjkU(str): """ simple class to hold the frag corresponding to a str """ def __new__(cls, value, frag, encoding): - self = unicode.__new__(cls, value) + self = str.__new__(cls, value) self._frag = frag if hasattr(frag, 'cbDefn'): w = getattr(frag.cbDefn, 'width', 0) @@ -817,14 +817,14 @@ minDescent = min(minDescent, descent) if not _sameFrag(f0, f): f0 = f0.clone() - f0.text = u''.join(CW) + f0.text = ''.join(CW) words.append(f0) CW = [] f0 = f CW.append(u) if CW: f0 = f0.clone() - f0.text = u''.join(CW) + f0.text = ''.join(CW) words.append(f0) return FragLine(kind=1, extraSpace=extraSpace, wordCount=1, words=words[1:], fontSize=maxSize, ascent=maxAscent, descent=minDescent) @@ -840,7 +840,7 @@ U = [] # get a list of single glyphs with their widths etc etc for f in frags: text = f.text - if not isinstance(text, unicode): + if not isinstance(text, str): text = text.decode(encoding) if text: U.extend([cjkU(t, f, encoding) for t in text]) @@ -945,7 +945,7 @@ def __repr__(self): n = self.__class__.__name__ L = [n + "("] - keys = self.__dict__.keys() + keys = list(self.__dict__.keys()) for k in keys: v = getattr(self, k) rk = repr(k) @@ -978,9 +978,9 @@ def wrap(self, availWidth, availHeight): if self.debug: - print (id(self), "wrap") + print((id(self), "wrap")) try: - print (repr(self.getPlainText()[:80])) + print((repr(self.getPlainText()[:80]))) except: print ("???") @@ -1036,7 +1036,7 @@ else: words = _getFragWords(frags) func = lambda x: x[0] - return max(map(func, words)) + return max(list(map(func, words))) def _get_split_blParaFunc(self): return self.blPara.kind == 0 and _split_blParaSimple or _split_blParaHard @@ -1044,7 +1044,7 @@ def split(self, availWidth, availHeight): if self.debug: - print (id(self), "split") + print((id(self), "split")) if len(self.frags) <= 0: return [] @@ -1159,7 +1159,7 @@ """ if self.debug: - print (id(self), "breakLines") + print((id(self), "breakLines")) if not isinstance(width, (tuple, list)): maxWidths = [width] @@ -1378,7 +1378,7 @@ Cannot handle font variations.""" if self.debug: - print (id(self), "breakLinesCJK") + print((id(self), "breakLinesCJK")) if not isinstance(width, (list, tuple)): maxWidths = [width] @@ -1433,7 +1433,7 @@ algorithm will go infinite.""" if self.debug: - print (id(self), "drawPara", self.blPara.kind) + print((id(self), "drawPara", self.blPara.kind)) #stash the key facts locally for speed canvas = self.canv @@ -1550,7 +1550,7 @@ if link: _do_link_line(0, dx, ws, tx) #now the middle of the paragraph, aligned with the left margin which is our origin. - for i in xrange(1, nLines): + for i in range(1, nLines): ws = lines[i][0] t_off = dpl(tx, _offsets[i], ws, lines[i][1], noJustifyLast and i == lim) if dpl != _justifyDrawParaLine: ws = 0 @@ -1558,7 +1558,7 @@ if strike: _do_under_line(i, t_off + leftIndent, ws, tx, lm=0.125) if link: _do_link_line(i, t_off + leftIndent, ws, tx) else: - for i in xrange(1, nLines): + for i in range(1, nLines): dpl(tx, _offsets[i], lines[i][0], lines[i][1], noJustifyLast and i == lim) else: f = lines[0] @@ -1615,7 +1615,7 @@ _do_post_text(tx) #now the middle of the paragraph, aligned with the left margin which is our origin. - for i in xrange(1, nLines): + for i in range(1, nLines): f = lines[i] dpl(tx, _offsets[i], f, noJustifyLast and i == lim) _do_post_text(tx) @@ -1656,12 +1656,12 @@ func = lambda frag, w=self.width: w - frag.extraSpace else: func = lambda frag, w=self.width: w - frag[0] - return map(func, self.blPara.lines) + return list(map(func, self.blPara.lines)) if __name__ == '__main__': # NORUNTESTS def dumpParagraphLines(P): - print ('dumpParagraphLines()') % id(P) + print(('dumpParagraphLines()') % id(P)) lines = P.blPara.lines for l, line in enumerate(lines): line = lines[l] @@ -1670,9 +1670,9 @@ else: words = line[1] nwords = len(words) - print ('line%d: %d(%s)\n ') % (l, nwords, str(getattr(line, 'wordCount', 'Unknown'))), - for w in xrange(nwords): - print ("%d:'%s'") % (w, getattr(words[w], 'text', words[w])), + print(('line%d: %d(%s)\n ') % (l, nwords, str(getattr(line, 'wordCount', 'Unknown'))), end=' ') + for w in range(nwords): + print(("%d:'%s'") % (w, getattr(words[w], 'text', words[w])), end=' ') print() def fragDump(w): @@ -1683,20 +1683,20 @@ return ', '.join(R) def dumpParagraphFrags(P): - print ('dumpParagraphFrags() minWidth() = %.2f') % (id(P), P.minWidth()) + print(('dumpParagraphFrags() minWidth() = %.2f') % (id(P), P.minWidth())) frags = P.frags n = len(frags) - for l in xrange(n): - print ("frag%d: '%s' %s") % ( - l, frags[l].text, ' '.join(['%s=%s' % (k, getattr(frags[l], k)) for k in frags[l].__dict__ if k != text])) + for l in range(n): + print(("frag%d: '%s' %s") % ( + l, frags[l].text, ' '.join(['%s=%s' % (k, getattr(frags[l], k)) for k in frags[l].__dict__ if k != text]))) l = 0 cum = 0 for W in _getFragWords(frags): cum += W[0] - print ("fragword%d: cum=%3d size=%d") % (l, cum, W[0]), + print(("fragword%d: cum=%3d size=%d") % (l, cum, W[0]), end=' ') for w in W[1:]: - print ('(%s)') % fragDump(w), + print(('(%s)') % fragDumpRefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/reportlab_paragraph.py (w), end=' ') print() l += 1 @@ -1770,12 +1770,12 @@ P = Paragraph(text, B) dumpParagraphFrags(P) w, h = P.wrap(aW, aH) - print ('After initial wrap', w, h) + print(('After initial wrap', w, h)) dumpParagraphLines(P) S = P.split(aW, aH) dumpParagraphFrags(S[0]) w0, h0 = S[0].wrap(aW, aH) - print ('After split wrap', w0, h0) + print(('After split wrap', w0, h0)) dumpParagraphLines(S[0]) if flagged(5): @@ -1810,7 +1810,7 @@ w, h = P.wrap(6 * 72, 9.7 * 72) dumpParagraphLines(P) S = P.split(6 * 72, h / 2.0) - print (len(S)) + print((len(S))) dumpParagraphLines(S[0]) dumpParagraphLines(S[1]) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/pisa.py file: ../python3/xhtml2pdf/pisa.py + 2to3 -w -n ../python3/xhtml2pdf/pisa.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/pisa.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/pisa.py --- ../python3/xhtml2pdf/pisa.py (original) +++ ../python3/xhtml2pdf/pisa.py (refactored) @@ -10,11 +10,11 @@ import sys import tempfile try: - import urllib2 + import urllib.request, urllib.error, urllib.parse except ImportError: import urllib.request as urllib2 try: - import urlparse + import urllib.parse except ImportError: import urllib.parse as urlparse # Copyright 2010 Dirk Holtwick, holtwick.it @@ -113,15 +113,15 @@ os.remove(path) def getFileName(self, name, relative=None): - url = urlparse.urljoin(relative or self.src, name) - path = urlparse.urlsplit(url)[2] + url = urllib.parse.urljoin(relative or self.src, name) + path = urllib.parse.urlsplit(url)[2] suffix = "" if "." in path: new_suffix = "." + path.split(".")[-1].lower() if new_suffix in (".css", ".gif", ".jpg", ".png"): suffix = new_suffix path = tempfile.mktemp(prefix="pisa-", suffix=suffix) - ufile = urllib2.urlopen(url) + ufile = urllib.request.urlopen(url) tfile = file(path, "wb") while True: data = ufile.read(1024) @@ -133,7 +133,7 @@ self.tfileList.append(path) if not self.quiet: - print (" Loading", url, "to", path) + print((" Loading", url, "to", path)) return path @@ -231,12 +231,12 @@ print () print ("SYSTEM INFORMATIONS") print ("--------------------------------------------") - print ("OS: ", sys.platform) - print ("Python: ", sys.version) - print ("html5lib: ", "?") + print(("OS: ", sys.platform)) + print(("Python: ", sys.version)) + print(("html5lib: ", "?")) import reportlab - print ("Reportlab: ", reportlab.Version) + print(("Reportlab: ", reportlab.Version)) sys.exit(0) if o in ("-t", "--format"): @@ -311,7 +311,7 @@ if src.startswith("http:") or src.startswith("https:"): wpath = src fsrc = getFile(src).getFile() - src = "".join(urlparse.urlsplit(src)[1:3]).replace("/", "-") + src = "".join(urllib.parse.urlsplit(src)[1:3]).replace("/", "-") else: fsrc = wpath = os.path.abspath(src) fsrc = open(fsrc, "rb") @@ -321,7 +321,7 @@ if dest_part.lower().endswith(".html") or dest_part.lower().endswith(".htm"): dest_part = ".".join(src.split(".")[:-1]) dest = dest_part + "." + format.lower() - for i in xrange(10): + for i in range(10): try: open(dest, "wb").close() break @@ -345,13 +345,13 @@ try: open(dest, "wb").close() except: - print ("File '%s' seems to be in use of another application.") % dest + print(("File '%s' seems to be in use of another application.") % dest) sys.exit(2) fdest = open(dest, "wb") fdestclose = 1 if not quiet: - print ("Converting %s to %s...") % (src, dest) + print(("Converting %s to %s...") % (src, dest)) pdf = pisaDocument( fsrc, @@ -376,7 +376,7 @@ if (not errors) and startviewer: if not quiet: - print ("Open viewer for file %s") % dest + print(("Open viewer for file %s") % dest) startViewer(dest) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/pdf.py file: ../python3/xhtml2pdf/pdf.py + 2to3 -w -n ../python3/xhtml2pdf/pdf.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/pdf.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/pdf.py --- ../python3/xhtml2pdf/pdf.py (original) +++ ../python3/xhtml2pdf/pdf.py (refactored) @@ -50,7 +50,7 @@ output = PyPDF2.PdfFileWriter() for pdffile in self.files: input = PyPDF2.PdfFileReader(pdffile) - for pageNumber in xrange(input.getNumPages()): + for pageNumber in range(input.getNumPages()): output.addPage(input.getPage(pageNumber)) if file is not None: + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/parser.py file: ../python3/xhtml2pdf/parser.py + 2to3 -w -n ../python3/xhtml2pdf/parser.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/parser.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/parser.py --- ../python3/xhtml2pdf/parser.py (original) +++ ../python3/xhtml2pdf/parser.py (refactored) @@ -55,7 +55,7 @@ attrs = {} if attributes: - for k, v in attributes.items(): + for k, v in list(attributes.items()): try: attrs[str(k)] = str(v) # XXX no Unicode! Reportlab fails with template names except: @@ -66,11 +66,11 @@ block, adef = TAGS[tag] adef["id"] = STRING # print block, adef - for k, v in adef.iteritems(): + for k, v in adef.items(): nattrs[k] = None # print k, v # defaults, wenn vorhanden - if type(v) == types.TupleType: + if type(v) == tuple: if v[1] == MUST: if k not in attrs: log.warn(c.warning("Attribute '%s' must be set!", k)) @@ -84,7 +84,7 @@ dfl = None if nv is not None: - if type(v) == types.ListType: + if type(v) == list: nv = nv.strip().lower() if nv not in v: #~ raise PML_EXCEPTION, "attribute '%s' of wrong value, allowed is one of: %s" % (k, repr(v)) @@ -225,7 +225,7 @@ def getCSSAttrCacheKey(node): _cl = _id = _st = '' - for k, v in node.attributes.items(): + for k, v in list(node.attributes.items()): if k == 'class': _cl = v elif k == 'id': @@ -393,7 +393,7 @@ Collect all CSS definitions """ - data = u"" + data = "" if node.nodeType == Node.TEXT_NODE and collect: data = node.data @@ -411,7 +411,7 @@ for node in node.childNodes: data += pisaPreLoop(node, context, collect=True) context.addCSS(data) - return u"" + return "" if name == "link" and attr.href and attr.rel.lower() == "stylesheet": # print "CSS LINK", attr @@ -647,8 +647,8 @@ else: parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("dom")) - if type(src) in types.StringTypes: - if type(src) is types.UnicodeType: + if type(src) in (str,): + if type(src) is str: # If an encoding was provided, do not change it. if not encoding: encoding = "utf-8" + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/paragraph2.py file: ../python3/xhtml2pdf/paragraph2.py + 2to3 -w -n ../python3/xhtml2pdf/paragraph2.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/paragraph2.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/paragraph2.py --- ../python3/xhtml2pdf/paragraph2.py (original) +++ ../python3/xhtml2pdf/paragraph2.py (refactored) @@ -344,9 +344,9 @@ return self.height def dumpFragments(self): - print ("Line", 40 * "-") + print(("Line", 40 * "-")) for frag in self: - print ("%s") % frag.get("text", frag.name.upper()), + print(("%s") % frag.get("text", frag.name.upper()), end=' ') print() @@ -509,7 +509,7 @@ For debugging dump all line and their content """ for i, line in enumerate(self.lines): - print ("Line %d:") % i, + print(("Line %d:") % i, end=' ') line.dumpFragments() @@ -539,7 +539,7 @@ self.splitted = splitted # More attributes - for k, v in kwDict.iteritems(): + for k, v in kwDict.items(): setattr(self, k, v) # set later... @@ -556,11 +556,11 @@ self.avHeight = availHeight if self.debug: - print ("*** wrap (%f, %f)") % (availWidth, availHeight) + print(("*** wrap (%f, %f)") % (availWidth, availHeight)) if not self.text: if self.debug: - print ("*** wrap (%f, %f) needed") % (0, 0) + print(("*** wrap (%f, %f) needed") % (0, 0)) return 0, 0 # Split lines @@ -570,7 +570,7 @@ self.width, self.height = availWidth, self.text.height if self.debug: - print ("*** wrap (%f, %f) needed, splitIndex %r") % (self.width, self.height, self.splitIndex) + print(("*** wrap (%f, %f) needed, splitIndex %r") % (self.width, self.height, self.splitIndex)) return self.width, self.height @@ -580,7 +580,7 @@ """ if self.debug: - print ("*** split (%f, %f)") % (availWidth, availHeight) + print(("*** split (%f, %f)") % (availWidth, availHeight)) splitted = [] if self.splitIndex: @@ -591,10 +591,10 @@ splitted = [p1, p2] if self.debug: - print ("*** text1 %s / text %s") % (len(text1), len(text2)) + print(("*** text1 %s / text %s") % (len(text1), len(text2))) if self.debug: - print ('*** return %s') % self.splitted + print(('*** return %s') % self.splitted) return splitted @@ -658,7 +658,7 @@ _scheme_re = re.compile('^[a-zA-Z][-+a-zA-Z0-9]+$') x, y, w, h = frag["x"], dy - y, frag["width"], frag["fontSize"] rect = (x, y, w, h) - if isinstance(link, unicode): + if isinstance(link, str): link = link.encode('utf8') parts = link.split(':', 1) scheme = len(parts) == 2 and parts[0].lower() or '' @@ -925,13 +925,13 @@ # text = Text(list(textGenerator(TEXT, "Times-Roman", 10))) text = Text(makeSpecial()) text.calc() - print (text[1].type) + print((text[1].type)) while 1: width, br, group = text.getGroup() if not group: - print ("ENDE", repr(group)) + print(("ENDE", repr(group))) break - print (width, br, " ".join([str(x) for x in group])) + print((width, br, " ".join([str(x) for x in group]))) # test2() if 1: # FIXME: Again, why this? And the commented lines around here. + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/paragraph.py file: ../python3/xhtml2pdf/paragraph.py + 2to3 -w -n ../python3/xhtml2pdf/paragraph.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/paragraph.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/paragraph.py --- ../python3/xhtml2pdf/paragraph.py (original) +++ ../python3/xhtml2pdf/paragraph.py (refactored) @@ -288,9 +288,9 @@ return self.height def dumpFragments(self): - print ("Line", 40 * "-") + print(("Line", 40 * "-")) for frag in self: - print ("%s") % frag.get("text", frag.name.upper()), + print(("%s") % frag.get("text", frag.name.upper()), end=' ') print() @@ -415,7 +415,7 @@ For debugging dump all line and their content """ for i, line in enumerate(self.lines): - print ("Line %d:") % i, + print(("Line %d:") % i, end=' ') line.dumpFragments() @@ -444,7 +444,7 @@ self.splitted = splitted # More attributes - for k, v in kwDict.iteritems(): + for k, v in kwDict.items(): setattr(self, k, v) # set later... @@ -461,11 +461,11 @@ self.avHeight = availHeight if self.debug: - print ("*** wrap (%f, %f)") % (availWidth, availHeight) + print(("*** wrap (%f, %f)") % (availWidth, availHeight)) if not self.text: if self.debug: - print ("*** wrap (%f, %f) needed") % (0, 0) + print(("*** wrap (%f, %f) needed") % (0, 0)) return 0, 0 # Split lines @@ -475,7 +475,7 @@ self.width, self.height = availWidth, self.text.height if self.debug: - print ("*** wrap (%f, %f) needed, splitIndex %r") % (self.width, self.height, self.splitIndex) + print(("*** wrap (%f, %f) needed, splitIndex %r") % (self.width, self.height, self.splitIndex)) return self.width, self.height @@ -485,7 +485,7 @@ """ if self.debug: - print ("*** split (%f, %f)") % (availWidth, availHeight) + print(("*** split (%f, %f)") % (availWidth, availHeight)) splitted = [] if self.splitIndex: @@ -496,10 +496,10 @@ splitted = [p1, p2] if self.debug: - print ("*** text1 %s / text %s") % (len(text1), len(text2)) + print(("*** text1 %s / text %s") % (len(text1), len(text2))) if self.debug: - print ('*** return %s') % self.splitted + print(('*** return %s') % self.splitted) return splitted @@ -557,7 +557,7 @@ _scheme_re = re.compile('^[a-zA-Z][-+a-zA-Z0-9]+$') x, y, w, h = frag["x"], dy - y, frag["width"], frag["fontSize"] rect = (x, y, w, h) - if isinstance(link, unicode): + if isinstance(link, str): link = link.encode('utf8') parts = link.split(':', 1) scheme = len(parts) == 2 and parts[0].lower() or '' + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/document.py file: ../python3/xhtml2pdf/document.py + 2to3 -w -n ../python3/xhtml2pdf/document.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/document.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/document.py --- ../python3/xhtml2pdf/document.py (original) +++ ../python3/xhtml2pdf/document.py (refactored) @@ -119,7 +119,7 @@ topPadding=0)], pagesize=context.pageSize) - doc.addPageTemplates([body] + context.templateList.values()) + doc.addPageTemplates([body] + list(context.templateList.values())) # Use multibuild e.g. if a TOC has to be created if context.multiBuild: + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/default.py file: ../python3/xhtml2pdf/default.py + 2to3 -w -n ../python3/xhtml2pdf/default.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/xhtml2pdf/default.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/xhtml2pdf/default.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/context.py file: ../python3/xhtml2pdf/context.py + 2to3 -w -n ../python3/xhtml2pdf/context.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/xhtml2pdf/context.py --- ../python3/xhtml2pdf/context.py (original) +++ ../python3/xhtml2pdf/context.py (refactored) @@ -19,7 +19,7 @@ import reportlab import types try: - import urlparse + import urllib.parse except ImportError: import urllib.parse as urlparse import xhtml2pdf.default @@ -47,7 +47,7 @@ subFraction = 0.4 # fraction of font size that a sub script should be lowered superFraction = 0.4 -NBSP = u"\u00a0" +NBSP = "\u00a0" def clone(self, **kwargs): @@ -145,7 +145,7 @@ def getDirName(path): - parts = urlparse.urlparse(path) + parts = urllib.parse.urlparse(path) if parts.scheme: return path else: @@ -158,7 +158,7 @@ Embed fonts """ result = self.ruleset([self.selector('*')], declarations) - data = result[0].values()[0] + data = list(result[0].values())[0] if "src" not in data: # invalid - source is required, ignore this specification return {}, {} @@ -221,7 +221,7 @@ result = self.ruleset([self.selector('*')], declarations) if declarations: - data = result[0].values()[0] + data = list(result[0].values())[0] pageBorder = data.get("-pdf-frame-border", None) if name in c.templateList: @@ -233,12 +233,12 @@ isLandscape = False if "size" in data: size = data["size"] - if type(size) is not types.ListType: + if type(size) is not list: size = [size] sizeList = [] for value in size: valueStr = str(value).lower() - if type(value) is types.TupleType: + if type(value) is tuple: sizeList.append(getSize(value)) elif valueStr == "landscape": isLandscape = True @@ -363,7 +363,7 @@ data = result[0] if data: - data = data.values()[0] + data = list(data.values())[0] self.c.frameList.append( self._pisaAddFrame(name, data, size=self.c.pageSize)) @@ -377,8 +377,8 @@ cssFile = self.c.getFile(cssResourceName, relative=self.rootPath) if not cssFile: return None - if self.rootPath and urlparse.urlparse(self.rootPath).scheme: - self.rootPath = urlparse.urljoin(self.rootPath, cssResourceName) + if self.rootPath and urllib.parse.urlparse(self.rootPath).scheme: + self.rootPath = urllib.parse.urljoin(self.rootPath, cssResourceName) else: self.rootPath = getDirName(cssFile.uri) @@ -406,7 +406,7 @@ self.log = [] self.err = 0 self.warn = 0 - self.text = u"" + self.text = "" self.uidctr = 0 self.multiBuild = False @@ -447,7 +447,7 @@ # Store path to document self.pathDocument = path or "__dummy__" - parts = urlparse.urlparse(self.pathDocument) + parts = urllib.parse.urlparse(self.pathDocument) if not parts.scheme: self.pathDocument = os.path.abspath(self.pathDocument) self.pathDirectory = getDirName(self.pathDocument) @@ -572,7 +572,7 @@ def addTOC(self): styles = [] - for i in xrange(20): + for i in range(20): self.node.attributes["class"] = "pdftoclevel%d" % i self.cssAttr = xhtml2pdf.parser.CSSCollect(self.node, self) xhtml2pdf.parser.CSS2Frag(self, { @@ -679,7 +679,7 @@ def clearFrag(self): self.fragList = [] self.fragStrip = True - self.text = u"" + self.text = "" def copyFrag(self, **kw): return self.frag.clone(**kw) @@ -716,9 +716,9 @@ # Replace ­ with empty and normalize NBSP text = (text - .replace(u"\xad", u"") - .replace(u"\xc2\xa0", NBSP) - .replace(u"\xa0", NBSP)) + .replace("\xad", "") + .replace("\xc2\xa0", NBSP)RefactoringTool: Files that were modified: RefactoringTool: ../python3/xhtml2pdf/context.py + .replace("\xa0", NBSP)) if frag.whiteSpace == "pre": @@ -734,7 +734,7 @@ self._appendFrag(frag) else: # Handle tabs in a simple way - text = text.replace(u"\t", 8 * u" ") + text = text.replace("\t", 8 * " ") # Somehow for Reportlab NBSP have to be inserted # as single character fragments for text in re.split(r'(\ )', text): @@ -744,7 +744,7 @@ frag.text = text self._appendFrag(frag) else: - for text in re.split(u'(' + NBSP + u')', text): + for text in re.split('(' + NBSP + ')', text): frag = baseFrag.clone() if text == NBSP: self.force = True @@ -832,12 +832,12 @@ Name of a font """ # print names, self.fontList - if type(names) is not types.ListType: - if type(names) not in types.StringTypes: + if type(names) is not list: + if type(names) not in (str,): names = str(names) names = names.strip().split(",") for name in names: - if type(name) not in types.StringTypes: + if type(name) not in (str,): name = str(name) font = self.fontList.get(name.strip().lower(), None) if font is not None: @@ -847,7 +847,7 @@ def registerFont(self, fontname, alias=[]): self.fontList[str(fontname).lower()] = str(fontname) for a in alias: - if type(fontname) not in types.StringTypes: + if type(fontname) not in (str,): fontname = str(fontname) self.fontList[str(a)] = fontname @@ -861,7 +861,7 @@ log.debug("Load font %r", src) - if type(names) is types.ListType: + if type(names) is list: fontAlias = names else: fontAlias = (x.lower().strip() for x in names.split(",") if x) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/xhtml2pdf/__init__.py file: ../python3/xhtml2pdf/__init__.py + 2to3 -w -n ../python3/xhtml2pdf/__init__.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/xhtml2pdf/__init__.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/xhtml2pdf/__init__.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/tests/test_utils.py file: ../python3/tests/test_utils.py + 2to3 -w -n ../python3/tests/test_utils.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/tests/test_utils.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/tests/test_utils.py --- ../python3/tests/test_utils.py (original) +++ ../python3/tests/test_utils.py (refactored) @@ -145,7 +145,7 @@ } expected = (10.0, 20.0, 30.0, 40.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) def test_FrameDimensions_left_top_bottom_right(self): dims = { @@ -156,7 +156,7 @@ } expected = (10.0, 20.0, 50.0, 150.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) def test_FrameDimensions_bottom_right_width_height(self): dims = { @@ -167,7 +167,7 @@ } expected = (10.0, 110.0, 70.0, 80.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) def test_FrameDimensions_left_top_width_height_with_margin(self): dims = { @@ -182,7 +182,7 @@ } expected = (25.0, 30.0, 30.0, 50.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) def test_FrameDimensions_bottom_right_width_height_with_margin(self): dims = { @@ -197,7 +197,7 @@ } expected = (25.0, 120.0, 30.0, 50.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) def test_frame_dimensions_for_box_len_eq_4(self): dims = { @@ -216,7 +216,7 @@ } expected = (10.0, 0.0, 30.0, 200.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) def test_trame_dimentions_for_width_without_left_or_right(self): dims = { @@ -227,7 +227,7 @@ } expected = (0.0, 20.0, 100.0, 40.0) result = getFrameDimensions(dims, 100, 200) - self.assertEquals(expected, result) + self.assertEqual(expected, result) class GetPosTestCase(TestCase): def test_get_pos_simple(self): + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/tests/test_parser.py file: ../python3/tests/test_parser.py + 2to3 -w -n ../python3/tests/test_parser.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/tests/test_parser.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/tests/test_parser.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/tests/runtests.py file: ../python3/tests/runtests.py + 2to3 -w -n ../python3/tests/runtests.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/tests/runtests.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/tests/runtests.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/tests/__init__.py file: ../python3/tests/__init__.py + 2to3 -w -n ../python3/tests/__init__.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/tests/__init__.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/tests/__init__.py --- ../python3/tests/__init__.py (original) +++ ../python3/tests/__init__.py (refactored) @@ -1 +1 @@ -from runtests import buildTestSuite +from .runtests import buildTestSuite + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/testrender/testrender.py file: ../python3/testrender/testrender.py + 2to3 -w -n ../python3/testrender/testrender.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/testrender/testrender.py --- ../python3/testrender/testrender.py (original) +++ ../python3/testrender/testrender.py (refactored) @@ -12,7 +12,7 @@ def render_pdf(filename, output_dir, options): if options.debug: - print 'Rendering %s' % filename + print('Rendering %s' % filename) basename = os.path.basename(filename) outname = '%s.pdf' % os.path.splitext(basename)[0] outfile = os.path.join(output_dir, outname) @@ -26,14 +26,14 @@ output.close() if result.err: - print 'Error rendering %s: %s' % (filename, result.err) + print('Error rendering %s: %s' % (filename, result.err)) sys.exit(1) return outfile def convert_to_png(infile, output_dir, options): if options.debug: - print 'Converting %s to PNG' % infile + print('Converting %s to PNG' % infile) basename = os.path.basename(infile) filename = os.path.splitext(basename)[0] outname = '%s.page%%0d.png' % filename @@ -47,7 +47,7 @@ def create_diff_image(srcfile1, srcfile2, output_dir, options): if options.debug: - print 'Creating difference image for %s and %s' % (srcfile1, srcfile2) + print('Creating difference image for %s and %s' % (srcfile1, srcfile2)) outname = '%s.diff%s' % os.path.splitext(srcfile1) outfile = os.path.join(output_dir, outname) @@ -55,13 +55,13 @@ diff_value = int(result.strip()) if diff_value > 0: if not options.quiet: - print 'Image %s differs from reference, value is %i' % (srcfile1, diff_value) + print('Image %s differs from reference, value is %i' % (srcfile1, diff_value)) return outfile, diff_value def copy_ref_image(srcname, output_dir, options): if options.debug: - print 'Copying reference image %s ' % srcname + print('Copying reference image %s ' % srcname) dstname = os.path.basename(srcname) dstfile = os.path.join(output_dir, '%s.ref%s' % os.path.splitext(dstname)) shutil.copyfile(srcname, dstfile) @@ -71,14 +71,14 @@ def create_thumbnail(filename, options): thumbfile = '%s.thumb%s' % os.path.splitext(filename) if options.debug: - print 'Creating thumbnail of %s' % filename + print('Creating thumbnail of %s' % filename) exec_cmd(options, options.convert_cmd, '-resize', '20%', filename, thumbfile) return thumbfile def render_file(filename, output_dir, ref_dir, options): if not options.quiet: - print 'Rendering %s' % filename + print('Rendering %s' % filename) pdf = render_pdf(filename, output_dir, options) pngs = convert_to_png(pdf, output_dir, options) if options.create_reference: @@ -91,7 +91,7 @@ for page in pages: refsrc = os.path.join(ref_dir, os.path.basename(page['png'])) if not os.path.isfile(refsrc): - print 'Reference image for %s not found!' % page['png'] + print('Reference image for %s not found!' % page['png']) continue page['ref'] = copy_ref_image(refsrc, output_dir, options) page['ref_thumb'] = create_thumbnail(page['ref'], options) @@ -106,13 +106,13 @@ def exec_cmd(options, *args): if options.debug: - print 'Executing %s' % ' '.join(args) + print('Executing %s' % ' '.join(args)) proc = Popen(args, stdout=PIPE, stderr=PIPE) result = proc.communicate() if options.debug: - print result[0], result[1] + print(result[0], result[1]) if proc.returncode: - print 'exec error (%i): %s' % (proc.returncode, result[1]) + print('exec error (%i): %s' % (proc.returncode, result[1])) sys.exit(1) return result[0], result[1] @@ -127,7 +127,7 @@ '

%(pdf)s

\n' % {'pdf': pdfname}) for i, page in enumerate(pages): - vars = dict(((k, os.path.basename(v)) for k,v in page.items() + vars = dict(((k, os.path.basename(v)) for k,v in list(page.items()) RefactoringTool: Files that were modified: RefactoringTool: ../python3/testrender/testrender.py if k != 'diff_value')) vars['page'] = i+1 if 'diff' in page: @@ -216,15 +216,15 @@ num = len(results) if options.create_reference is not None: - print 'Created reference for %i file%s' % (num, '' if num == 1 else 's') + print('Created reference for %i file%s' % (num, '' if num == 1 else 's')) else: htmlfile = create_html_file(results, template_file, output_dir, options) if not options.quiet: - print 'Rendered %i file%s' % (num, '' if num == 1 else 's') - print '%i file%s differ%s from reference' % \ + print('Rendered %i file%s' % (num, '' if num == 1 else 's')) + print('%i file%s differ%s from reference' % \ (diff_count, diff_count != 1 and 's' or '', - diff_count == 1 and 's' or '') - print 'Check %s for results' % htmlfile + diff_count == 1 and 's' or '')) + print('Check %s for results' % htmlfile) if diff_count: sys.exit(1) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/visualdiff.py file: ../python3/test/visualdiff.py + 2to3 -w -n ../python3/test/visualdiff.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/test/visualdiff.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/test/visualdiff.py --- ../python3/test/visualdiff.py (original) +++ ../python3/test/visualdiff.py (refactored) @@ -40,21 +40,21 @@ self.folder4del = None def execute(self, *a): - print "EXECUTE", " ".join(a) + print("EXECUTE", " ".join(a)) return subprocess.Popen(a, stdout=subprocess.PIPE).communicate()[0] def getFiles(self, folder, pattern="*.*"): pattern = os.path.join(folder, pattern) self.files = [x for x in glob.glob(pattern) if not x.startswith(".")] self.files.sort() - print "FILES", self.files + print("FILES", self.files) return self.files def loadFile(self, file, folder=None, delete=True): if folder is None: folder = self.folder4del = tempfile.mkdtemp(prefix="visualdiff-tmp-") delete = True - print "FOLDER", folder, "DELETE", delete + print("FOLDER", folder, "DELETE", delete) source = os.path.abspath(file) destination = os.path.join(folder, "image.png") self.execute(CONVERT, source, destination) @@ -62,12 +62,12 @@ return folder def compare(self, other, chunk=16 * 1024): - if len(self.files) <> len(other.files): + if len(self.files) != len(other.files): return False for i in range(len(self.files)): a = open(self.files[i], "rb") b = open(other.files[i], "rb") - if a.read() <> b.read(): + if a.read() != b.read(): return False return True @@ -105,7 +105,7 @@ options, args = getoptions() - print args + print(args) a = VisualObject() b = VisualObject() @@ -113,7 +113,7 @@ a.loadFile("expected/test-loremipsum.pdf") b.files = a.files - print a.compare(b) + print(a.compare(b)) if __name__=="__main__": main() + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/testEvenOddPage.py file: ../python3/test/testEvenOddPage.py + 2to3 -w -n ../python3/test/testEvenOddPage.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/test/testEvenOddPage.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/test/testEvenOddPage.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/testBackground.py file: ../python3/test/testBackground.py + 2to3 -w -n ../python3/test/testBackground.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/test/testBackground.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/test/testBackground.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/story2canvas.py file: ../python3/test/story2canvas.py + 2to3 -w -n ../python3/test/story2canvas.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: No changes to ../python3/test/story2canvas.py RefactoringTool: Files that need to be modified: RefactoringTool: ../python3/test/story2canvas.py + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/simple.py file: ../python3/test/simple.py + 2to3 -w -n ../python3/test/simple.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/test/simple.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/test/simple.py --- ../python3/test/simple.py (original) +++ ../python3/test/simple.py (refactored) @@ -21,7 +21,7 @@ import os import sys import cgi -import cStringIO +import io import logging import xhtml2pdf.pisa as pisa @@ -36,7 +36,7 @@ #if pdf.warn: # print "*** %d WARNINGS OCCURED" % pdf.warn if pdf.err: - print "*** %d ERRORS OCCURED" % pdf.err + print("*** %d ERRORS OCCURED" % pdf.err) def testSimple( data="""Hello World
""", @@ -49,7 +49,7 @@ """ pdf = pisa.CreatePDF( - cStringIO.StringIO(data), + io.StringIO(data), file(dest, "wb") ) @@ -65,20 +65,20 @@ file object and then send it to STDOUT """ - result = cStringIO.StringIO() + result = io.StringIO() pdf = pisa.CreatePDF( - cStringIO.StringIO(data), + io.StringIO(data), result ) if pdf.err: - print "Content-Type: text/plain" - print + print("Content-Type: text/plain") + print() dumpErrors(pdf) else: - print "Content-Type: application/octet-stream" - print + print("Content-Type: application/octet-stream") + print() sys.stdout.write(result.getvalue()) def testBackgroundAndImage( @@ -115,10 +115,10 @@ the Reportlab Toolkit needs real filenames for images and stuff. Then we also pass the url as 'path' for relative path calculations. """ - import urllib + import urllib.request, urllib.parse, urllib.error pdf = pisa.CreatePDF( - urllib.urlopen(url), + urllib.request.urlopen(url), file(dest, "wb"), log_warn = 1, log_err = 1, + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/pdfjoiner.py file: ../python3/test/pdfjoiner.py + 2to3 -w -n ../python3/test/pdfjoiner.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/test/pdfjoiner.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/test/pdfjoiner.py --- ../python3/test/pdfjoiner.py (original) +++ ../python3/test/pdfjoiner.py (refactored) @@ -27,7 +27,7 @@ pdf = pisa_pdf.pisaPDF() subPdf = pisa.pisaDocument( - u""" + """ Hello World """) pdf.addDocument(subPdf) + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/linkloading.py file: ../python3/test/linkloading.py + 2to3 -w -n ../python3/test/linkloading.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/test/linkloading.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/test/linkloading.py --- ../python3/test/linkloading.py (original) +++ ../python3/test/linkloading.py (refactored) @@ -64,7 +64,7 @@ tmpFile.close() self.tmpFileList.append(tmpPath) return tmpPath - except Exception, e: + except Exception as e: log.exception("myLinkLoader.getFileName") return None @@ -74,7 +74,7 @@ lc = myLinkLoader(database="some_name", port=666).getFileName pdf = pisa.CreatePDF( - u""" + """

Hello World

+ for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/helloworld.py file: ../python3/test/helloworld.py + 2to3 -w -n ../python3/test/helloworld.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/test/helloworld.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/test/helloworld.py --- ../python3/test/helloworld.py (original) +++ ../python3/test/helloworld.py (refactored) @@ -23,7 +23,7 @@ def helloWorld(): filename = __file__ + ".pdf" pdf = pisa.CreatePDF( - u"Hello World", + "Hello World", file(filename, "wb") ) if not pdf.err: + for i in $(find ../python3 -type f -name '*.py') + echo file: ../python3/test/datauri.py file: ../python3/test/datauri.py + 2to3 -w -n ../python3/test/datauri.py RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/test/datauri.py RefactoringTool: Files that were modified: RefactoringTool: ../python3/test/datauri.py --- ../python3/test/datauri.py (original) +++ ../python3/test/datauri.py (refactored) @@ -28,7 +28,7 @@ datauri = pisa.makeDataURIFromFile('img/denker.png') bguri = os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir, "pdf/background-sample.pdf")) bguri = pisa.makeDataURIFromFile(bguri) - html = u""" + html = """