Skip to content

Commit 4e346ea

Browse files
committed
comments for util funcs
1 parent 3b1bbda commit 4e346ea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ipinfo/handler_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,23 @@ def get_headers(access_token):
2424
return headers
2525

2626
def format_details(details, countries):
27+
"""
28+
Format details given a countries object.
29+
30+
The countries object can be retrieved from read_country_names.
31+
"""
2732
details["country_name"] = countries.get(details.get("country"))
2833
details["latitude"], details["longitude"] = read_coords(
2934
details.get("loc")
3035
)
3136

3237
def read_coords(location):
38+
"""
39+
Given a location of the form `<lat>,<lon>`, returns the latitude and
40+
longitude as a tuple.
41+
42+
Returns None for each tuple item if the form is invalid.
43+
"""
3344
lat, lon = None, None
3445
coords = tuple(location.split(",")) if location else ""
3546
if len(coords) == 2 and coords[0] and coords[1]:

0 commit comments

Comments
 (0)