diff options
author | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-05 13:13:42 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-05 13:13:42 (GMT) |
commit | b124747fd79b14b6b4fa7b3d89724339b1ba7d5b (patch) | |
tree | 135ff0c3557c404e144b8876220abd647a07f05a /pep8_check.py | |
parent | 8230036cb7189202181ac76fa54912ef3f0c3f91 (diff) |
PEP8 fixes
Signed-off-by: Agustin Zubiaga <aguzubiaga97@gmail.com>
Diffstat (limited to 'pep8_check.py')
-rw-r--r-- | pep8_check.py | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/pep8_check.py b/pep8_check.py index 4d002bc..04954e4 100644 --- a/pep8_check.py +++ b/pep8_check.py @@ -1,38 +1,48 @@ #!/usr/bin/env python -# -*- coding: UTF-8 -*- +import logging + +log = logging.getLogger('EditJam') +log.setLevel(logging.DEBUG) +logging.basicConfig() import commands class PEP8_Check(): - def check_file(self, text, editor): - tmp_file = open("/tmp/jamedit-pep8-chk.py", "w") - tmp_file.write(text) - chk = self.get_check() - - tmp_file.close() - - self.highlight_errors(editor, chk) - - def highlight_errors(self, editor, chk): - for key in chk.keys(): - # Here highlight errors whit tag pep8-error - pass - - def get_check(self): - output = commands.getoutput("pep8 /tmp/jamedit-pep8-chk.py") - check = self.interpret_output(output) - return check - - def interpret_output(self, output): - checks = {} - outputs = output.split("\n") - for out in outputs: - try: - splits = out.split(":") - line = splits[1] - error = splits[3] - checks[line] = error - except: pass - - return checks + def check_file(self, text, editor): + tmp_file = open("/tmp/jamedit-pep8-chk.py", "w") + tmp_file.write(text) + tmp_file.close() + + chk = self.get_check() + + self.highlight_errors(editor, chk) + + def highlight_errors(self, editor, chk): + for key in chk.keys(): + # Here highlight errors whit tag pep8-error + log.debug('%s: %s' % (key, chk[key])) + + def get_check(self): + (status, output) = commands.getstatusoutput( + "pep8 -r /tmp/jamedit-pep8-chk.py") + check = self.interpret_output(output) + return check + + def interpret_output(self, output): + checks = {} + outputs = output.split("\n") + for out in outputs: + try: + splits = out.split(":") + line = splits[1] + character = splits[2] + error = splits[3] + if line not in checks: + checks[line] = '%s:%s' % (character, error) + else: + checks[line] = '%s; %s:%s' % ( + checks[line], character, error) + except: pass + + return checks |