diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-11 15:16:18 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-03-12 11:02:35 +0100 |
commit | a96f60eeec49110748d9180724d74a05dd74f136 (patch) | |
tree | 531fb595338da0f9390de7adf1e9ceabcb797012 /pylint/utils/utils.py | |
parent | 3649312233b39a74b4f631bae1e242f5bc7bde2c (diff) | |
download | pylint-git-a96f60eeec49110748d9180724d74a05dd74f136.tar.gz |
Move _get_python_path in utils to be accessible by that file as well
Diffstat (limited to 'pylint/utils/utils.py')
-rw-r--r-- | pylint/utils/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index d5fe8f6ea..dec15f29a 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -115,6 +115,20 @@ def _modpath_from_file(filename, is_namespace): ) +def get_python_path(filepath): + dirname = os.path.realpath(os.path.expanduser(filepath)) + if not os.path.isdir(dirname): + dirname = os.path.dirname(dirname) + while True: + if not os.path.exists(os.path.join(dirname, "__init__.py")): + return dirname + old_dirname = dirname + dirname = os.path.dirname(dirname) + if old_dirname == dirname: + return os.getcwd() + return None + + def expand_modules(files_or_modules, black_list, black_list_re): """take a list of files/modules/packages and return the list of tuple (file, module name) which have to be actually checked |