In [ ]:
import pathlib
import json

from pikov import JSONGraph

In [ ]:
sample_dir = (pathlib.Path("..") / ".." / "samples").resolve()

with open(sample_dir / "pikov-core.json") as fp:
    core_types = json.load(fp)
    #graph = JSONGraph.load(fp)

sample_path = sample_dir / "gamekitty.json"

# Merge core types into pikov.json
graph = JSONGraph.load(sample_path)
for key, item in core_types["guidMap"].items():
    graph._guid_map[key] = item

In [3]:
# Find every node that doesn't have a name.
def find_all_nameless(graph):
    nameless = []
    for node in graph:
        is_nameless = True
        for edge in node:
            if edge.guid == "169a81aefca74e92b45e3fa03c7021df":
                is_nameless = False
        if is_nameless:
            nameless.append(node.guid)
    return nameless

nameless = find_all_nameless(graph)
len(nameless)


Out[3]:
0

In [4]:
for unnamed in nameless:
    ctor = graph.get_value(unnamed, "aba6ac79fd3d409da860a77c90942852")
    ctor_name = graph.get_value(ctor, "169a81aefca74e92b45e3fa03c7021df").value
    print(ctor_name)

In [5]:
# Delete every node that doesn't have a name.
for guid in nameless:
    graph.delete_node(guid)

In [6]:
graph.save()

In [ ]: