From fab5ce0ee6e2bc98c9b94bfe550561d51ea485d9 Mon Sep 17 00:00:00 2001 From: Ritwik Sharma Date: Fri, 14 Dec 2018 01:20:11 +0530 Subject: [PATCH 1/3] Update expand_source_files( ) Allow files with all extensions irrespective of ".py" --- importlab/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/importlab/utils.py b/importlab/utils.py index f2a9cfa..ebe0fd4 100644 --- a/importlab/utils.py +++ b/importlab/utils.py @@ -66,22 +66,21 @@ def expand_source_files(filenames, cwd=None): This is a helper function for handling command line arguments that specify a list of source files and directories. - Any directories in filenames will be scanned recursively for .py files. - Any files that do not end with ".py" will be dropped. + Any directories in filenames will be scanned recursively for files. Args: filenames: A list of filenames to process. cwd: An optional working directory to expand relative paths Returns: - A set of full paths to .py files + A set of full paths to files """ out = [] for f in expand_paths(filenames, cwd): if os.path.isdir(f): - # If we have a directory, collect all the .py files within it. - out += collect_files(f, ".py") + # If we have a directory, collect all the files within it. + out += collect_files(f, ".*") else: - if f.endswith(".py"): + if f.endswith(".*"): out.append(f) return set(out) From 0f395d756b814efa647da4ab0a64ac181fda014e Mon Sep 17 00:00:00 2001 From: Ritwik Sharma Date: Fri, 14 Dec 2018 01:45:45 +0530 Subject: [PATCH 2/3] Update for all file extension --- importlab/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/importlab/utils.py b/importlab/utils.py index ebe0fd4..fef5f08 100644 --- a/importlab/utils.py +++ b/importlab/utils.py @@ -56,7 +56,10 @@ def collect_files(path, extension): out = [] # glob would be faster (see PEP471) but python glob doesn't do **/* for root, _, files in os.walk(path): - out += [os.path.join(root, f) for f in files if f.endswith(extension)] + if extension is None: + out += [os.path.join(root, f) for f in files] + else: + out += [os.path.join(root, f) for f in files if f.endswith(extension)] return out @@ -80,8 +83,7 @@ def expand_source_files(filenames, cwd=None): # If we have a directory, collect all the files within it. out += collect_files(f, ".*") else: - if f.endswith(".*"): - out.append(f) + out.append(f) return set(out) From f98129c68543513aa085a484563599558faef8c1 Mon Sep 17 00:00:00 2001 From: Ritwik Sharma Date: Fri, 14 Dec 2018 21:33:23 +0530 Subject: [PATCH 3/3] Update expand_source_files( ) --- importlab/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importlab/utils.py b/importlab/utils.py index fef5f08..364eef7 100644 --- a/importlab/utils.py +++ b/importlab/utils.py @@ -81,7 +81,7 @@ def expand_source_files(filenames, cwd=None): for f in expand_paths(filenames, cwd): if os.path.isdir(f): # If we have a directory, collect all the files within it. - out += collect_files(f, ".*") + out += collect_files(f, None) else: out.append(f) return set(out)