Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--address", help="The bolt url and port used to connect to the neo4j instance. (default:"
"bolt://localhost:7687)",
default="bolt://localhost:7687")
parser.add_argument("-u", "--username", help="The username used to connect to the neo4j instance. (default: )",
default='')
parser.add_argument("-p", "--password", help="The password used to connect to the neo4j instance. (default: )",
default='')
args = parser.parse_args()
if args.username == '' or args.password == '':
print('usage: DumpNeo4jToCSV.py [-h] [-a URL] [-u USERNAME] [-p PASSWORD]')
print('DumpNeo4jToCSV.py: error: invalid username or password')
exit(0)
driver = neo4j.v1.GraphDatabase.driver(args.address, auth=(args.username, args.password))
make_nodes_file()
make_rels_file()
def neo4j_connect(self):
assert self.neo4j_url is not None
assert self.neo4j_user is not None
assert self.neo4j_password is not None
self.driver = neo4j.v1.GraphDatabase.driver(self.neo4j_url,
auth=(self.neo4j_user,
self.neo4j_password))
# def neo4j_shutdown(self):
def neo4j_connect(self):
assert self.neo4j_url is not None
assert self.neo4j_user is not None
assert self.neo4j_password is not None
self.driver = neo4j.v1.GraphDatabase.driver(self.neo4j_url,
auth=(self.neo4j_user,
self.neo4j_password))
# def neo4j_shutdown(self):
# This is weird, I know, re-write later when I'm making this more efficient
def append(self, point):
self.x.append(point.x)
self.y.append(point.y)
def __str__(self):
return "{x:\n" + str(self.x) + ",\ny:\n" + str(self.y) + "}"
def __repr__(self):
return self.__str__()
def noop():
pass
RecordGenerator = Generator[neo4j.v1.Record, None, None]
PointGenerator = Generator[Point, None, None]
class Recipe:
def __init__(self,
transform:Callable[[RecordGenerator], PointGenerator] = None,
query:Callable[[], RecordGenerator] = None,
partition:Callable[[PointGenerator], Generator[Tuple[str, Point], None, None]] = None,
split:Callable[[neo4j.v1.Record], Point] = None,
finalize_x = None):
self.transform = transform
self.query = query
self.partition = partition
# TODO: migrate older experiments
if transform is None:
import neo4j.v1
class ReasoningToolNode(neo4j.v1.types.Node):
def __init__(self):
pass
def get_biotype(self):
labels = self.labels.copy()
labels.remove("Base")
assert len(labels)==1
return list(labels)[0]
def get_bioname(self):
properties = self.properties
return properties["name"]
def is_expanded(self):
return self.properties["expanded"] == "true"