MCPcopy Create free account
hub / github.com/adobe/Marinus / reformat_data

Function reformat_data

python3_cron_scripts/create_netaddr_graphs.py:328–353  ·  view source on GitHub ↗

Reformat the data object and add the docs properties for d3.js compliance

(data, cidr, groups)

Source from the content-addressed store, hash-verified

326
327
328def reformat_data(data, cidr, groups):
329 """
330 Reformat the data object and add the docs properties for d3.js compliance
331 """
332 for i in range(0, len(data["nodes"])):
333 data["nodes"][i]["name"] = data["nodes"][i]["id"]
334
335 # Build relationships
336 for tmp_links in data["links"]:
337 if (
338 data["nodes"][i]["id"] == tmp_links["target"]
339 and tmp_links["source"] not in data["nodes"][i]["depends"]
340 and tmp_links["source"] != data["nodes"][i]["id"]
341 ):
342 data["nodes"][i]["depends"].append(tmp_links["source"])
343
344 if (
345 data["nodes"][i]["id"] == tmp_links["source"]
346 and tmp_links["target"] not in data["nodes"][i]["dependedOnBy"]
347 and tmp_links["target"] != data["nodes"][i]["id"]
348 ):
349 data["nodes"][i]["dependedOnBy"].append(tmp_links["target"])
350
351 # Create docs
352 data["nodes"][i]["docs"] = build_docs(data["nodes"][i], cidr, groups)
353 data["nodes"][i]["group"] = groups[data["nodes"][i]["type"]]
354
355
356def main(logger=None):

Callers 1

mainFunction · 0.70

Calls 1

build_docsFunction · 0.70

Tested by

no test coverage detected