diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-06 23:50:46 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-06-06 23:50:46 -0400 |
commit | 16f6bee13c9b568c898a9997e2813b343ca98596 (patch) | |
tree | 7f3dc13ab920aa3e6c4151555fb6494295200613 /cmd2/cmd2.py | |
parent | 6cdf70823b344b99d6623af19fb618a9c2dbdad4 (diff) | |
download | cmd2-git-16f6bee13c9b568c898a9997e2813b343ca98596.tar.gz |
Extracted duplicated code to utility function
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 3b47ee9e..520ac33d 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1163,7 +1163,7 @@ class Cmd(cmd.Cmd): # Find every executable file in the user's path that matches the pattern for path in paths: full_path = os.path.join(path, starts_with) - matches = [f for f in glob.glob(full_path + '*') if os.path.isfile(f) and os.access(f, os.X_OK)] + matches = utils.files_from_glob_pattern(full_path + '*', access=os.X_OK) for match in matches: exes_set.add(os.path.basename(match)) @@ -3707,9 +3707,9 @@ class Cmd(cmd.Cmd): :return: list of transcript file paths with glob patterns expanded """ expanded_transcripts = [] - for fileset in transcript_paths: - for fname in glob.glob(fileset): - expanded_transcripts.append(fname) + for pattern in transcript_paths: + files = utils.files_from_glob_pattern(pattern, access=os.R_OK) + expanded_transcripts.extend(files) return expanded_transcripts def run_transcript_tests(self, transcript_paths: List[str]) -> None: |