This class acts as an iterator on account of its next() method.
Basically, it just goes through all the files in a directory in order
(depth-first) and subjects each file to a bunch of tests (selection
functions) in order. The first test that includes or excludes the file
means that the file gets included (iterated) or excluded. The default is
include, so with no tests we would just iterate all the files in the
directory in order.
The one complication to this is that sometimes we don't know whether
or not to include a directory until we examine its contents. For
instance, if we want to include all the **.py files. If /home/ben/foo.py
exists, we should also include /home and /home/ben, but if these
directories contain no **.py files, they shouldn't be included. For this
reason, a test may not include or exclude a directory, but merely
"scan" it. If later a file in the directory gets included, so
does the directory.
As mentioned above, each test takes the form of a selection function.
The selection function takes a path, and returns:
None - means the test has nothing to say about the related file 0 -
the file is excluded by the test 1 - the file is included 2 - the test
says the file (must be directory) should be scanned
Also, a selection function f has a variable f.exclude which should be
true iff f could potentially exclude some file. This is used to signal
an error if the last function only includes, which would be redundant and
presumably isn't what the user intends.
|
|
__init__(self,
path)
Initializer, called with Path of root directory |
source code
|
|
|
|
set_iter(self)
Initialize generator, prepare to iterate. |
source code
|
|
|
|
|
|
|
Select(self,
path)
Run through the selection functions and return dominant val
0/1/2 |
source code
|
|
|
|
ParseArgs(self,
argtuples,
filelists)
Create selection functions based on list of tuples |
source code
|
|
|
|
parse_catch_error(self,
exc)
Deal with selection error exc |
source code
|
|
|
|
parse_last_excludes(self)
Exit with error if last selection function isn't an exclude |
source code
|
|
|
|
add_selection_func(self,
sel_func,
add_to_start=None)
Add another selection function at the end or beginning |
source code
|
|
|
|
|
|
|
filelist_read(self,
filelist_fp,
include,
filelist_name)
Read filelist from fp, return (tuplelist, something_excluded) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
other_filesystems_get_sf(self,
include)
Return selection function matching files on other filesystems |
source code
|
|
|
|
regexp_get_sf(self,
regexp_string,
include)
Return selection function given by regexp_string |
source code
|
|
|
|
devfiles_get_sf(self)
Return a selection function to exclude all dev files |
source code
|
|
|
|
glob_get_sf(self,
glob_str,
include)
Return selection function given by glob string |
source code
|
|
|
|
present_get_sf(self,
filename,
include)
Return selection function given by existence of a file in a
directory |
source code
|
|
|
|
|
|
|
glob_get_tuple_sf(self,
tuple,
include)
Return selection function based on tuple |
source code
|
|
|
|
|
|
|
glob_get_prefix_res(self,
glob_str)
Return list of regexps equivalent to prefixes of glob_str |
source code
|
|
|
|
|