def from_flat_repr(self,fact_list,include_node_id=False,no_attributes=False,track_namespaces=True,namespace_mapping=None):
if not namespace_mapping:<EOL><INDENT>namespace_mapping = {}<EOL><DEDENT>name_counter = {'<STR_LIT>':<NUM_LIT:0>}<EOL>def make_ns_slug(name_counter,slug='<STR_LIT:n>'):<EOL><INDENT>while "<STR_LIT>" % (slug,name_counter['<STR_LIT>']) in namespace_mapping.values():<EOL><INDENT>name_counter['<STR_LIT>']  = name_counter['<STR_LIT>']+<NUM_LIT:1><EOL><DEDENT>return "<STR_LIT>" % (slug,name_counter['<STR_LIT>'])<EOL><DEDENT>if include_node_id or track_namespaces:<EOL><INDENT>no_attributes=False<EOL><DEDENT>def node_id_unpack(n):<EOL><INDENT>"""<STR_LIT>"""<EOL>return (n[<NUM_LIT:0>],int(n[<NUM_LIT:1>:]))<EOL><DEDENT>fact_list.sort(key=lambda x : x['<STR_LIT>'])<EOL>result = self<EOL>for fact in fact_list:<EOL><INDENT>current_ns_slug = {-<NUM_LIT:1>:None}<EOL>fact_path = fact['<STR_LIT>'].split('<STR_LIT:/>')<EOL>del(fact['<STR_LIT>'])<EOL>if fact.get('<STR_LIT>'):<EOL><INDENT>if fact_path == ["<STR_LIT>"]:<EOL><INDENT>fact_path = []<EOL><DEDENT>fact_path.append('<STR_LIT>' % fact['<STR_LIT>'])<EOL>del(fact['<STR_LIT>'])<EOL><DEDENT>node_path = fact['<STR_LIT>'].split('<STR_LIT::>')<EOL>del(fact['<STR_LIT>'])<EOL>if '<STR_LIT>' in fact.keys():<EOL><INDENT>namespace_map = fact['<STR_LIT>']<EOL>del(fact['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>namespace_map = None<EOL><DEDENT>walker = result<EOL>walker_parent=None<EOL>for i in range(<NUM_LIT:0>,len(node_path)):<EOL><INDENT>namespace_slug=None<EOL>if track_namespaces and namespace_map:<EOL><INDENT>try:<EOL><INDENT>namespace = namespace_map.namespaces_thru.get(position=i).namespace.uri<EOL><DEDENT>except:<EOL><INDENT>namespace = None<EOL><DEDENT>if namespace:<EOL><INDENT>if not namespace in namespace_mapping:<EOL><INDENT>namespace_slug = make_ns_slug(name_counter)<EOL>namespace_mapping[namespace] = namespace_slug<EOL><DEDENT>else:<EOL><INDENT>namespace_slug= namespace_mapping[namespace]<EOL><DEDENT><DEDENT><DEDENT>current_ns_slug[i] = namespace_slug<EOL>(node_kind,counter) = node_id_unpack(node_path[i])<EOL>element = fact_path[i]<EOL>node_id = '<STR_LIT::>'.join(node_path[<NUM_LIT:0>:i+<NUM_LIT:1>])<EOL>if no_attributes and i == len(node_path)-<NUM_LIT:1> and node_kind== '<STR_LIT:A>':<EOL><INDENT>continue<EOL><DEDENT>if not (element in walker.keys()):<EOL><INDENT>if node_kind == '<STR_LIT:L>':<EOL><INDENT>walker[element] = []<EOL>child_dict = DingoObjDict()<EOL>if include_node_id:<EOL><INDENT>child_dict['<STR_LIT>'] = node_id<EOL><DEDENT>if namespace_slug and current_ns_slug[i] != current_ns_slug[i-<NUM_LIT:1>]:<EOL><INDENT>child_dict['<STR_LIT>'] = current_ns_slug[i]<EOL><DEDENT>walker[element].append(child_dict)<EOL>walker_parent = walker<EOL>walker = walker[element][<NUM_LIT:0>]<EOL><DEDENT>elif node_kind == '<STR_LIT:N>':<EOL><INDENT>child_dict = DingoObjDict()<EOL>if include_node_id:<EOL><INDENT>child_dict['<STR_LIT>'] = node_id<EOL><DEDENT>if namespace_slug and current_ns_slug[i] != current_ns_slug[i-<NUM_LIT:1>]:<EOL><INDENT>child_dict['<STR_LIT>'] = current_ns_slug[i]<EOL><DEDENT>walker[element] = child_dict<EOL>walker_parent = walker<EOL>walker = walker[element]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if node_kind == '<STR_LIT:L>':<EOL><INDENT>if len(walker[element]) == counter:<EOL><INDENT>next_item = DingoObjDict()<EOL>if include_node_id:<EOL><INDENT>next_item['<STR_LIT>'] = node_id<EOL><DEDENT>walker[element].append(next_item)<EOL>walker_parent=walker<EOL>walker=walker[element][counter]<EOL><DEDENT>elif len(walker[element]) > counter:<EOL><INDENT>walker_parent=walker<EOL>walker = walker[element][counter]<EOL><DEDENT>else:<EOL><INDENT>logger.error("<STR_LIT>" % (element,counter,node_id))<EOL>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>walker_parent=walker<EOL>walker=walker[element]<EOL><DEDENT><DEDENT><DEDENT>if node_kind == '<STR_LIT:A>':<EOL><INDENT>if no_attributes:<EOL><INDENT>continue<EOL><DEDENT>if len(fact['<STR_LIT>']) == <NUM_LIT:1>:<EOL><INDENT>value = fact['<STR_LIT>'][<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>value = fact['<STR_LIT>']<EOL><DEDENT>if include_node_id:<EOL><INDENT>walker[element] = {'<STR_LIT>' : node_id,<EOL>'<STR_LIT>' : value}<EOL><DEDENT>else:<EOL><INDENT>walker[element] = value<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(fact['<STR_LIT>']) == <NUM_LIT:1>:<EOL><INDENT>if fact['<STR_LIT>'][<NUM_LIT:0>] != '<STR_LIT>':<EOL><INDENT>if no_attributes:<EOL><INDENT>walker_parent[element] = fact['<STR_LIT>'][<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>walker['<STR_LIT>'] = fact['<STR_LIT>'][<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if no_attributes:<EOL><INDENT>walker_parent[element] = fact['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>walker['<STR_LIT>'] = fact['<STR_LIT>']<EOL><DEDENT><DEDENT>if include_node_id:<EOL><INDENT>walker['<STR_LIT>'] = node_id<EOL><DEDENT>del(fact['<STR_LIT>'])<EOL>if not no_attributes:<EOL><INDENT>for key in fact:<EOL><INDENT>if fact[key]:<EOL><INDENT>walker[key] = fact[key]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if track_namespaces:<EOL><INDENT>return namespace_mapping<EOL><DEDENT>
Convert a flat representation of information (consisting of a fact list and a dictionary
mapping node ids to attributes into a dictionary representation information.

Input Example (CybOx)::


  { '00': { 'condition': 'Equals', 'datatype': 'String'},
    '01:L00:00': { 'condition': 'Equals', 'datatype': 'hexBinary'},
    '01:L00:01': { 'datatype': 'String'},
    '01:L01:00': { 'condition': 'Equals', 'datatype': 'hexBinary'},
    '01:L01:01': { 'datatype': 'String'}
  }

Output Example::

    {'File_Name': {'@condition': 'Equals', '@datatype': 'String', '_value': u'UNITED NATIONS COMPENSATION SCHEME...pdf'},
      'Hashes': {'Hash': [{'Simple_Hash_Value':
                            {'@condition': 'Equals',
                             '@datatype': 'hexBinary',
                              '_value': u'576fea79dd23a352a14c3f8bf3dbc9eb732e1d54f804a29160894aec55df4bd5'},
                           'Type': {'@datatype': 'String', '_value': 'SHA256'}},
                          {'Simple_Hash_Value': {'@condition': 'Equals',
                                                 '@datatype': 'hexBinary',
                                                 '_value': u'491809c2092cecd633e43d465409a78c'},
                           'Type': {'@datatype': 'String', '_value': 'MD5'}}]
                }
    }