Skip to content

Commit

Permalink
ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Nov 21, 2023
1 parent 61a945c commit 540c850
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pynxtools/dataconverter/readers/sts/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def overwrite_fields(template, data_dict,
path_to_data = data_path[unit]
unit = transform_to_intended_dt(data_dict[path_to_data] if path_to_data in data_dict
else None)
template[new_temp_key + "/@units"] =
template[new_temp_key + "/@units"] = unit


def nested_path_to_slash_separated_path(nested_dict: dict,
Expand Down
23 changes: 11 additions & 12 deletions pynxtools/dataconverter/readers/sts/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,32 +195,31 @@ def read(self,
fl_obj: object
if ext in ['sxm', 'dat']:
data_file = file
if ext == 'json':
with open(file, mode="r", encoding="utf-8") as fl_obj:
config_dict = json.load(fl_obj)
if ext in ['yaml', 'yml']:
with open(file, mode="r", encoding="utf-8") as fl_obj:
with open(file, encoding="utf-8", mode="r") as fl_obj:
eln_dict = flatten_and_replace(
FlattenSettings(
yaml.safe_load(fl_obj),
CONVERT_DICT,
REPLACE_NESTED
replace_nested=REPLACE_NESTED,
convert_dict=CONVERT_DICT,
)
)
if ext == 'json':
with open(file, mode="r", encoding="utf-8") as fl_obj:
config_dict = json.load(fl_obj)

# Get callable object that has parser inside
parser = Spm().get_appropriate_parser(eln_dict)
parser(template, data_file, config_dict, eln_dict)

for key, val in template.items():

if val is None:
del template[key]
else:
if val is not None:
filled_template[key] = val
else:
del template[key]

if not filled_template.keys():
raise ValueError("Reader could not read anything! Check for input files and the"
" corresponding extention.")
raise ValueError("Reader could not read anything! Check for input files")
return filled_template


Expand Down
9 changes: 4 additions & 5 deletions pynxtools/dataconverter/readers/xrd/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def get_template_from_xrd_reader(nxdl_name, file_paths):
Parameters
----------
nxdl_name : str_
nxdl_name : str
Name of nxdl definition
file_paths : str
_description_
file_paths : Tuple[str]
Tuple of path of files.
Returns
-------
Expand Down Expand Up @@ -141,8 +141,7 @@ def read(self,
eln_dict = flatten_and_replace(
FlattenSettings(
yaml.safe_load(fl_obj),
CONVERT_DICT,
REPLACE_NESTED
CONVERT_DICT, REPLACE_NESTED
)
)
elif ext in XRD_FILE_EXTENSIONS:
Expand Down

0 comments on commit 540c850

Please sign in to comment.