summaryrefslogtreecommitdiff
path: root/config.py
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2006-08-09 15:27:30 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2006-08-09 15:27:30 +0200
commitd0ebd20cc4427f14bef83d6d77861b36008cea86 (patch)
treebbebc7ba88dafdc0ec1f37219ef217c236bf70b3 /config.py
parent160cba648c2278f2a6ef02564f9a65cdd48324c6 (diff)
downloadpylint-d0ebd20cc4427f14bef83d6d77861b36008cea86.tar.gz
find pylintrc in parent directory until we're not in a package anymore
Diffstat (limited to 'config.py')
-rw-r--r--config.py41
1 files changed, 26 insertions, 15 deletions
diff --git a/config.py b/config.py
index d5b4e9b..e3e11eb 100644
--- a/config.py
+++ b/config.py
@@ -71,22 +71,33 @@ def save_results(results, base):
# location of the configuration file ##########################################
-# is there a pylint rc file in the current directory ?
-if exists('pylintrc'):
- PYLINTRC = abspath('pylintrc')
-elif os.environ.has_key('PYLINTRC') and exists(os.environ['PYLINTRC']):
- PYLINTRC = os.environ['PYLINTRC']
-else:
- USER_HOME = expanduser('~')
- if USER_HOME == '~' or USER_HOME == '/root':
- PYLINTRC = ".pylintrc"
- else:
- PYLINTRC = join(USER_HOME, '.pylintrc')
-if not isfile(PYLINTRC):
- if isfile('/etc/pylintrc'):
- PYLINTRC = '/etc/pylintrc'
+
+def find_pylintrc():
+ # is there a pylint rc file in the current directory ?
+ if exists('pylintrc'):
+ return abspath('pylintrc')
+ if isfile('__init__.py'):
+ curdir = abspath(os.getcwd())
+ while isfile(join(curdir, '__init__.py')):
+ curdir = abspath(join(curdir, '..'))
+ if isfile(join(curdir, 'pylintrc')):
+ return join(curdir, 'pylintrc')
+ if os.environ.has_key('PYLINTRC') and exists(os.environ['PYLINTRC']):
+ pylintrc = os.environ['PYLINTRC']
else:
- PYLINTRC = None
+ USER_HOME = expanduser('~')
+ if USER_HOME == '~' or USER_HOME == '/root':
+ pylintrc = ".pylintrc"
+ else:
+ pylintrc = join(USER_HOME, '.pylintrc')
+ if not isfile(pylintrc):
+ if isfile('/etc/pylintrc'):
+ pylintrc = '/etc/pylintrc'
+ else:
+ pylintrc = None
+ return pylintrc
+
+PYLINTRC = find_pylintrc()
ENV_HELP = '''
The following environment variables are used :