Show More
@@ -48,14 +48,14 b' Supported syntax in globs (wilcard matching patterns)::' | |||||
48 | rec:*.py |
|
48 | rec:*.py | |
49 | - All .py files under current working dir, recursively |
|
49 | - All .py files under current working dir, recursively | |
50 | foo |
|
50 | foo | |
51 |
- File |
|
51 | - File or dir foo | |
52 | !*.bak readme* |
|
52 | !*.bak readme* | |
53 | - readme*, exclude files ending with .bak |
|
53 | - readme*, exclude files ending with .bak | |
54 | !.svn/ !.hg/ !*_Data/ rec:. |
|
54 | !.svn/ !.hg/ !*_Data/ rec:. | |
55 | - Skip .svn, .hg, foo_Data dirs (and their subdirs) in recurse. |
|
55 | - Skip .svn, .hg, foo_Data dirs (and their subdirs) in recurse. | |
56 | Trailing / is the key, \ does not work! |
|
56 | Trailing / is the key, \ does not work! | |
57 | dir:foo |
|
57 | dir:foo | |
58 | - the directory foo (not files in foo) |
|
58 | - the directory foo if it exists (not files in foo) | |
59 | dir:* |
|
59 | dir:* | |
60 | - all directories in current folder |
|
60 | - all directories in current folder | |
61 | foo.py bar.* !h* rec:*.py |
|
61 | foo.py bar.* !h* rec:*.py | |
@@ -73,12 +73,15 b' import os,glob,fnmatch,sys' | |||||
73 | from sets import Set as set |
|
73 | from sets import Set as set | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | def expand(flist): |
|
76 | def expand(flist,exp_dirs = False): | |
77 | """ Expand the glob(s) in flist. |
|
77 | """ Expand the glob(s) in flist. | |
78 |
|
78 | |||
79 | flist may be either a whitespace-separated list of globs/files |
|
79 | flist may be either a whitespace-separated list of globs/files | |
80 | or an array of globs/files. |
|
80 | or an array of globs/files. | |
81 |
|
81 | |||
|
82 | if exp_dirs is true, directory names in glob are expanded to the files | |||
|
83 | contained in them - otherwise, directory names are returned as is. | |||
|
84 | ||||
82 | """ |
|
85 | """ | |
83 | if isinstance(flist, basestring): |
|
86 | if isinstance(flist, basestring): | |
84 | flist = flist.split() |
|
87 | flist = flist.split() | |
@@ -157,7 +160,7 b' def expand(flist):' | |||||
157 | res.extend(once_filter(filter(os.path.isdir,glob.glob(ent[4:])))) |
|
160 | res.extend(once_filter(filter(os.path.isdir,glob.glob(ent[4:])))) | |
158 |
|
161 | |||
159 | # get all files in the specified dir |
|
162 | # get all files in the specified dir | |
160 | elif os.path.isdir(ent): |
|
163 | elif os.path.isdir(ent) and exp_dirs: | |
161 | res.extend(once_filter(filter(os.path.isfile,glob.glob(ent + os.sep+"*")))) |
|
164 | res.extend(once_filter(filter(os.path.isfile,glob.glob(ent + os.sep+"*")))) | |
162 |
|
165 | |||
163 | # glob only files |
|
166 | # glob only files |
General Comments 0
You need to be logged in to leave comments.
Login now