-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
47 lines (37 loc) · 1.29 KB
/
__main__.py
File metadata and controls
47 lines (37 loc) · 1.29 KB
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
import argparse
from pathlib import Path
from mast_contributor_tools.filename_check.hlsp_filename import HlspFileName
from mast_contributor_tools.utils.logger_config import setup_logger
logger = setup_logger(__name__)
def main(inFile: str, hlspName: str):
"""HLSP filename module CLI driver.
Parameters
----------
inFile : str
Name of example HLSP product
hlspName : str
Name of example HLSP collection
"""
fp = Path(inFile)
hfn = HlspFileName(fp, hlspName)
hfn.partition()
hfn.create_fields()
elements = hfn.evaluate_fields()
file_rec = hfn.evaluate_filename()
# Display results
logger.info("Filename parameters:")
for p, v in file_rec.items():
print(f" {p}: {v}")
logger.info("Field parameters:")
for e in elements:
for p, v in e.items():
logger.info(f" {p}: {v}")
if __name__ == "__main__":
"""HLSP filename module entry point.
"""
descr_text = "Validate a specific name of an HLSP science product"
parser = argparse.ArgumentParser(description=descr_text)
parser.add_argument("in_file", type=str, help="Name of an HLSP product")
parser.add_argument("hlsp_name", type=str, help="Name of HLSP collection")
args = parser.parse_args()
main(args.in_file, args.hlsp_name)