10000 Using graph properties instead of list search · arangodb/python-arango@ce34687 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce34687

Browse files
committed
Using graph properties instead of list search
1 parent e7bcd4d commit ce34687

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arango/database.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from arango.cluster import Cluster
1818
from arango.collection import StandardCollection
1919
from arango.connection import Connection
20+
from arango.errno import HTTP_NOT_FOUND
2021
from arango.exceptions import (
2122
AnalyzerCreateError,
2223
AnalyzerDeleteError,
@@ -1644,12 +1645,14 @@ def has_graph(self, name: str) -> Result[bool]:
16441645
:return: True if graph exists, False otherwise.
16451646
:rtype: bool
16461647
"""
1647-
request = Request(method="get", endpoint="/_api/gharial")
1648+
request = Request(method="get", endpoint=f"/_api/gharial/{name}")
16481649

16491650
def response_handler(resp: Response) -> bool:
1650-
if not resp.is_success:
1651-
raise GraphListError(resp, request)
1652-
return any(name == graph["_key"] for graph in resp.body["graphs"])
1651+
if resp.is_success:
1652+
return True
1653+
if resp.status_code == HTTP_NOT_FOUND:
1654+
return False
1655+
raise GraphListError(resp, request)
16531656

16541657
return self._execute(request, response_handler)
16551658

0 commit comments

Comments
 (0)
0