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.
- dkist_header_validator/__init__.py +12 -0
- dkist_header_validator/api/__init__.py +0 -0
- dkist_header_validator/api/validate.py +66 -0
- dkist_header_validator/base_validator.py +751 -0
- dkist_header_validator/exceptions.py +51 -0
- dkist_header_validator/spec_validators.py +54 -0
- dkist_header_validator/tests/__init__.py +0 -0
- dkist_header_validator/tests/conftest.py +639 -0
- dkist_header_validator/tests/test_base_validator.py +494 -0
- dkist_header_validator/tests/test_spec122_translation.py +233 -0
- dkist_header_validator/tests/test_spec122_validation+.py +144 -0
- dkist_header_validator/tests/test_spec122_validation-.py +118 -0
- dkist_header_validator/tests/test_spec214_validation+.py +402 -0
- dkist_header_validator/tests/test_spec214_validation-.py +211 -0
- dkist_header_validator/tests/test_translator.py +114 -0
- dkist_header_validator/translator.py +251 -0
- dkist_header_validator/utils/__init__.py +0 -0
- dkist_header_validator/utils/expansions.py +18 -0
- dkist_header_validator/version.py +8 -0
- dkist_header_validator-5.2.0.dist-info/METADATA +151 -0
- dkist_header_validator-5.2.0.dist-info/RECORD +24 -0
- dkist_header_validator-5.2.0.dist-info/WHEEL +5 -0
- dkist_header_validator-5.2.0.dist-info/entry_points.txt +2 -0
- dkist_header_validator-5.2.0.dist-info/top_level.txt +1 -0
|
@@ -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()
|