Ignore:
Timestamp:
04/15/10 08:46:14 (2 years ago)
Author:
Luper Rouch <luper.rouch@…>
Children:
a5ddfc01388e61386872d1e2747d8bfcccb65937
Parents:
d52a2e9e1acc40b1056ae2f58806bd9a4b6aff00
git-committer:
Luper Rouch <luper.rouch@…> (04/15/10 08:46:14)
Message:

pyflu.setuptools.cython: added more Extension arguments to the etension() class method, added an option to exclude files from search

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyflu/pyflu/path.py

    r0a610e3 r6408560  
    1212 
    1313 
    14 def iter_files(ext_filter, path="."): 
     14def iter_files(ext_filter, path=".", exclude=None): 
    1515    """ 
    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. 
    1821    """ 
    1922    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) 
    2433 
    2534 
Note: See TracChangeset for help on using the changeset viewer.