Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Wilkins <[email protected]>
  • Loading branch information
ElliottKasoar and oerc0122 authored Jun 11, 2024
1 parent 568772b commit 6705612
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions abcd/frontends/commandline/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def login(*, config, name, url, disable_ssl=False, **kwargs):
db = ABCD.from_url(url=url, use_ssl=(not disable_ssl))
info = db.info()

config["url"] = url
config["use_ssl"] = not disable_ssl
config.update(url=url, use_ssl=not disable_ssl)
config.save()

print("Successfully connected to the database!")
Expand Down Expand Up @@ -187,21 +186,21 @@ def key_add(*, db, query, keys, **kwargs):
if query:
if isinstance(db, OpenSearchDatabase):
test = [
f"{query} AND ({' OR '.join([f'{key}:*' for key in data.keys()])})"
f"{query} AND ({' OR '.join(f'{key}:*' for key in data)})"
for query in query
]
else:
test = ("AND", query, ("OR", *(("NAME", key) for key in data.keys())))
else:
if isinstance(db, OpenSearchDatabase):
test = " OR ".join([f"{key}:*" for key in data.keys()])
test = " OR ".join(f"{key}:*" for key in data)
else:
test = ("OR", *(("NAME", key) for key in data.keys()))

if db.count(query=test):
print(
"The new key already exist for the given query! "
"Please make sure that the target key name don't exist"
"The new key already exists for the given query! "
"Please make sure that the target key name doesn't exist"
)
exit(1)

Expand Down Expand Up @@ -233,7 +232,7 @@ def key_delete(*, db, query, yes, keys, **kwargs):

if isinstance(db, OpenSearchDatabase):
query = [
f"{query} AND ({' OR '.join([f'{key}:*' for key in data.keys()])})"
f"{query} AND ({' OR '.join(f'{key}:*' for key in data)})"
for query in query
]
else:
Expand Down

0 comments on commit 6705612

Please sign in to comment.