From d0d0705bee30cc0ea9dd8b37b78d7311822ee181 Mon Sep 17 00:00:00 2001 From: Diogo Cruz <92991667+diogoocruz@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:44:21 +0100 Subject: [PATCH 1/2] ignore files added --- burocrata/cli.py | 10 +++++++++- pyproject.toml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/burocrata/cli.py b/burocrata/cli.py index edc42cc..4847632 100644 --- a/burocrata/cli.py +++ b/burocrata/cli.py @@ -78,7 +78,13 @@ def main(extension, check, verbose, directories): reporter.error(config_file.read_text()) sys.exit(1) notice = config["tool"]["burocrata"]["notice"].split("\n") - + + ######### + if "exclude" in config["tool"]["burocrata"]: + exclude = config["tool"]["burocrata"]["exclude"] + exclude = pathspec.PathSpec.from_lines("gitwildmatch", exclude) + ######## + gitignore = get_gitignore() missing_notice = [] @@ -88,6 +94,8 @@ def main(extension, check, verbose, directories): for path in directory.glob(f"**/*.{ext}"): if gitignore.match_file(path): continue + if exclude.match_file(path): + continue amount += 1 source_code = path.read_text().split("\n") if not source_code: diff --git a/pyproject.toml b/pyproject.toml index 8835ccc..dd42fb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,3 +61,4 @@ notice = ''' # Distributed under the terms of the MIT License. # SPDX-License-Identifier: MIT # This code is part of the Fatiando a Terra project (https://www.fatiando.org).''' +exclude=[] From d7b78a76bdd087b528a268405337606cae45821a Mon Sep 17 00:00:00 2001 From: Diogo Cruz <92991667+diogoocruz@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:26:01 +0100 Subject: [PATCH 2/2] ignore command added --- burocrata/cli.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/burocrata/cli.py b/burocrata/cli.py index 4847632..9048ec1 100644 --- a/burocrata/cli.py +++ b/burocrata/cli.py @@ -40,13 +40,21 @@ show_default=True, help="Print information during execution / Don't print", ) +@click.option( + "--ignore", + "-i", + default=None, + show_default=True, + help="A comma separated list of directories to ignore during the analysis ", + +) @click.version_option() @click.argument( "directories", type=click.Path(exists=True, file_okay=False, path_type=pathlib.Path), nargs=-1, ) -def main(extension, check, verbose, directories): +def main(extension, check, verbose, directories, ignore): """ Burocrata: Check and insert copyright and license notices into source code @@ -84,7 +92,12 @@ def main(extension, check, verbose, directories): exclude = config["tool"]["burocrata"]["exclude"] exclude = pathspec.PathSpec.from_lines("gitwildmatch", exclude) ######## - + if ignore: + ignore = ignore.split(",") + print(ignore) + ignore = [i for i in ignore] + ignore = pathspec.PathSpec.from_lines("gitwildmatch", ignore) + gitignore = get_gitignore() missing_notice = [] @@ -96,6 +109,9 @@ def main(extension, check, verbose, directories): continue if exclude.match_file(path): continue + if ignore: + if ignore.match_file(path): + continue amount += 1 source_code = path.read_text().split("\n") if not source_code: