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
commit99196f23052a5d04ad5135b815d19ff4771db27c (patch)
treed919e2c2b7f33ae3d11dfafd4a6777abc81337de /epylint.py
parentc0b4d64b5cfea5b69c6f000ae07f42a5a943d32d (diff)
downloadpylint-git-99196f23052a5d04ad5135b815d19ff4771db27c.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 b7822455d..24baa61e9 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: