Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def result(value, graph_db):
try:
metadata = value["body"]
if "type" in metadata:
entity = neo4j.Relationship(metadata["self"], graph_db=graph_db)
else:
entity = neo4j.Node(metadata["self"], graph_db=graph_db)
entity._metadata = rest.PropertyCache(metadata)
return entity
except KeyError:
raise ValueError(value)
def creator(id, value, graph_db):
if isinstance(value, dict):
return {
"method": "POST",
"to": "/node",
"id": id,
"body": value
}
try:
if isinstance(value[0], neo4j.Node):
value[0]._must_belong_to(graph_db)
start_node_uri = relative_uri(value[0]._lookup("self"), "/node")
else:
start_node_uri = "{" + str(value[0]) + "}"
if isinstance(value[2], neo4j.Node):
value[2]._must_belong_to(graph_db)
end_node_uri = relative_uri(value[2]._lookup("self"), "/node")
else:
end_node_uri = "{" + str(value[2]) + "}"
return {
"method": "POST",
"to": start_node_uri + "/relationships",
"id": id,
"body": {
"to": end_node_uri,
"data": value[3] if len(value) > 3 else {},