Skip to content

Commit

Permalink
fix for entry_type assignment (#464)
Browse files Browse the repository at this point in the history
* fix for entry_type assignment

* remove prints
  • Loading branch information
sanbrock authored Nov 15, 2024
1 parent 3fbf36d commit a31431b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/pynxtools/nomad/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,26 @@ def parse(
archive.metadata = EntryMetadata()

# Normalise experiment type
app_def = str(self.nx_root).split("(")[1].split(")")[0].split(",")[0]
app_defs = str(self.nx_root).split("(")[1].split(")")[0].split(",")
app_def_list = []
for app_elem in app_defs:
app = app_elem.lstrip()
try:
app_sec = getattr(self.nx_root, app)
try:
app_entry = getattr(app_sec, "ENTRY")
except AttributeError:
app_entry = getattr(app_sec, "entry")
app_def_list.append(
app if app != rename_nx_for_nomad("NXroot") else "Generic"
)
except AttributeError:
pass
if len(app_def_list) == 0:
app_def = "Experiment"
app_def = ", ".join(app_def_list) + (
" Experiment" if len(app_def_list) == 1 else "Experiments"
)
if archive.metadata.entry_type is None:
archive.metadata.entry_type = app_def
archive.metadata.domain = "nexus"
Expand Down

0 comments on commit a31431b

Please sign in to comment.