(path)
| 162 | json.dump(d, f, indent=2) |
| 163 | |
| 164 | def _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 |
no test coverage detected