Skip to content

Commit 5253fd0

Browse files
committed
rename read_countries_file to read_json_file
1 parent a96a10a commit 5253fd0

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

ipinfo/handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def __init__(self, access_token=None, **kwargs):
4141
self.access_token = access_token
4242

4343
# load countries file
44-
self.countries = handler_utils.read_country_names(
44+
self.countries = handler_utils.read_json_file(
4545
kwargs.get("countries_file")
4646
if kwargs.get("countries_file")
4747
else COUNTRY_FILE_DEFAULT
4848
)
4949

5050
# load eu countries file
51-
self.eu_countries = handler_utils.read_country_names(
51+
self.eu_countries = handler_utils.read_json_file(
5252
kwargs.get("eu_countries_file")
5353
if kwargs.get("eu_countries_file")
5454
else COUNTRY_EU_FILE_DEFAULT

ipinfo/handler_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def __init__(self, access_token=None, **kwargs):
4242
self.access_token = access_token
4343

4444
# load countries file
45-
self.countries = handler_utils.read_country_names(
45+
self.countries = handler_utils.read_json_file(
4646
kwargs.get("countries_file")
4747
if kwargs.get("countries_file")
4848
else COUNTRY_FILE_DEFAULT
4949
)
5050

5151
# load eu countries file
52-
self.eu_countries = handler_utils.read_country_names(
52+
self.eu_countries = handler_utils.read_json_file(
5353
kwargs.get("eu_countries_file")
5454
if kwargs.get("eu_countries_file")
5555
else COUNTRY_EU_FILE_DEFAULT

ipinfo/handler_utils.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def get_headers(access_token):
5555
def format_details(details, countries, eu_countries):
5656
"""
5757
Format details given a countries object.
58-
59-
The countries object can be retrieved from read_country_names.
6058
"""
6159
details["country_name"] = countries.get(details.get("country"))
6260
details["isEU"] = details.get("country") in eu_countries
@@ -77,13 +75,12 @@ def read_coords(location):
7775
return lat, lon
7876

7977

80-
def read_country_names(countries_file):
78+
def read_json_file(json_file):
8179
"""
82-
Read list of countries from specified country file or
83-
default file.
80+
Read a list of countries from specified country file or default file.
8481
"""
85-
countries_file = os.path.join(os.path.dirname(__file__), countries_file)
86-
with open(countries_file) as f:
82+
json_file = os.path.join(os.path.dirname(__file__), json_file)
83+
with open(json_file) as f:
8784
countries_json = f.read()
8885

8986
return json.loads(countries_json)

0 commit comments

Comments
 (0)