@@ -5,7 +5,8 @@ class Record(object):
55 __metaclass__ = ABCMeta
66
77 def __init__ (self , ** args ):
8- self .__dict__ .update ({k : args .get (k ) for k in self ._valid_attributes })
8+ valid_args = dict ((k , args .get (k )) for k in self ._valid_attributes )
9+ self .__dict__ .update (valid_args )
910
1011 def __setattr__ (self , name , value ):
1112 raise NotImplementedError (name + ' is read-only.' )
@@ -20,7 +21,7 @@ def __init__(self, languages=None, **args):
2021 languages = []
2122 object .__setattr__ (self , 'languages' , languages )
2223 args ['names' ] = args .pop ('name' , [])
23- super ().__init__ (** args )
24+ super (PlaceRecord , self ).__init__ (** args )
2425
2526 @property
2627 def name (self ):
@@ -29,42 +30,43 @@ def name(self):
2930
3031
3132class City (PlaceRecord ):
32- _valid_attributes = { 'confidence' , 'geoname_id' , 'names' }
33+ _valid_attributes = set ([ 'confidence' , 'geoname_id' , 'names' ])
3334
3435
3536class Continent (PlaceRecord ):
36- _valid_attributes = { 'continent_code' , 'geoname_id' , 'names' }
37+ _valid_attributes = set ([ 'continent_code' , 'geoname_id' , 'names' ])
3738
3839
3940class Country (PlaceRecord ):
40- _valid_attributes = { 'confidence' , 'geoname_id' , 'iso_3166_1_alpha_2' ,
41- 'iso_3166_1_alpha_3' , 'names' }
41+ _valid_attributes = set ([ 'confidence' , 'geoname_id' , 'iso_3166_1_alpha_2' ,
42+ 'iso_3166_1_alpha_3' , 'names' ])
4243
4344
4445class Location (Record ):
45- _valid_attributes = { 'accuracy_radius' , 'latitude' , 'longitude'
46- 'metro_code' , 'postal_code' , 'postal_confidence' ,
47- 'time_zone' }
46+ _valid_attributes = set ([ 'accuracy_radius' , 'latitude' , 'longitude'
47+ 'metro_code' , 'postal_code' , 'postal_confidence' ,
48+ 'time_zone' ])
4849
4950
5051class Region (PlaceRecord ):
51- _valid_attributes = {'confidence' , 'geoname_id' , 'iso_3166_2' , 'names' }
52+ _valid_attributes = set (['confidence' , 'geoname_id' , 'iso_3166_2' ,
53+ 'names' ])
5254
5355
5456class Traits (Record ):
55- _valid_attributes = { 'autonomous_system_number' ,
56- 'autonomous_system_organization' ,
57- 'domain' ,
58- 'is_anonymous_proxy' ,
59- 'is_satellite_provider' ,
60- 'is_transparent_proxy' ,
61- 'isp' ,
62- 'ip_address' ,
63- 'organization' ,
64- 'user_type' }
57+ _valid_attributes = set ([ 'autonomous_system_number' ,
58+ 'autonomous_system_organization' ,
59+ 'domain' ,
60+ 'is_anonymous_proxy' ,
61+ 'is_satellite_provider' ,
62+ 'is_transparent_proxy' ,
63+ 'isp' ,
64+ 'ip_address' ,
65+ 'organization' ,
66+ 'user_type' ])
6567
6668 def __init__ (self , languages = None , ** args ):
6769 for k in ['is_anonymous_proxy' , 'is_satellite_provider' ,
6870 'is_transparent_proxy' ]:
6971 args [k ] = bool (args .get (k , False ))
70- super ().__init__ (** args )
72+ super (Traits , self ).__init__ (** args )
0 commit comments