Mercurial > hg > drupalISMI
diff importFromOpenMind/importer/ismi2model.py @ 33:7e2e344c3b87
make name of type attribute configurable. default '_type' for nodes.
author | casties |
---|---|
date | Tue, 02 Feb 2016 14:41:08 +0100 |
parents | ce12475d2109 |
children | 74dfaed3600b |
line wrap: on
line diff
--- a/importFromOpenMind/importer/ismi2model.py Fri Jan 22 20:41:25 2016 +0100 +++ b/importFromOpenMind/importer/ismi2model.py Tue Feb 02 14:41:08 2016 +0100 @@ -23,6 +23,9 @@ 'notes_old' ] +# name of type attribute +node_type_attribute = '_type' +rel_type_attribute = 'type' entsURL=baseURL+"method=get_ents&oc=%s" @@ -149,16 +152,8 @@ print("ERROR: entity type doesn't match!") return None - # rename if type attr exists - if 'type' in attrs: - attrs['type2'] = attrs['type'] - if '_n_type' in attrs: - # rename normalized attribute - attrs['_n_type2'] = attrs['_n_type'] - del attrs['n_type'] - # set type - attrs['type'] = fixName(oc) + attrs[node_type_attribute] = fixName(oc) ismi_id = ent['id'] # rename id to ismi_id @@ -234,7 +229,8 @@ continue # create relation with type - nx_rel = nx_graph.add_edge(src_id, tar_id, type=fixName(rel_name), ismi_id=rel_id) + rel_atts = {rel_type_attribute: fixName(rel_name), 'ismi_id': rel_id} + nx_rel = nx_graph.add_edge(src_id, tar_id, rel_atts) nx_relations[rel_id] = nx_rel