@@ -27,13 +27,21 @@ class Handler:
2727 REQUEST_TIMEOUT_DEFAULT = 2
2828
2929 def __init__ (self , access_token = None , ** kwargs ):
30- """Initialize the Handler object with country name list and the cache initialized."""
30+ """
31+ Initialize the Handler object with country name list and the
32+ cache initialized.
33+ """
3134 self .access_token = access_token
35+
36+ # load countries file
3237 self .countries = self ._read_country_names (kwargs .get ("countries_file" ))
38+
39+ # setup req opts
3340 self .request_options = kwargs .get ("request_options" , {})
3441 if "timeout" not in self .request_options :
3542 self .request_options ["timeout" ] = self .REQUEST_TIMEOUT_DEFAULT
3643
44+ # setup cache
3745 if "cache" in kwargs :
3846 self .cache = kwargs ["cache" ]
3947 else :
@@ -58,8 +66,9 @@ def getBatchDetails(self, ip_addresses):
5866 # the IPs not in the cache.
5967 lookup_addresses = []
6068 for ip_address in ip_addresses :
61- # If the supplied IP address uses the objects defined in the built-in module ipaddress
62- # extract the appropriate string notation before formatting the URL
69+ # If the supplied IP address uses the objects defined in the
70+ # built-in module ipaddress extract the appropriate string notation
71+ # before formatting the URL.
6372 if isinstance (ip_address , IPv4Address ) or isinstance (
6473 ip_address , IPv6Address
6574 ):
@@ -99,8 +108,9 @@ def getBatchDetails(self, ip_addresses):
99108 def _requestDetails (self , ip_address = None ):
100109 """Get IP address data by sending request to IPinfo API."""
101110
102- # If the supplied IP address uses the objects defined in the built-in module ipaddress
103- # extract the appropriate string notation before formatting the URL
111+ # If the supplied IP address uses the objects defined in the built-in
112+ # module ipaddress extract the appropriate string notation before
113+ # formatting the URL.
104114 if isinstance (ip_address , IPv4Address ) or isinstance (
105115 ip_address , IPv6Address
106116 ):
@@ -149,7 +159,10 @@ def _read_coords(self, location):
149159 return lat , lon
150160
151161 def _read_country_names (self , countries_file = None ):
152- """Read list of countries from specified country file or default file."""
162+ """
163+ Read list of countries from specified country file or
164+ default file.
165+ """
153166 if not countries_file :
154167 countries_file = os .path .join (
155168 os .path .dirname (__file__ ), self .COUNTRY_FILE_DEFAULT
0 commit comments