def detail(self, i_format): """See :meth:`.Data_Handler.BaseDetailer.detail`""" assert isinstance(i_format, dict) # Extract the DictHandlerKey_Attr data dict_attrs = i_format.get(DictHandlerKey_Attr, []) try: assert isinstance(dict_attrs, list) except Exception: raise RuntimeError( 'Dictionary contains "DictHandlerKey_Attr" key but the value is not list.' + '\n' ' ' + 'DictHandlerKey_Attr : ' + '\n' (' ' * 2) + str(dict_attrs)) # Extract the DictHandlerKey_Choice data dict_choices = i_format.get(DictHandlerKey_Choice, {}) try: assert isinstance(dict_choices, dict) except Exception: raise RuntimeError( 'Dictionary contains "DictHandlerKey_Choice" key but the value is not dict.' + '\n' ' ' + 'DictHandlerKey_Choice : ' + '\n' (' ' * 2) + str(dict_choices)) # Create a detail object detail = DataDetail(DataType.Complex, self.data_handler, i_format) detail.children = {} # Check if the i_value is optional if DictHandlerAttr_Optional in dict_attrs: detail.is_optional = True i_format_key = None # Encapsulate the entire object to append the name of the tag being # normalized in any exceptions that are thrown. try: # Loop over the available choice groups # TODO: Figure out what to do with complex choices # Go over the mandatory attributes for i_format_key, i_format_value in i_format.items(): if i_format_key in _DictHandlerKeysList: continue # Ensure the structure data is of correct type assert isinstance(i_format_key, str) # Update the value using the normalized value detail.children[i_format_key] = self.generic_detail( i_format_value) except Exception as e: raise type(e), type(e)(('' if i_format_key is None else ( i_format_key + '->')) + str(e)), sys.exc_info()[2] return detail
def detail(self, i_format): """See :meth:`.Data_Handler.BaseDetailer.detail`""" assert isinstance(i_format, list) detail = DataDetail(DataType.List, self.data_handler, i_format) detail.children = [] for element in i_format: detail.children.append(self.generic_detail(element)) return detail