Skip to content

Commit

Permalink
typo and test.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Sep 12, 2024
1 parent 620ce87 commit fde8058
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/pynxtools/nomad/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@
import pynxtools.nomad.schema as nexus_schema
from pynxtools.nexus.nexus import HandleNexus

# from pynxtools.nomad.utils import __rename_nx_to_nomad

__REPLARCEMENT_FOR_NX = "BS"
__REPLARCEMENT_LEN = len(__REPLARCEMENT_FOR_NX)
__REPLACEMENT_FOR_NX = "BS"
__REPLACEMENT_LEN = len(__REPLACEMENT_FOR_NX)


def _rename_nx_to_nomad(name: str) -> Optional[str]:
Expand All @@ -56,7 +54,7 @@ def _rename_nx_to_nomad(name: str) -> Optional[str]:
return name
if name is not None:
if name.startswith("NX"):
return name.replace("NX", __REPLARCEMENT_FOR_NX)
return name.replace("NX", __REPLACEMENT_FOR_NX)
return name


Expand All @@ -66,7 +64,7 @@ def _to_group_name(nx_node: ET.Element):
"""
# assuming always upper() is incorrect, e.g. NXem_msr is a specific one not EM_MSR!
grp_nm = nx_node.attrib.get(
"name", nx_node.attrib["type"][__REPLARCEMENT_LEN:].upper()
"name", nx_node.attrib["type"][__REPLACEMENT_LEN:].upper()
)

return grp_nm
Expand Down
4 changes: 2 additions & 2 deletions src/pynxtools/nomad/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

from pynxtools import get_definitions_url
from pynxtools.definitions.dev_tools.utils.nxdl_utils import get_nexus_definitions_path
from pynxtools.nomad.utils import __REPLACEMNT_FOR_NX, __rename_nx_to_nomad
from pynxtools.nomad.utils import __REPLACEMENT_FOR_NX, __rename_nx_to_nomad

# __URL_REGEXP from
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
Expand Down Expand Up @@ -557,7 +557,7 @@ def __create_group(xml_node: ET.Element, root_section: Section):
__add_common_properties(group, group_section)

nx_name = xml_attrs.get(
"name", nx_type.replace(__REPLACEMNT_FOR_NX, "").upper()
"name", nx_type.replace(__REPLACEMENT_FOR_NX, "").upper()
)
group_subsection = SubSection(
section_def=group_section,
Expand Down
4 changes: 2 additions & 2 deletions src/pynxtools/nomad/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from typing import Optional

__REPLACEMNT_FOR_NX = "BS"
__REPLACEMENT_FOR_NX = "BS"


def __rename_nx_to_nomad(name: str) -> Optional[str]:
Expand All @@ -31,5 +31,5 @@ def __rename_nx_to_nomad(name: str) -> Optional[str]:
return name
if name is not None:
if name.startswith("NX"):
return name.replace("NX", __REPLACEMNT_FOR_NX)
return name.replace("NX", __REPLACEMENT_FOR_NX)
return name

0 comments on commit fde8058

Please sign in to comment.