[Checkins] SVN: refline.srccheck/trunk/ Fix: cleanup the madness in logging
Adam Groszer
cvs-admin at zope.org
Wed Apr 4 09:00:25 UTC 2012
Log message for revision 124938:
Fix: cleanup the madness in logging
Changed:
U refline.srccheck/trunk/CHANGES.txt
U refline.srccheck/trunk/src/refline/srccheck/README.txt
U refline.srccheck/trunk/src/refline/srccheck/checker.py
-=-
Modified: refline.srccheck/trunk/CHANGES.txt
===================================================================
--- refline.srccheck/trunk/CHANGES.txt 2012-04-04 08:36:57 UTC (rev 124937)
+++ refline.srccheck/trunk/CHANGES.txt 2012-04-04 09:00:22 UTC (rev 124938)
@@ -4,7 +4,7 @@
0.5.3 (unreleased)
------------------
-- Nothing changed yet.
+- Fix: cleanup the madness in logging
0.5.2 (2012-04-04)
Modified: refline.srccheck/trunk/src/refline/srccheck/README.txt
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/README.txt 2012-04-04 08:36:57 UTC (rev 124937)
+++ refline.srccheck/trunk/src/refline/srccheck/README.txt 2012-04-04 09:00:22 UTC (rev 124938)
@@ -20,10 +20,18 @@
testing/bad.css
---------------
PropertyValue: No match: ('CHAR', u':', 4, 10)
+ PropertyValue: Unknown syntax or no value: 10px
+ width: 20
<BLANKLINE>
+ CSSStyleDeclaration: Syntax Error in Property: height: 10px
+ width: 20
+ <BLANKLINE>
+ <BLANKLINE>
testing/bad.py
--------------
Tab found in file
+ 9: print "there's a tab"
+ ^
<BLANKLINE>
testing/bad.py
--------------
Modified: refline.srccheck/trunk/src/refline/srccheck/checker.py
===================================================================
--- refline.srccheck/trunk/src/refline/srccheck/checker.py 2012-04-04 08:36:57 UTC (rev 124937)
+++ refline.srccheck/trunk/src/refline/srccheck/checker.py 2012-04-04 09:00:22 UTC (rev 124938)
@@ -33,7 +33,7 @@
basename = None
error = None
- def log(self, lineidx, line=None, pos=None):
+ def log(self, lineidx=0, line=None, pos=None, noInfo=False):
if not self.fnameprinted:
# always slash please, for cross platform stability
filename = self.filename.replace('\\', '/')
@@ -41,17 +41,13 @@
print
print filename
print '-' * len(filename)
-
- if line is None:
- #no details
- if not self.fnameprinted:
- print "%s%s" % (INDENT, self.error)
self.fnameprinted = True
- return
- self.fnameprinted = True
-
print "%s%s" % (INDENT, self.error)
+
+ if noInfo:
+ return
+
lineidx = str(lineidx + 1) + ': '
print "%s%s%s" % (INDENT, lineidx, line)
if pos is not None:
@@ -72,9 +68,10 @@
error = 'Tab found in file'
def check(self, filename, content, lines):
- for idx, line in enumerate(lines):
+ for lineidx, line in enumerate(lines):
if '\t' in line:
- self.log(idx)
+ pos = line.index('\t')
+ self.log(lineidx, line, pos)
VALIDCHARS = string.printable
@@ -83,10 +80,10 @@
error = 'Non ASCII char found in line'
def check(self, filename, content, lines):
- for idx, line in enumerate(lines):
- for cidx, c in enumerate(line):
+ for lineidx, line in enumerate(lines):
+ for pos, c in enumerate(line):
if c not in VALIDCHARS:
- self.log(idx, line, cidx)
+ self.log(lineidx, line, pos)
break
@@ -94,29 +91,29 @@
error = 'Breakpoint found in line'
def check(self, filename, content, lines):
- for idx, line in enumerate(lines):
+ for lineidx, line in enumerate(lines):
if 'pdb.set_trace' in line \
and not (-1 < line.find('#') < line.find('pdb.set_trace')):
- self.log(idx, line)
+ self.log(lineidx, line)
if 'from dbgp.client import brk; brk(' in line \
and not (-1 < line.find('#') < line.find('dbgp.client.brk')):
- self.log(idx, line)
+ self.log(lineidx, line)
if 'import rpdb2; rpdb2.start_embedded_debugger' in line \
and not (-1 < line.find('#') < line.find(
'rpdb2.start_embedded_debugger')):
- self.log(idx, line)
+ self.log(lineidx, line)
class OpenInBrowserChecker(BaseChecker):
error = 'openInBrowser found in line'
def check(self, filename, content, lines):
- for idx, line in enumerate(lines):
+ for lineidx, line in enumerate(lines):
if 'openInBrowser' in line \
and not (-1 < line.find('#') < line.find('openInBrowser')):
- self.log(idx, line)
+ self.log(lineidx, line)
class PyflakesChecker(BaseChecker):
@@ -152,7 +149,7 @@
if isinstance(result, basestring):
#something fatal occurred
self.error = result
- self.log(0)
+ self.log(noInfo=True)
else:
#there are messages
for warning in result:
@@ -166,10 +163,10 @@
error = 'Breakpoint found in line'
def check(self, filename, content, lines):
- for idx, line in enumerate(lines):
+ for lineidx, line in enumerate(lines):
if 'console.log' in line \
and not (-1 < line.find('//') < line.find('console.log')):
- self.log(idx, line)
+ self.log(lineidx, line)
class POChecker(BaseChecker):
@@ -225,7 +222,7 @@
if not 'i18n:domain' in content:
#bummer, here we go
- self.log(0, '')
+ self.log(noInfo=True)
class CSSLogger(object):
@@ -251,7 +248,7 @@
# unicode in doctests drives me mad
self.checker.error = msg.encode('ascii', 'replace')
# can't add much help, all info is encoded in msg
- self.checker.log(0)
+ self.checker.log(noInfo=True)
warn = error
critical = error
More information about the checkins
mailing list