Commit bffdd13d authored by Antoine Beaupré's avatar Antoine Beaupré

make find_files and match_jobs APIs similar

this simplifies code as well
parent 03bf11c7
......@@ -55,18 +55,16 @@ def render(obj, srcdir):
mirror = obj['mirror']
patterns = obj['patterns']
if 'changed_paths' not in obj:'looking for patterns %s in %s', patterns, srcdir)
filelist = find_files(srcdir, patterns)
if not filelist:
filelist = []
# get modified paths from extractor, if it was also called
if 'changed_paths' in obj:
if srcdir:
logging.warn('ignoring --srcdir parameter because called with extractor')'received %d paths from extractor',
filelist = itertools.chain(filelist, obj['changed_paths'])
filelist = match_jobs(obj['changed_paths'], patterns)
else:'looking for patterns %s in %s', patterns, srcdir)
filelist = find_files(srcdir, patterns)
if obj['progress']:
progress = click.progressbar
......@@ -83,7 +81,7 @@ def render(obj, srcdir):
progress = fake_progress
i = 0
t = time.time()
with progress(list(match_jobs(filelist, patterns)),
with progress(list(filelist),
label='rendering manpages') as bar:
for job in bar:
dispatch(job, destdir=output, dryrun=obj['dryrun'],
......@@ -354,8 +352,8 @@ def find_files(directory, patterns):
reimplemented with :func:`scandir` if we ever depend on
Python 3.5 or later.
.. todo:: doesn't look at patterns at all?!
:return: ``module``, ``path`` tuples
:rtype: list
for root, dirs, files in os.walk(directory):
logging.debug('walking: %s %s %s', root, dirs, files)
......@@ -363,7 +361,7 @@ def find_files(directory, patterns):
path = os.path.join(root, path)
for regex, module in patterns.iteritems():
if, path):
yield path
yield module, path
def match_jobs(files, patterns):
......@@ -374,7 +372,7 @@ def match_jobs(files, patterns):
``regex``). ``regex`` is a compiled regex
patterns to match against the pathnames,
``cls`` is a CommandRenderer subclass to run
:return: ``command``, ``path`` tuples
:return: ``module``, ``path`` tuples
:rtype: list
for path in files:
......@@ -51,15 +51,15 @@ def search(pattern):
logger.debug('searching for pattern: %s', pattern)
patterns = {}
# XXX: this doesn't belong here? should be command-level patterns
patterns[re.compile(pattern)] = None
patterns[re.compile(pattern)] = ManpageRenderer
# XXX: not sure this is the best structure
manpages = {} # suite -> (name, section)
i = 0
assert app.static_folder
for path in find_files(app.static_folder, patterns):
for module, path in find_files(app.static_folder, patterns):
i += 1
# XXX: again
m =, path)
m =, path)
assert m
suite ='suite')
name ='name')
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment