diff options
author | Radosław Ganczarek <radoslaw@ganczarek.in> | 2015-07-25 14:02:22 +0200 |
---|---|---|
committer | Radosław Ganczarek <radoslaw@ganczarek.in> | 2015-07-25 14:02:22 +0200 |
commit | 645b0ce18fdb082112da1e6e6c78bf681f2c5af6 (patch) | |
tree | b340cb0c0efa46f05c7b87e68a183b0ae6cfb387 /astroid/modutils.py | |
parent | 1f6e4d633932f938224dbdf40fb29efb41ba0c10 (diff) | |
download | astroid-git-645b0ce18fdb082112da1e6e6c78bf681f2c5af6.tar.gz |
Add option to search for all Python files in get_module_files
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r-- | astroid/modutils.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py index 5a6c3471..605f5eb4 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -37,6 +37,7 @@ import sys from distutils.sysconfig import get_python_lib from distutils.errors import DistutilsPlatformError import zipimport +import scandir try: import pkg_resources @@ -393,7 +394,7 @@ def get_module_part(dotted_name, context_file=None): return dotted_name -def get_module_files(src_directory, blacklist): +def get_module_files(src_directory, blacklist, get_all=False): """given a package directory return a list of all available python module's files in the package and its subpackages @@ -406,16 +407,21 @@ def get_module_files(src_directory, blacklist): optional list of files or directory to ignore, default to the value of `logilab.common.STD_BLACKLIST` + :type get_all: bool + :para get_all: + boolean value of if we want to get all python files, + ignoring the missing __init__.py + :rtype: list :return: the list of all available python module's files in the package and its subpackages """ files = [] - for directory, dirnames, filenames in os.walk(src_directory): + for directory, dirnames, filenames in scandir.walk(src_directory): _handle_blacklist(blacklist, dirnames, filenames) # check for __init__.py - if not '__init__.py' in filenames: + if not get_all and not '__init__.py' in filenames: dirnames[:] = () continue for filename in filenames: |