-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from cedadev/formatting
Formatting and documentation updates
- Loading branch information
Showing
23 changed files
with
1,164 additions
and
607 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
"""Console script for checksit.""" | ||
|
||
__author__ = """Ag Stephens""" | ||
__contact__ = '[email protected]' | ||
__contact__ = "[email protected]" | ||
__copyright__ = "Copyright 2022 United Kingdom Research and Innovation" | ||
__license__ = "BSD - see LICENSE file in top-level package directory" | ||
|
||
import click | ||
import os | ||
|
||
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.""" | ||
|
@@ -35,12 +37,30 @@ def main(): | |
@click.option("-t", "--template", default="auto") | ||
@click.option("-w", "--ignore-warnings", is_flag=True) | ||
@click.option("-p", "--skip-spellcheck", 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, | ||
skip_spellcheck=False): | ||
|
||
if ignore_all_globals or ignore_all_dimensions or ignore_all_variables or ignore_all_variable_attrs: | ||
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, | ||
skip_spellcheck=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: | ||
|
@@ -55,10 +75,19 @@ def check(file_path, mappings=None, rules=None, specs=None, ignore_attrs=None, i | |
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, skip_spellcheck=skip_spellcheck) | ||
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, | ||
skip_spellcheck=skip_spellcheck, | ||
) | ||
|
||
|
||
@main.command() | ||
|
@@ -68,28 +97,44 @@ def check(file_path, mappings=None, rules=None, specs=None, ignore_attrs=None, i | |
@click.option("-x", "--exclude", default=None) | ||
@click.option("-e", "--exclude-file", default=None) | ||
@click.option("--verbose/--no-verbose", default=False) | ||
def summary(log_files=None, log_directory=None, show_files=False, | ||
exclude=None, exclude_file=None, | ||
verbose=False): | ||
def summary( | ||
log_files=None, | ||
log_directory=None, | ||
show_files=False, | ||
exclude=None, | ||
exclude_file=None, | ||
verbose=False, | ||
): | ||
|
||
if exclude: | ||
exclude = string_to_list(exclude) | ||
exclude = string_to_list(exclude) | ||
else: | ||
exclude = [] | ||
|
||
if exclude_file: | ||
if not os.path.isfile(exclude_file): | ||
raise Exception(f"'--exclude-file' does not point to a valid file") | ||
|
||
with open(exclude_file) as exfile: | ||
exclude.extend([exclude_pattern for exclude_pattern in exfile if exclude_pattern.strip()]) | ||
|
||
return summarise(log_files, log_directory=log_directory, show_files=show_files, | ||
exclude=exclude, verbose=verbose) | ||
exclude.extend( | ||
[ | ||
exclude_pattern | ||
for exclude_pattern in exfile | ||
if exclude_pattern.strip() | ||
] | ||
) | ||
|
||
return summarise( | ||
log_files, | ||
log_directory=log_directory, | ||
show_files=show_files, | ||
exclude=exclude, | ||
verbose=verbose, | ||
) | ||
|
||
|
||
@main.command() | ||
@click.argument("check_ids", nargs=-1, default=None) | ||
@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) | ||
|
@@ -104,4 +149,3 @@ def show_specs(spec_ids=None, verbose=False): | |
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.