Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/50.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed typo, "ncfc22" should have been "hcfc22" (see [#39](https://github.com/WCRP-CMIP/Variable-Registry/issues/39))
46 changes: 46 additions & 0 deletions scripts/39-fixes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Fixes from #39
"""

from __future__ import annotations

import json
from pathlib import Path


def main():
"""
Apply the fixes
"""
REPO_ROOT = Path(__file__).parents[1]

for branded_variable, mapping in (("ncfc22_tavg-u-hm-u", ("ncfc", "hcfc")),):
with open(
REPO_ROOT / "src-data" / "variable" / f"{branded_variable}.json"
) as fh:
working = json.load(fh)

for key in working:
if working[key] is None:
continue

if isinstance(working[key], list):
working[key] = [v.replace(*mapping) for v in working[key]]

else:
working[key] = working[key].replace(*mapping)

with open(
REPO_ROOT
/ "src-data"
/ "variable"
/ f"{branded_variable.replace(*mapping)}.json",
"w",
) as fh:
json.dump(working, fh, indent=4)

(REPO_ROOT / "src-data" / "variable" / f"{branded_variable}.json").unlink()


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "ncfc22_tavg-u-hm-u",
"validation-key": "ncfc22_tavg-u-hm-u",
"id": "hcfc22_tavg-u-hm-u",
"validation-key": "hcfc22_tavg-u-hm-u",
"ui-label": "Global Mean Mole Fraction of HCFC22",
"description": "Mole fraction is used in the construction mole\\_fraction\\_of\\_X\\_in\\_Y, where X is a material constituent of Y. A chemical species denoted by X may be described by a single term such as 'nitrogen' or a phrase such as 'nox\\_expressed\\_as\\_nitrogen'. The chemical formula for HCFC22 is CHClF2. The IUPAC name for HCFC22 is chloro-difluoro-methane.",
"area-label": "u",
Expand Down
Loading