[Checkins] SVN: refline.srccheck/trunk/ Added support for Python 3.3, fixed some cruft.
Albertas Agejevas
cvs-admin at zope.org
Tue Mar 26 23:51:48 UTC 2013
Log message for revision 130168:
Added support for Python 3.3, fixed some cruft.
Changed:
U refline.srccheck/trunk/CHANGES.txt
U refline.srccheck/trunk/setup.py
U refline.srccheck/trunk/src/refline/srccheck/README.txt
U refline.srccheck/trunk/src/refline/srccheck/checker.py
U refline.srccheck/trunk/src/refline/srccheck/pyflakes.py
U refline.srccheck/trunk/src/refline/srccheck/testing/bad.py
U refline.srccheck/trunk/src/refline/srccheck/tests.py
-=-
Modified: refline.srccheck/trunk/CHANGES.txt
===================================================================
--- refline.srccheck/trunk/CHANGES.txt 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/CHANGES.txt 2013-03-26 23:51:48 UTC (rev 130168)
@@ -4,8 +4,9 @@
0.5.5 (unreleased)
------------------
-- ...
+- Added support for Python 3.3.
+
0.5.4 (2012-11-16)
------------------
Modified: refline.srccheck/trunk/setup.py
===================================================================
--- refline.srccheck/trunk/setup.py 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/setup.py 2013-03-26 23:51:48 UTC (rev 130168)
@@ -31,7 +31,7 @@
'cssutils',
],
extras_require=dict(
- test=[]),
+ test=['zope.testing']),
packages=find_packages('src'),
package_dir={'': 'src'},
Modified: refline.srccheck/trunk/src/refline/srccheck/README.txt
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/README.txt 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/src/refline/srccheck/README.txt 2013-03-26 23:51:48 UTC (rev 130168)
@@ -9,6 +9,7 @@
Import the checker:
+ >>> import refline.srccheck.pyflakes
>>> from refline.srccheck.checker import checker
Run the checks.
@@ -30,7 +31,7 @@
testing/bad.py
--------------
Tab found in file
- 9: print "there's a tab"
+ 9: print("there's a tab")
^
<BLANKLINE>
testing/bad.py
@@ -60,4 +61,4 @@
- With the checker `ignoreFiles` parameter
-- With `##ignore PyflakesChecker##` in the file
\ No newline at end of file
+- With `##ignore PyflakesChecker##` in the file
Modified: refline.srccheck/trunk/src/refline/srccheck/checker.py
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/checker.py 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/src/refline/srccheck/checker.py 2013-03-26 23:51:48 UTC (rev 130168)
@@ -26,7 +26,12 @@
INDENT = ' '
+try:
+ STR = basestring # Py2
+except NameError:
+ STR = str # Py3
+
class BaseChecker(object):
fnameprinted = False
filename = None
@@ -39,19 +44,19 @@
filename = self.filename.replace('\\', '/')
filename = filename[len(self.basename) + 1:]
print
- print filename
- print '-' * len(filename)
+ print(filename)
+ print('-' * len(filename))
self.fnameprinted = True
- print "%s%s" % (INDENT, self.error)
+ print("%s%s" % (INDENT, self.error))
if noInfo:
return
lineidx = str(lineidx + 1) + ': '
- print "%s%s%s" % (INDENT, lineidx, line)
+ print("%s%s%s" % (INDENT, lineidx, line))
if pos is not None:
- print "%s%s^" % (INDENT, ' ' * (len(lineidx) + pos))
+ print("%s%s^" % (INDENT, ' ' * (len(lineidx) + pos)))
def check(self, filename, content, lines):
pass
@@ -143,10 +148,10 @@
content = self.fixcontent(lines)
try:
result = pyflakes.check(content, filename)
- except Exception, e:
+ except Exception as e:
result = "Fatal exception in pyflakes: %s" % e
- if isinstance(result, basestring):
+ if isinstance(result, STR):
#something fatal occurred
self.error = result
self.log(noInfo=True)
@@ -329,7 +334,6 @@
for root, dirs, files in os.walk(top, topdown=True):
#keep the name order
- dirs.sort()
files.sort()
for name in files:
ignoreThis = False
@@ -345,7 +349,7 @@
if ext in self.extensions:
#read file once, pass the content to checkers
- content = open(fullname, 'rb').read()
+ content = open(fullname).read()
if 'checker_ignore_this_file' in content:
continue
Modified: refline.srccheck/trunk/src/refline/srccheck/pyflakes.py
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/pyflakes.py 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/src/refline/srccheck/pyflakes.py 2013-03-26 23:51:48 UTC (rev 130168)
@@ -6,7 +6,7 @@
Implementation of the command-line I{pyflakes} tool.
"""
-import compiler, sys
+import sys
import os
import _ast
@@ -36,7 +36,7 @@
if sys.version_info[:2] == (2, 4):
raise SyntaxError(None)
raise
- except (SyntaxError, IndentationError), value:
+ except (SyntaxError, IndentationError) as value:
msg = value.args[0]
(lineno, offset, text) = value.lineno, value.offset, value.text
@@ -46,7 +46,7 @@
# Avoid using msg, since for the only known case, it contains a
# bogus message that claims the encoding the file declared was
# unknown.
- return ["%s: problem decoding source" % (filename, )]
+ return "%s: problem decoding source" % (filename, )
else:
line = text.splitlines()[-1]
@@ -58,13 +58,13 @@
if offset is not None:
result += '\n'+" " * offset+"^"
- return [result]
+ return result
else:
# Okay, it's syntactically valid. Now parse it into an ast and check
# it.
tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST)
w = checker.Checker(tree, filename)
- w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
+ w.messages.sort(key=lambda x: x.lineno)
return w.messages
@@ -75,8 +75,8 @@
@return: the number of warnings printed
"""
try:
- return check(file(filename, 'U').read() + '\n', filename)
- except IOError, msg:
+ return check(open(filename, 'U').read() + '\n', filename)
+ except IOError as msg:
print >> sys.stderr, "%s: %s" % (filename, msg.args[1])
return 1
Modified: refline.srccheck/trunk/src/refline/srccheck/testing/bad.py
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/testing/bad.py 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/src/refline/srccheck/testing/bad.py 2013-03-26 23:51:48 UTC (rev 130168)
@@ -6,4 +6,4 @@
foo = bar
def with_tab():
- print "there's a tab"
\ No newline at end of file
+ print("there's a tab")
Modified: refline.srccheck/trunk/src/refline/srccheck/tests.py
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/tests.py 2013-03-26 23:46:12 UTC (rev 130167)
+++ refline.srccheck/trunk/src/refline/srccheck/tests.py 2013-03-26 23:51:48 UTC (rev 130168)
@@ -17,11 +17,14 @@
"""
import unittest
import doctest
+import re
+from zope.testing.renormalizing import RENormalizing
+
def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite('README.txt',
- optionflags=doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS,
- ),
- ))
+ return doctest.DocFileSuite(
+ 'README.txt',
+ optionflags=doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS,
+ checker=RENormalizing([(re.compile(u"u':'"), "':'")])
+ )
More information about the checkins
mailing list