1010http://dev.maxmind.com/geoip/geoip2/web-services for more details.
1111
1212"""
13- # pylint:disable=R0903
13+ # pylint: disable=too-many-instance-attributes,too-few-public-methods
14+ from abc import ABCMeta
15+
1416import geoip2 .records
17+ from geoip2 .mixins import SimpleEquality
1518
1619
17- class Country (object ):
20+ class Country (SimpleEquality ):
1821
1922 """Model for the GeoIP2 Precision: Country and the GeoIP2 Country database
2023
@@ -66,6 +69,7 @@ class Country(object):
6669 def __init__ (self , raw_response , locales = None ):
6770 if locales is None :
6871 locales = ['en' ]
72+ self ._locales = locales
6973 self .continent = \
7074 geoip2 .records .Continent (locales ,
7175 ** raw_response .get ('continent' , {}))
@@ -76,18 +80,24 @@ def __init__(self, raw_response, locales=None):
7680 geoip2 .records .Country (locales ,
7781 ** raw_response .get ('registered_country' ,
7882 {}))
79- # pylint:disable=bad-continuation
8083 self .represented_country \
8184 = geoip2 .records .RepresentedCountry (locales ,
8285 ** raw_response .get (
83- 'represented_country' , {}))
86+ 'represented_country' , {}))
8487
8588 self .maxmind = \
8689 geoip2 .records .MaxMind (** raw_response .get ('maxmind' , {}))
8790
8891 self .traits = geoip2 .records .Traits (** raw_response .get ('traits' , {}))
8992 self .raw = raw_response
9093
94+ def __repr__ (self ):
95+ return '{module}.{class_name}({data}, {locales})' .format (
96+ module = self .__module__ ,
97+ class_name = self .__class__ .__name__ ,
98+ data = self .raw ,
99+ locales = self ._locales )
100+
91101
92102class City (Country ):
93103
@@ -230,7 +240,21 @@ class Insights(City):
230240 """
231241
232242
233- class ConnectionType (object ):
243+ class SimpleModel (SimpleEquality ):
244+
245+ """Provides basic methods for non-location models"""
246+
247+ __metaclass__ = ABCMeta
248+
249+ def __repr__ (self ):
250+ # pylint: disable=no-member
251+ return '{module}.{class_name}({data})' .format (
252+ module = self .__module__ ,
253+ class_name = self .__class__ .__name__ ,
254+ data = str (self .raw ))
255+
256+
257+ class ConnectionType (SimpleModel ):
234258
235259 """Model class for the GeoIP2 Connection-Type
236260
@@ -262,7 +286,7 @@ def __init__(self, raw):
262286 self .raw = raw
263287
264288
265- class Domain (object ):
289+ class Domain (SimpleModel ):
266290
267291 """Model class for the GeoIP2 Domain
268292
@@ -288,7 +312,7 @@ def __init__(self, raw):
288312 self .raw = raw
289313
290314
291- class ISP (object ):
315+ class ISP (SimpleModel ):
292316
293317 """Model class for the GeoIP2 ISP
294318
0 commit comments