Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aclark4life committed Nov 26, 2024
1 parent 4ba50ff commit f77a633
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions django_mongodb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def check_django_compatability():

def parse(uri, **kwargs):
uri = parse_uri(uri)

host = None
port = None

Expand All @@ -37,20 +38,18 @@ def parse(uri, **kwargs):
else:
# If the fqdn is not present, this is a standard URI and the host and
# port are in the nodelist.
host, port = [f"{node[0]}:{node[1]}" for node in uri["nodelist"]].next().split(":")
host, port = [f"{node[0]}:{node[1]}" for node in uri["nodelist"]][0].split(":") # noqa: RUF015

settings_dict = {
"ENGINE": "django_mongodb",
"NAME": uri["database"],
"HOST": host,
"PORT": port,
"USER": uri.get("username"),
"PASSWORD": uri.get("password"),
"OPTIONS": uri.get("options"),
}

if port:
settings_dict["PORT"] = port

if kwargs:
settings_dict.update(kwargs)

Expand Down

0 comments on commit f77a633

Please sign in to comment.