44=======
55
66"""
7-
7+ #pylint:disable=R0903
88from abc import ABCMeta
9- import collections
109
1110
1211class Record (object ):
1312 """All records are subclasses of ``Record``"""
1413 __metaclass__ = ABCMeta
1514
15+ _valid_attributes = None
16+
1617 def __init__ (self , ** kwargs ):
1718 valid_args = dict ((k , kwargs .get (k )) for k in self ._valid_attributes )
1819 self .__dict__ .update (valid_args )
1920
2021 def __setattr__ (self , name , value ):
21- raise NotImplementedError ( name + ' is read-only.' )
22+ raise AttributeError ( "can't set attribute" )
2223
2324
2425class PlaceRecord (Record ):
@@ -35,6 +36,8 @@ def __init__(self, languages=None, **kwargs):
3536
3637 @property
3738 def name (self ):
39+ """Dict with language codes as keys and localized name as value"""
40+ #pylint:disable=E1101
3841 return next ((self .names .get (x ) for x in self ._languages if x in
3942 self .names ), None )
4043
@@ -100,9 +103,9 @@ class Country(PlaceRecord):
100103 end point.
101104 :ivar geoname_id: The GeoName ID for the country. This attribute is
102105 returned by all end points.
103- :ivar iso_code: The two-character ISO 3166-1
104- ( http://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country.
105- This attribute is returned by all end points.
106+ :ivar iso_code: The two-character ` ISO 3166-1
107+ < http://en.wikipedia.org/wiki/ISO_3166-1>`_ alpha code for the
108+ country. This attribute is returned by all end points.
106109 :ivar name: The name of the country based on the languages list
107110 passed to the constructor. This attribute is returned by all end points.
108111 :ivar names: A dictionary where the keys are language codes and the values
@@ -115,8 +118,8 @@ class Country(PlaceRecord):
115118class RepresentedCountry (Country ):
116119 """Contains data for the represented country associated with an IP address
117120
118- This class contains the country-level data associated with an IP address for
119- the IP's represented country. The represented country is the country
121+ This class contains the country-level data associated with an IP address
122+ for the IP's represented country. The represented country is the country
120123 represented by something like a military base or embassy.
121124
122125 This record is returned by all the end points.
@@ -128,8 +131,8 @@ class RepresentedCountry(Country):
128131 end point.
129132 :ivar geoname_id: The GeoName ID for the country. This attribute is
130133 returned by all end points.
131- :ivar iso_code: The two-character ISO 3166-1
132- ( http://en.wikipedia.org/wiki/ISO_3166-1) alpha code for the country.
134+ :ivar iso_code: The two-character ` ISO 3166-1
135+ < http://en.wikipedia.org/wiki/ISO_3166-1>`_ alpha code for the country.
133136 This attribute is returned by all end points.
134137 :ivar name: The name of the country based on the languages list
135138 passed to the constructor. This attribute is returned by all end points.
@@ -141,7 +144,8 @@ class RepresentedCountry(Country):
141144 endpoints.
142145
143146 """
144- _valid_attributes = set (['confidence' , 'geoname_id' , 'iso_code' , 'names' , 'type' ])
147+ _valid_attributes = set (['confidence' , 'geoname_id' , 'iso_code' ,
148+ 'names' , 'type' ])
145149
146150
147151class Location (Record ):
@@ -164,13 +168,13 @@ class Location(Record):
164168 except the Country end point.
165169 :ivar metro_code: The metro code of the location if the
166170 location is in the US. MaxMind returns the same metro codes as the
167- Google AdWords API
168- ( https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions) .
171+ ` Google AdWords API
172+ < https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions>`_ .
169173 This attribute is returned by all end points except the Country end
170174 point.
171175 :ivar time_zone: The time zone associated with location, as
172- specified by the IANA Time Zone Database
173- ( http://www.iana.org/time-zones) , e.g., "America/New_York". This
176+ specified by the ` IANA Time Zone Database
177+ < http://www.iana.org/time-zones>`_ , e.g., "America/New_York". This
174178 attribute is returned by all end points except the Country end point.
175179
176180 """
@@ -215,9 +219,9 @@ class Subdivision(PlaceRecord):
215219 :ivar geoname_id: This is a GeoName ID for the subdivision. This
216220 attribute is returned by all end points except Country.
217221 :ivar iso_code: This is a string up to three characters long
218- contain the subdivision portion of the ISO 3166-2 code
219- ( http://en.wikipedia.org/wiki/ISO_3166-2) . This attribute is returned
220- by all end points except Country.
222+ contain the subdivision portion of the ` ISO 3166-2 code
223+ < http://en.wikipedia.org/wiki/ISO_3166-2>`_ . This attribute is
224+ returned by all end points except Country.
221225 :ivar name: The name of the subdivision based on the languages list
222226 passed to the constructor. This attribute is returned by all end points.
223227 :ivar names: A dictionary where the keys are language codes and the
@@ -241,6 +245,7 @@ class Subdivisions(tuple):
241245 end point.
242246
243247 """
248+ #pylint:disable=R0924,W0212,W0142
244249 def __new__ (cls , languages , * subdivisions ):
245250 subdivisions = [Subdivision (languages , ** x ) for x in subdivisions ]
246251 obj = super (cls , Subdivisions ).__new__ (cls , subdivisions )
@@ -271,14 +276,14 @@ class Traits(Record):
271276
272277 This class has the following attributes:
273278
274- :ivar autonomous_system_number: The autonomous system
275- number ( http://en.wikipedia.org/wiki/Autonomous_system_(Internet))
279+ :ivar autonomous_system_number: The ` autonomous system
280+ number < http://en.wikipedia.org/wiki/Autonomous_system_(Internet)>`_
276281 associated with the IP address. This attribute is only available from
277282 the City/ISP/Org and Omni end points.
278283 :ivar autonomous_system_organization: The organization
279- associated with the registered autonomous system number
280- ( http://en.wikipedia.org/wiki/Autonomous_system_(Internet)) for the IP
281- address. This attribute is only available from the City/ISP/Org and
284+ associated with the registered ` autonomous system number
285+ < http://en.wikipedia.org/wiki/Autonomous_system_(Internet)>`_ for the
286+ IP address. This attribute is only available from the City/ISP/Org and
282287 Omni end points.
283288 :ivar domain: The second level domain associated with the
284289 IP address. This will be something like "example.com" or
@@ -331,7 +336,7 @@ class Traits(Record):
331336 'organization' ,
332337 'user_type' ])
333338
334- def __init__ (self , languages = None , ** kwargs ):
339+ def __init__ (self , ** kwargs ):
335340 for k in ['is_anonymous_proxy' , 'is_satellite_provider' ]:
336341 kwargs [k ] = bool (kwargs .get (k , False ))
337342 super (Traits , self ).__init__ (** kwargs )
0 commit comments