-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathname_to_cas.py
More file actions
40 lines (31 loc) · 1.07 KB
/
Copy pathname_to_cas.py
File metadata and controls
40 lines (31 loc) · 1.07 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
"""Legacy launcher for the original NIST name-to-CAS workbook workflow."""
from aromanexus.sources.nist import NistWebBookClient
from aromanexus.workflows import run_resolve_cas
INPUT_FILE = "name.xlsx"
COL_NAME = "Name"
COL_RESULT = "Found CAS"
def get_cas_by_name(name: object) -> str:
"""Compatibility helper returning the historic text statuses."""
result = NistWebBookClient().resolve_name(name)
if result.status == "ok":
return str(result.values.get("cas", "Not Found"))
return {
"ambiguous": "Ambiguous/List Found",
"not_found": "Not Found",
"network_error": "Connection Error",
}.get(result.status, "Error")
def main() -> None:
output = INPUT_FILE.replace(".xlsx", "_with_cas.xlsx")
summary = run_resolve_cas(
INPUT_FILE,
NistWebBookClient(),
output_path=output,
name_column=COL_NAME,
result_column=COL_RESULT,
include_provenance=False,
checkpoint_every=25,
force=True,
)
print(f"Done: {summary.output_path}")
if __name__ == "__main__":
main()