MCPcopy Create free account
hub / github.com/CyberPoint/libpgm / _validate

Function _validate

utils/bntextutils.py:164–182  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

162 json.dump(d, f, indent=2)
163
164def _validate(path):
165 # is json correctly formatted?
166 try:
167 with open(path) as f:
168 json.load(f)
169 except:
170 raise Exception("The network file you are trying to modify is invalid")
171
172 # do the nodes match the node data?
173 with open(path) as f:
174 j = json.load(f)
175 if not (sorted(j["V"]) == sorted(j["Vdata"].keys())):
176 print "warning: nodes and node data do not match"
177
178 # are the edges valid?
179 for e in j["E"]:
180 if (e[0] not in j["V"]) or (e[1] not in j["V"]):
181 print "warning: nodes not found for this edge:",
182 print e
183

Callers 8

list_edgesFunction · 0.85
list_nodesFunction · 0.85
list_nodedataFunction · 0.85
add_edgeFunction · 0.85
remove_edgeFunction · 0.85
add_nodeFunction · 0.85
remove_nodeFunction · 0.85
alter_vdataFunction · 0.85

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected