diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-03-15 12:42:09 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-03-15 13:14:27 +0100 |
| commit | 039dc0e133229482ff93aac1eac07e1d06465d2f (patch) | |
| tree | cc1a10d865a219e9e259490347ae08052107f54c /repo/www | |
| parent | e1a97d377394b17ad76eb8d7e4eba5b5ebe47a8e (diff) | |
| download | memory-leaks-039dc0e133229482ff93aac1eac07e1d06465d2f.tar.xz | |
Stop duplicating list of text file extensions
Diffstat (limited to 'repo/www')
| -rw-r--r-- | repo/www/Makefile | 2 | ||||
| -rwxr-xr-x | repo/www/make-deps.py | 27 |
2 files changed, 21 insertions, 8 deletions
diff --git a/repo/www/Makefile b/repo/www/Makefile index 6bc53ea..ca50752 100644 --- a/repo/www/Makefile +++ b/repo/www/Makefile @@ -16,7 +16,7 @@ dependencies = deps.mk include $(dependencies) $(dependencies): make-deps.py $(text_folders) - python3 $< $(TOP_DIR) $(OUT_DIR) + python3 $< "$(TEXT_FILES)" $(TOP_DIR) $(OUT_DIR) site: $(pages) diff --git a/repo/www/make-deps.py b/repo/www/make-deps.py index 26a4037..189ccfd 100755 --- a/repo/www/make-deps.py +++ b/repo/www/make-deps.py @@ -32,16 +32,29 @@ class Directory: def parse_arguments(args): - if len(args) != 3: - exit(f'Usage: {argv[0]} TOP-DIR OUTPUT-DIR') + if len(args) != 4: + exit(f'Usage: {argv[0]} EXTENSIONS TOP-DIR OUTPUT-DIR') - return argv[1], argv[2] + return argv[1].split(), argv[2], argv[3] -def find_sources(top_dir): +def join(collections, joiner): + out = [] + + for c in collections[:-1]: + out.extend(c) + out.append(joiner) + + out.extend(collections[-1]) + return tuple(out) + + +def find_sources(extensions, top_dir): + filters = tuple(('-name', '*.'+ext) for ext in extensions) + p = run( # TODO: use git ls-files - ('find', top_dir, '-name', '*.md', '-o', '-name', '*.org'), + ('find', top_dir) + join(filters, '-o'), capture_output=True, check=True, text=True ) @@ -95,8 +108,8 @@ def write_dependencies(deps, directories, top_dir, out_dir): def main(arguments): - top_dir, out_dir = parse_arguments(arguments) - source_files = find_sources(top_dir) + extensions, top_dir, out_dir = parse_arguments(arguments) + source_files = find_sources(extensions, top_dir) directories = compute_directories(source_files, top_dir) |
