Reformat the data object and add the docs properties for d3.js compliance
(data, cidr, groups)
| 326 | |
| 327 | |
| 328 | def 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 | |
| 356 | def main(logger=None): |