From dd1d13ba958bcc596911992cdd28b2cb8c2fe1a3 Mon Sep 17 00:00:00 2001 From: Berk Onat <b.onat@warwick.ac.uk> Date: Sat, 31 Mar 2018 18:53:32 +0100 Subject: [PATCH] Fixing meta info writer for NoneType topology. --- .../smart_parser/SmartParserCommon.py | 57 +++++++++++++++---- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/common/python/nomadcore/smart_parser/SmartParserCommon.py b/common/python/nomadcore/smart_parser/SmartParserCommon.py index 346dc8e..604d9e5 100644 --- a/common/python/nomadcore/smart_parser/SmartParserCommon.py +++ b/common/python/nomadcore/smart_parser/SmartParserCommon.py @@ -233,19 +233,54 @@ class ParserBase(object): """ sO = open_section supB = backend.superBackend + topoDict = None if self.topology: topoDict = self.topology.topoDict - types_list = topoDict["types_list"] - atom_type_list = topoDict["atom_type_list"] - atomlabelList = topoDict["atom_label_list"] - name_list = topoDict["name_list"] - massesList = topoDict["atom_mass_list"] - elementList = topoDict["element_list"] - atomelementList = topoDict["atom_element_list"] - radiusList = topoDict["atom_radius_list"] - chargeList = topoDict["atom_charge_list"] - interDict = topoDict["interactions_dict"] - interTypeDict = topoDict["interactions_type_dict"] + if topoDict: + if "types_list" in topoDict: + types_list = topoDict["types_list"] + else: + types_list = [] + if "atom_type_list" in topoDict: + atom_type_list = topoDict["atom_type_list"] + else: + atom_type_list = [] + if "atom_label_list" in topoDict: + atomlabelList = topoDict["atom_label_list"] + else: + atomlabelList = [] + if "name_list" in topoDict: + name_list = topoDict["name_list"] + else: + name_list = [] + if "atom_mass_list" in topoDict: + massesList = topoDict["atom_mass_list"] + else: + massesList = [] + if "element_list" in topoDict: + elementList = topoDict["element_list"] + else: + elementList = [] + if "atom_element_list" in topoDict: + atomelementList = topoDict["atom_element_list"] + else: + atomelementList = [] + if "atom_radius_list" in topoDict: + radiusList = topoDict["atom_radius_list"] + else: + radiusList = [] + if "atom_charge_list" in topoDict: + chargeList = topoDict["atom_charge_list"] + else: + chargeList = [] + if "interactions_dict" in topoDict: + interDict = topoDict["interactions_dict"] + else: + interDict = [] + if "interactions_type_dict" in topoDict: + interTypeDict = topoDict["interactions_type_dict"] + else: + interTypeDict = [] for elm in range(len(types_list)): with sO(supB, 'section_atom_type'): # Atom Type NOMAD Name -- GitLab