Skip to content

Commit 12aef80

Browse files
committed
BLD: add verbose option to validate_unwanted_patterns.py
1 parent 5e30717 commit 12aef80

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

scripts/validate_unwanted_patterns.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ def main(
407407
output_format: str,
408408
file_extensions_to_check: str,
409409
excluded_file_paths: str,
410+
verbose: int,
410411
) -> bool:
411412
"""
412413
Main entry point of the script.
@@ -423,6 +424,8 @@ def main(
423424
Comma separated values of what file extensions to check.
424425
excluded_file_paths : str
425426
Comma separated values of what file paths to exclude during the check.
427+
verbose : int
428+
Verbosity level (currently only distinguishes between zero and nonzero).
426429
427430
Returns
428431
-------
@@ -450,14 +453,22 @@ def main(
450453
def check_file(file_path: str):
451454
nonlocal is_failed
452455

456+
local_is_failed = False
457+
if verbose:
458+
print("Checking {}...".format(file_path), file=sys.stderr, end="")
453459
with open(file_path, "r") as file_obj:
454460
for line_number, msg in function(file_obj):
455-
is_failed = True
461+
local_is_failed = True
456462
print(
457463
output_format.format(
458464
source_path=file_path, line_number=line_number, msg=msg
459465
)
460466
)
467+
if not local_is_failed:
468+
if verbose:
469+
print(" OK", file=sys.stderr)
470+
else:
471+
is_failed = True
461472

462473
def is_ignored(path: str):
463474
path = os.path.abspath(os.path.normpath(path))
@@ -526,6 +537,12 @@ def is_ignored(path: str):
526537
default="asv_bench/env",
527538
help="Comma separated file paths to exclude.",
528539
)
540+
parser.add_argument(
541+
"-v",
542+
"--verbose",
543+
action="count",
544+
help="Set the verbosity level to the number of times this flag is used.",
545+
)
529546

530547
args = parser.parse_args()
531548

@@ -536,5 +553,6 @@ def is_ignored(path: str):
536553
output_format=args.format,
537554
file_extensions_to_check=args.included_file_extensions,
538555
excluded_file_paths=args.excluded_file_paths,
556+
verbose=args.verbose,
539557
)
540558
)

0 commit comments

Comments
 (0)