- for f in os.listdir(path):
- fn = os.path.join(path, f)
- if os.path.isfile(fn) and matches(fn, pattern, negate):
- file_output(cap, [fn])
- elif os.path.isdir(fn):
- tree_output(cap, fn, pattern, negate)
+ for root, dirs, files in os.walk(path):
+ fns = [fn for fn in [os.path.join(root, f) for f in files]
+ if os.path.isfile(fn) and matches(fn, pattern, negate)]
+ file_output(cap, fns, newest_first=newest_first,
+ last_mod_time=last_mod_time)
+
+
+def prefix_output(cap, prefix, newest_first=False, last_mod_time=None):
+ """
+ Output files with the same prefix.
+ """
+ fns = []
+ for root, dirs, files in os.walk(os.path.dirname(prefix)):
+ fns += [fn for fn in [os.path.join(root, f) for f in files]
+ if fn.startswith(prefix)]
+ file_output(cap, fns, newest_first=newest_first,
+ last_mod_time=last_mod_time)
+