Changeset 640856057f0d1c086ec5c7f136d658cc5fc15205 for pyflu/pyflu/path.py
- Timestamp:
- 04/15/10 08:46:14 (2 years ago)
- Children:
- a5ddfc01388e61386872d1e2747d8bfcccb65937
- Parents:
- d52a2e9e1acc40b1056ae2f58806bd9a4b6aff00
- git-committer:
- Luper Rouch <luper.rouch@…> (04/15/10 08:46:14)
- File:
-
- 1 edited
-
pyflu/pyflu/path.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pyflu/pyflu/path.py
r0a610e3 r6408560 12 12 13 13 14 def iter_files(ext_filter, path="." ):14 def iter_files(ext_filter, path=".", exclude=None): 15 15 """ 16 An iterator returning all the files under ``path`` whose extension matches 17 ``ext_filter``. 16 An iterator returning all the files under *path* whose extension matches 17 *ext_filter*. 18 19 The optional *exclude* argument should be a list of paths prefixes to 20 exclude from the search. 18 21 """ 19 22 for dirpath, dirname, filenames in os.walk(path): 20 for fname in filenames: 21 name, ext = splitext(fname) 22 if ext == ext_filter: 23 yield join(dirpath, fname) 23 excluded = False 24 for excl_path in exclude: 25 if dirpath.startswith(excl_path): 26 excluded = True 27 break 28 if not excluded: 29 for fname in filenames: 30 name, ext = splitext(fname) 31 if ext == ext_filter: 32 yield join(dirpath, fname) 24 33 25 34
Note: See TracChangeset
for help on using the changeset viewer.
