Skip to content

Commit

Permalink
Runing XRD plugin without any error.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Oct 18, 2023
1 parent 469b95f commit e1d799a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pynxtools/dataconverter/readers/xrd/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# }

REPLACE_NESTED: Dict[str, str] = {}
XRD_FILE_EXTENSIONS = [".xrdml", ".udf", ".raw", ".xye"]
XRD_FILE_EXTENSIONS = [".xrdml", "xrdml", ".udf", ".raw", ".xye"]


def get_template_from_nxdl_name(nxdl_name):
Expand Down Expand Up @@ -89,7 +89,7 @@ def get_template_from_nxdl_name(nxdl_name):
if root is None and full_nxdl_path.exists():
root = ET.parse(full_nxdl_path).getroot()
else:
full_nxdl_path = (def_path, 'base_classes', nxdl_file)
full_nxdl_path = Path(def_path, 'base_classes', nxdl_file)

if root is None and full_nxdl_path.exists():
root = ET.parse(full_nxdl_path).getroot()
Expand Down Expand Up @@ -120,16 +120,20 @@ def read(self,
template: dict = None,
file_paths: Tuple[str] = None,
objects: Tuple[Any] = None):
"""General read menthod to prepare the template.
"""
General read menthod to prepare the template.
"""

if not isinstance(file_paths, tuple) and not isinstance(file_paths, list):
file_paths = (file_paths,)
print(' input files: ', file_paths)
filled_template: Union[Dict, None] = Template()
eln_dict: Union[Dict[str, Any], None] = None
config_dict: Dict = {}
data_file: str = ""
xrd_file_ext: str = ""
for file in file_paths:
ext = "".join(Path(file).suffixes)
print('file extension: ', ext)
if ext == '.json':
with open(file, mode="r", encoding="utf-8") as fl_obj:
config_dict = json.load(fl_obj)
Expand All @@ -147,7 +151,7 @@ def read(self,
xrd_dict = parse_and_convert_file(file)

# Feeding xrd data from xrdml type file
if xrd_file_ext == ".xrdml":
if xrd_file_ext in [".xrdml", "xrdml"]:
feed_xrdml_to_template(template, xrd_dict, config_dict, eln_dict)
# Feeding xrd data from udf type file
elif xrd_file_ext == ".udf":
Expand Down

0 comments on commit e1d799a

Please sign in to comment.