From c6ebf9d643e4fbed68232f21c018856d858e86b0 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Sun, 7 Aug 2022 19:42:28 +0100 Subject: [PATCH] vk/update-aliases.py: allow specifying the files we want to update Part-of: --- src/vulkan/registry/update-aliases.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vulkan/registry/update-aliases.py b/src/vulkan/registry/update-aliases.py index 77071bcd8dd..f44b7607aa2 100755 --- a/src/vulkan/registry/update-aliases.py +++ b/src/vulkan/registry/update-aliases.py @@ -56,7 +56,7 @@ def chunks(lst: list, n: int): yield lst[i:i + n] -def main(): +def main(paths: list[str]): """ Entrypoint; perform the search for all the aliases and replace them. """ @@ -93,10 +93,10 @@ def main(): 'grep', '-rlP', '|'.join(aliases_chunk), - 'src/' - ], stderr=subprocess.DEVNULL).decode() + ] + paths, stderr=subprocess.DEVNULL).decode() files_with_aliases.update(search_output.splitlines()) + def file_matches_path(file: str, path: str) -> bool: # if path is a folder; match any file within if path.endswith('/') and file.startswith(path): @@ -128,5 +128,9 @@ def main(): if __name__ == '__main__': parser = argparse.ArgumentParser() + parser.add_argument('paths', + nargs=argparse.ZERO_OR_MORE, + default=['src/'], + help='Limit script to these paths (default: `src/`)') args = parser.parse_args() main(**vars(args))