refactor: rename neo4j_* push vars to push_* (shared by neo4j + falkordb)
The --push/--user/--password export flags feed both the neo4j and falkordb dispatch branches, so the neo4j_ prefix was misleading - a neo4j_password that reads FALKORDB_PASSWORD made no sense. Renamed to push_uri/push_user/ push_password, and the password env lookup now reads the backend-specific var (FALKORDB_PASSWORD for falkordb, NEO4J_PASSWORD otherwise) instead of OR-ing both.
This commit is contained in:
+22
-18
@@ -3404,14 +3404,18 @@ def main() -> None:
|
||||
node_limit = 5000
|
||||
no_viz = False
|
||||
obsidian_dir = Path(_GRAPHIFY_OUT) / "obsidian"
|
||||
neo4j_uri: str | None = None
|
||||
neo4j_user = "neo4j"
|
||||
# F-031: prefer the NEO4J_PASSWORD env var so the password never
|
||||
# appears on argv (visible in `ps` output / shell history). The
|
||||
# explicit --password flag still overrides it for compatibility.
|
||||
neo4j_password: str | None = (
|
||||
os.environ.get("NEO4J_PASSWORD") or os.environ.get("FALKORDB_PASSWORD") or None
|
||||
)
|
||||
# Shared push-connection settings for the graph-database sinks (neo4j,
|
||||
# falkordb), parsed from the generic --push/--user/--password flags below.
|
||||
push_uri: str | None = None
|
||||
push_user = "neo4j" # Neo4j default user; FalkorDB auth is optional and ignores it
|
||||
# F-031: prefer an env var so the password never appears on argv (visible
|
||||
# in `ps` output / shell history). The explicit --password flag still
|
||||
# overrides it. Each sink reads its own var: FALKORDB_PASSWORD for falkordb,
|
||||
# NEO4J_PASSWORD otherwise.
|
||||
push_password: str | None = (
|
||||
os.environ.get("FALKORDB_PASSWORD") if subcmd == "falkordb"
|
||||
else os.environ.get("NEO4J_PASSWORD")
|
||||
) or None
|
||||
i = 0
|
||||
while i < len(args):
|
||||
a = args[i]
|
||||
@@ -3462,11 +3466,11 @@ def main() -> None:
|
||||
elif a == "--dir" and i + 1 < len(args):
|
||||
obsidian_dir = Path(args[i + 1]); i += 2
|
||||
elif a == "--push" and i + 1 < len(args):
|
||||
neo4j_uri = args[i + 1]; i += 2
|
||||
push_uri = args[i + 1]; i += 2
|
||||
elif a == "--user" and i + 1 < len(args):
|
||||
neo4j_user = args[i + 1]; i += 2
|
||||
push_user = args[i + 1]; i += 2
|
||||
elif a == "--password" and i + 1 < len(args):
|
||||
neo4j_password = args[i + 1]; i += 2
|
||||
push_password = args[i + 1]; i += 2
|
||||
elif subcmd == "callflow-html" and not a.startswith("-") and not graph_path_explicit:
|
||||
candidate = Path(a)
|
||||
if candidate.name == "graph.json" or candidate.suffix.lower() == ".json":
|
||||
@@ -3617,13 +3621,13 @@ def main() -> None:
|
||||
print(f"graph.graphml written - open in Gephi, yEd, or any GraphML tool")
|
||||
|
||||
elif subcmd == "neo4j":
|
||||
if neo4j_uri:
|
||||
if push_uri:
|
||||
from graphify.export import push_to_neo4j as _push
|
||||
if neo4j_password is None:
|
||||
if push_password is None:
|
||||
print("error: --password required for --push", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
result = _push(G, uri=neo4j_uri, user=neo4j_user,
|
||||
password=neo4j_password, communities=communities)
|
||||
result = _push(G, uri=push_uri, user=push_user,
|
||||
password=push_password, communities=communities)
|
||||
print(f"Pushed to Neo4j: {result['nodes']} nodes, {result['edges']} edges")
|
||||
else:
|
||||
from graphify.export import to_cypher as _to_cypher
|
||||
@@ -3631,10 +3635,10 @@ def main() -> None:
|
||||
print(f"cypher.txt written - import with: cypher-shell < {out_dir}/cypher.txt")
|
||||
|
||||
elif subcmd == "falkordb":
|
||||
if neo4j_uri:
|
||||
if push_uri:
|
||||
from graphify.export import push_to_falkordb as _push
|
||||
result = _push(G, uri=neo4j_uri, user=neo4j_user,
|
||||
password=neo4j_password, communities=communities)
|
||||
result = _push(G, uri=push_uri, user=push_user,
|
||||
password=push_password, communities=communities)
|
||||
print(f"Pushed to FalkorDB: {result['nodes']} nodes, {result['edges']} edges")
|
||||
else:
|
||||
from graphify.export import to_cypher as _to_cypher
|
||||
|
||||
Reference in New Issue
Block a user