dkist-header-validator 5.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ """Package providing support classes and methods used by all workflow tasks."""
2
+ from importlib.metadata import PackageNotFoundError
3
+ from importlib.metadata import version
4
+
5
+ from dkist_header_validator.exceptions import *
6
+ from dkist_header_validator.spec_validators import *
7
+
8
+ try:
9
+ __version__ = version(distribution_name=__name__)
10
+ except PackageNotFoundError:
11
+ # package is not installed
12
+ __version__ = "unknown"
File without changes
@@ -0,0 +1,66 @@
1
+ import typer
2
+
3
+ from dkist_header_validator.spec_validators import spec122_validator
4
+ from dkist_header_validator.spec_validators import Spec122ValidationException
5
+ from dkist_header_validator.spec_validators import spec214_validator
6
+ from dkist_header_validator.spec_validators import Spec214ValidationException
7
+
8
+ app = typer.Typer(help="CLI for the dkist-header-validator package")
9
+ """
10
+ Command Line Interface for the dkist-header-validator package
11
+ """
12
+
13
+
14
+ @app.command("validate122")
15
+ def validate122(
16
+ filename: str = typer.Argument(help="Location of the FITS file on disk", default=None)
17
+ ):
18
+ """
19
+ Validate a FITS file for SPEC-0122 compliance.
20
+
21
+ SPEC failures are:
22
+ - Extra keywords not included in SPEC-0122
23
+ - Keywords with values of the wrong type (float instead of string, for example)
24
+ - SPEC-0122 keywords that are missing
25
+ - SPEC-0122 keywords with invalid values compared to the valid list given in the SPEC
26
+ """
27
+ try:
28
+ spec122_validator.validate(filename, extra=False)
29
+ print(f"No validation errors found in file {filename}")
30
+ except Spec122ValidationException as e:
31
+ print(f"Validation errors in file {filename}")
32
+ for key, value in e.errors.items():
33
+ print(f"{key}: {value}")
34
+
35
+
36
+ @app.command("validate214")
37
+ def validate214(
38
+ filename: str = typer.Argument(help="Location of the FITS file on disk", default=None)
39
+ ):
40
+ """
41
+ Validate a FITS file for SPEC-0214 compliance.
42
+
43
+ SPEC failures are:
44
+ - Extra keywords not included in SPEC-0214
45
+ - Keywords with values of the wrong type (float instead of string, for example)
46
+ - SPEC-0214 keywords that are missing
47
+ - SPEC-0214 keywords with invalid values compared to the valid list given in the SPEC
48
+ """
49
+ try:
50
+ spec214_validator.validate(filename, extra=False)
51
+ print(f"No validation errors found in file {filename}")
52
+ except Spec214ValidationException as e:
53
+ print(f"Validation errors in file {filename}")
54
+ for key, value in e.errors.items():
55
+ print(f"{key}: {value}")
56
+
57
+
58
+ def main():
59
+ """
60
+ CLI for the dkist-header-validator package
61
+ """
62
+ app()
63
+
64
+
65
+ if __name__ == "__main__":
66
+ main()