summaryrefslogtreecommitdiff
path: root/epylint.py
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2013-12-22 23:41:57 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2013-12-22 23:41:57 +0100
commitd8895fcb65ecd958b627298b32b0592565ef137e (patch)
tree57cdbc1a28493d1f131fa2b4a8a3ff6611c7fa2b /epylint.py
parentd3f5227f8903cf72d7de78d0c2a9fc2948b19ca9 (diff)
downloadpylint-d8895fcb65ecd958b627298b32b0592565ef137e.tar.gz
various pylint fixes
Diffstat (limited to 'epylint.py')
-rwxr-xr-xepylint.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/epylint.py b/epylint.py
index b782245..24baa61 100755
--- a/epylint.py
+++ b/epylint.py
@@ -47,6 +47,7 @@ its output.
"""
import sys, os, re
+import os.path as osp
from subprocess import Popen, PIPE
@@ -67,34 +68,36 @@ def lint(filename, options=None):
the tree)
"""
# traverse downwards until we are out of a python package
- fullPath = os.path.abspath(filename)
- parentPath, childPath = os.path.dirname(fullPath), os.path.basename(fullPath)
+ full_path = osp.abspath(filename)
+ parent_path = osp.dirname(full_path)
+ child_path = osp.basename(full_path)
- while parentPath != "/" and os.path.exists(os.path.join(parentPath, '__init__.py')):
- childPath = os.path.join(os.path.basename(parentPath), childPath)
- parentPath = os.path.dirname(parentPath)
+ while parent_path != "/" and osp.exists(osp.join(parent_path, '__init__.py')):
+ child_path = osp.join(osp.basename(parent_path), child_path)
+ parent_path = osp.dirname(parent_path)
# Start pylint
# Ensure we use the python and pylint associated with the running epylint
- from pylint import lint
- lintPath = lint.__file__
+ from pylint import lint as lint_mod
+ lint_path = lint_mod.__file__
options = options or ['--disable=C,R,I']
- cmd = [sys.executable, lintPath] + options + ['--msg-template',
- '{path}:{line}: [{symbol}, {obj}] {msg}', '-r', 'n', childPath]
- process = Popen(cmd, stdout=PIPE, cwd=parentPath, universal_newlines=True)
+ cmd = [sys.executable, lint_path] + options + ['--msg-template',
+ '{path}:{line}: [{symbol}, {obj}] {msg}', '-r', 'n', child_path]
+ process = Popen(cmd, stdout=PIPE, cwd=parent_path, universal_newlines=True)
# The parseable line format is '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s'
# NOTE: This would be cleaner if we added an Emacs reporter to pylint.reporters.text ..
regex = re.compile(r"\[(?P<type>[WE])(?P<remainder>.*?)\]")
- def _replacement(mObj):
+ def _replacement(match_object):
"Alter to include 'Error' or 'Warning'"
- if mObj.group("type") == "W":
+ if match_object.group("type") == "W":
replacement = "Warning"
else:
replacement = "Error"
# replace as "Warning (W0511, funcName): Warning Text"
- return "%s (%s%s):" % (replacement, mObj.group("type"), mObj.group("remainder"))
+ return "%s (%s%s):" % (replacement, match_object.group("type"),
+ match_object.group("remainder"))
for line in process.stdout:
# remove pylintrc warning
@@ -103,7 +106,7 @@ def lint(filename, options=None):
line = regex.sub(_replacement, line, 1)
# modify the file name thats output to reverse the path traversal we made
parts = line.split(":")
- if parts and parts[0] == childPath:
+ if parts and parts[0] == child_path:
line = ":".join([filename] + parts[1:])
print line,
@@ -167,7 +170,7 @@ def Run():
if len(sys.argv) == 1:
print "Usage: %s <filename> [options]" % sys.argv[0]
sys.exit(1)
- elif not os.path.exists(sys.argv[1]):
+ elif not osp.exists(sys.argv[1]):
print "%s does not exist" % sys.argv[1]
sys.exit(1)
else: