epylint: ensure it uses the same python/pylint version. Closes #87024

also, drop usage of sub-shell on the way.

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changesetf673b9738dcd
branchdefault
phasepublic
hiddenno
parent revision#cf3067485953 Added tag pylint-debian-version-0.25.1-1 for changeset 3a6cf40ab050
child revision#c0a307bd6161 fix crash when decorators are accessed through more than one dot. Closes #87192
files modified by this revision
epylint.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1326140710 -3600
# Mon Jan 09 21:25:10 2012 +0100
# Node ID f673b9738dcd6c1f1a458e4763c123f2ad9d607c
# Parent cf3067485953c3ade5b307abffe34a36284cfd74
epylint: ensure it uses the same python/pylint version. Closes #87024

also, drop usage of sub-shell on the way.

diff --git a/epylint.py b/epylint.py
@@ -56,14 +56,15 @@
1      while parentPath != "/" and os.path.exists(os.path.join(parentPath, '__init__.py')):
2          childPath = os.path.join(os.path.basename(parentPath), childPath)
3          parentPath = os.path.dirname(parentPath)
4 
5      # Start pylint
6 -    process = Popen('pylint -f parseable -r n --disable=C,R,I "%s"' %
7 -                    childPath, shell=True, stdout=PIPE, stderr=PIPE,
8 -                    cwd=parentPath)
9 -    p = process.stdout
10 +    # Ensure we use the python and pylint associated with the running epylint
11 +    lintPath = os.path.join(os.path.dirname(__file__), 'lint.py')
12 +    cmd = [sys.executable, lintPath, '-f', 'parseable', '-r', 'n',
13 +           '--disable=C,R,I', childPath]
14 +    process = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=parentPath)
15 
16      # The parseable line format is '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s'
17      # NOTE: This would be cleaner if we added an Emacs reporter to pylint.reporters.text ..
18      regex = re.compile(r"\[(?P<type>[WE])(?P<remainder>.*?)\]")
19 
@@ -74,25 +75,26 @@
20          else:
21              replacement = "Error"
22          # replace as "Warning (W0511, funcName): Warning Text"
23          return "%s (%s%s):" % (replacement, mObj.group("type"), mObj.group("remainder"))
24 
25 -    for line in p:
26 +    for line in process.stdout:
27          # remove pylintrc warning
28          if line.startswith("No config file found"):
29              continue
30          line = regex.sub(_replacement, line, 1)
31          # modify the file name thats output to reverse the path traversal we made
32          parts = line.split(":")
33          if parts and parts[0] == childPath:
34              line = ":".join([filename] + parts[1:])
35          print line,
36 
37 -    p.close()
38 +    process.wait()
39 +    return process.returncode
40 
41  def Run():
42 -    lint(sys.argv[1])
43 +    sys.exit(lint(sys.argv[1]))
44 
45 
46  def py_run(command_options='', return_std=False, stdout=None, stderr=None,
47             script='epylint'):
48      """Run pylint from python (needs Python >= 2.4).