diff --git a/common/python/nomadcore/smart_parser/SmartParserCommon.py b/common/python/nomadcore/smart_parser/SmartParserCommon.py index 346dc8e76b91a6656a9c0b3694a255d908a87d34..604d9e5b19550d281355aedcca736e645d3d4a4b 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