Commit baf74199 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Fix bug in model_summary.json: xrefs as unwanted keys

parent 0f609781
......@@ -1200,7 +1200,9 @@ def model_info(model_file, output_dir='./',
"""Write informations about places in the model to a csv."""
with open(output_filename, 'w') as csvfile:
# Get all database names
database_names = {db_name for place in places for db_name in place.get('xrefs', dict()).iterkeys()}
database_names = \
{db_name for place in places
for db_name in place.get('xrefs', dict()).iterkeys()}
# Write headers
fieldnames = ("cadbiomName", "names", "uri", "entityType",
......@@ -1213,13 +1215,15 @@ def model_info(model_file, output_dir='./',
writer.writeheader()
for place in places:
# Since we modify places, we need to make a copy in memory
temp_place = place.copy()
# Join names with a pipe...
place['names'] = "|".join(place.get('names', list()))
# Join xref ids with a pipe...
temp_place['names'] = "|".join(place.get('names', list()))
# Join xrefs ids with a pipe...
for db_name, db_ids in place.get('xrefs', dict()).iteritems():
place[db_name] = "|".join(db_ids)
temp_place[db_name] = "|".join(db_ids)
writer.writerow(place)
writer.writerow(temp_place)
def get_csv_filename():
......@@ -1252,7 +1256,7 @@ def model_info(model_file, output_dir='./',
# Export to json file
if make_json:
with open(output_dir + "model_summary.json", 'w') as f_d:
f_d.write(json.dumps(model_info, sort_keys=True, indent=4) + '\n')
f_d.write(json.dumps(model_info, sort_keys=True, indent=2) + '\n')
if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment