removed some prints

This commit is contained in:
Tarek Ziade 2012-02-21 13:19:35 +01:00
parent cf16bf82b9
commit d8f6e431f1
2 changed files with 17 additions and 5 deletions

View file

@ -13,6 +13,16 @@ class Message(object):
return '%s:%s: %s' % (self.filename, self.lineno,
self.message % self.message_args)
def __lt__(self, other):
if self.filename != other.filename:
return self.filename < other.filename
return self.lineno < other.lineno
def __cmp__(self, other):
if self.filename != other.filename:
return cmp(self.filename, other.filename)
return cmp(self.lineno, other.lineno)
class UnusedImport(Message):
message = '%r imported but unused'

View file

@ -9,6 +9,7 @@ except ImportError:
import os.path
import _ast
import sys
from flake8 import messages
from flake8.util import skip_warning
@ -645,7 +646,7 @@ def checkPath(filename):
return check(open(filename, 'U').read() + '\n', filename)
except IOError:
msg = sys.exc_info()[1]
print >> sys.stderr, "%s: %s" % (filename, msg.args[1])
sys.stderr.write("%s: %s\n" % (filename, msg.args[1]))
return 1
@ -677,18 +678,19 @@ def check(codeString, filename='(code)'):
# Avoid using msg, since for the only known case, it contains a
# bogus message that claims the encoding the file declared was
# unknown.
print >> sys.stderr, "%s: problem decoding source" % (filename, )
sys.stderr.write("%s: problem decoding source\n" % (filename))
else:
line = text.splitlines()[-1]
if offset is not None:
offset = offset - (len(text) - len(line))
print >> sys.stderr, '%s:%d: %s' % (filename, lineno, msg)
print >> sys.stderr, line
sys.stderr.write('%s:%d: %s\n' % (filename, lineno, msg))
sys.stderr.write(line + '\n')
if offset is not None:
print >> sys.stderr, " " * offset, "^"
sys.stderr.write(" " * offset + "^\n")
return 1
else: