Skip to content

Commit

Permalink
adding Sherejeel PR review.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Nov 28, 2023
1 parent fdeda34 commit 3d35c53
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pynxtools/dataconverter/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ def get_nxdl_root_and_path(nxdl: str):
# Reading in the NXDL and generating a template
definitions_path = nexus.get_nexus_definitions_path()
if nxdl == "NXtest":
nxdl_path = os.path.join(
nxdl_f_path = os.path.join(
f"{os.path.abspath(os.path.dirname(__file__))}/../../",
"tests", "data", "dataconverter", "NXtest.nxdl.xml")
elif nxdl == "NXroot":
nxdl_path = os.path.join(definitions_path, "base_classes", "NXroot.nxdl.xml")
nxdl_f_path = os.path.join(definitions_path, "base_classes", "NXroot.nxdl.xml")
else:
nxdl_path = os.path.join(definitions_path, "contributed_definitions", f"{nxdl}.nxdl.xml")
if not os.path.exists(nxdl_path):
nxdl_path = os.path.join(definitions_path, "applications", f"{nxdl}.nxdl.xml")
if not os.path.exists(nxdl_path):
nxdl_path = os.path.join(definitions_path, "base_classes", f"{nxdl}.nxdl.xml")
if not os.path.exists(nxdl_path):
nxdl_f_path = os.path.join(definitions_path, "contributed_definitions", f"{nxdl}.nxdl.xml")
if not os.path.exists(nxdl_f_path):
nxdl_f_path = os.path.join(definitions_path, "applications", f"{nxdl}.nxdl.xml")
if not os.path.exists(nxdl_f_path):
nxdl_f_path = os.path.join(definitions_path, "base_classes", f"{nxdl}.nxdl.xml")
if not os.path.exists(nxdl_f_path):
raise FileNotFoundError(f"The nxdl file, {nxdl}, was not found.")

return ET.parse(nxdl_path).getroot(), nxdl_path
return ET.parse(nxdl_f_path).getroot(), nxdl_f_path


def transfer_data_into_template(input_file,
Expand Down Expand Up @@ -191,7 +191,7 @@ def convert(input_file: Tuple[str, ...],
None.
"""

nxdl_root, nxdl_path = get_nxdl_root_and_path(nxdl)
nxdl_root, nxdl_f_path = get_nxdl_root_and_path(nxdl)

if generate_template:
template = Template()
Expand All @@ -217,7 +217,7 @@ def convert(input_file: Tuple[str, ...],
path
)
helpers.add_default_root_attributes(data=data, filename=os.path.basename(output))
Writer(data=data, nxdl_path=nxdl_path, output_path=output).write()
Writer(data=data, nxdl_path=nxdl_f_path, output_path=output).write()

logger.info("The output file generated: %s", output)

Expand Down

0 comments on commit 3d35c53

Please sign in to comment.