Last active
August 29, 2015 14:26
-
-
Save godber/64c0dbcf4ac37e48e1dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from glob import glob | |
| def file_dir_glob_list(inlist=None): | |
| """Given a list of files, directories or globs, returns a fully expanded | |
| list of files | |
| """ | |
| file_list = [] | |
| if inlist: | |
| for item in inlist: | |
| if os.path.isdir(item): | |
| # If item is a directory, get all the files in the directory | |
| file_list.append(glob(os.path.join('%s' % (item), '*'))) | |
| elif item: | |
| # If its not a directory, then its either a glob or a file, | |
| # globbing it will work for either | |
| file_list.append(glob(item)) | |
| else: | |
| file_list = file_list.append(glob('*')) | |
| return file_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...