-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.py
86 lines (65 loc) · 3 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Console script for checksit."""
__author__ = """Ag Stephens"""
__contact__ = 'ag.stephens@stfc.ac.uk'
__copyright__ = "Copyright 2022 United Kingdom Research and Innovation"
__license__ = "BSD - see LICENSE file in top-level package directory"
import click
from .utils import string_to_dict, string_to_list
from .check import check_file
from .summary import summarise
from . import describer
from . import specs
@click.group()
def main():
"""Console script for checker."""
return 0
@main.command()
@click.argument("file_path")
@click.option("-m", "--mappings", default=None)
@click.option("-r", "--rules", default=None)
@click.option("-s", "--specs", default=None)
@click.option("-i", "--ignore-attrs", default=None)
@click.option("-G", "--ignore-all-globals", default=False)
@click.option("-D", "--ignore-all-dimensions", default=False)
@click.option("-V", "--ignore-all-variables", default=False)
@click.option("-A", "--ignore-all-variable-attrs", default=False)
@click.option("--auto-cache/--no-auto-cache", default=False)
@click.option("-l", "--log-mode", default="standard")
@click.option("-v", "--verbose/--no-verbose", default=False)
@click.option("-t", "--template", default="auto")
@click.option("-w", "--ignore-warnings", is_flag=True)
def check(file_path, mappings=None, rules=None, specs=None, ignore_attrs=None, ignore_all_globals=False,
ignore_all_dimensions=False, ignore_all_variables=False, ignore_all_variable_attrs=False,
auto_cache=False, log_mode="standard", verbose=False, template="auto", ignore_warnings=False):
if ignore_all_globals or ignore_all_dimensions or ignore_all_variables or ignore_all_variable_attrs:
raise Exception("Options not implemented yet!!!!!")
if mappings:
mappings = string_to_dict(mappings)
if rules:
rules = string_to_dict(rules)
if specs:
specs = string_to_list(specs)
if ignore_attrs:
ignore_attrs = string_to_list(ignore_attrs)
return check_file(file_path, template=template, mappings=mappings, extra_rules=rules,
specs=specs, ignore_attrs=ignore_attrs,
auto_cache=auto_cache, verbose=verbose,
log_mode=log_mode, ignore_warnings=ignore_warnings)
@main.command()
@click.argument("log_files", nargs=-1, default=None)
@click.option("-d", "--log-directory", default=None)
@click.option("--verbose/--no-verbose", default=False)
def summary(log_files=None, log_directory=None, verbose=False):
return summarise(log_files, log_directory=log_directory, verbose=verbose)
@main.command()
@click.argument("check_ids", nargs=-1, default=None)
@click.option("--verbose/--no-verbose", default=False)
def describe(check_ids=None, verbose=False):
return describer.describe(check_ids, verbose=verbose)
@main.command()
@click.argument("spec_ids", nargs=-1, default=None)
@click.option("--verbose/--no-verbose", default=False)
def show_specs(spec_ids=None, verbose=False):
return specs.show_specs(spec_ids, verbose=verbose)
if __name__ == "__main__":
main()