99
1010class GoogleMaps (object ):
1111 """To find address use: GoogleMaps.search(location=full_address)."""
12- _geocode_parser = GeocodeParser ()
13- _data = set ()
12+ geocode = GeocodeParser ()
13+ data = set ()
1414
1515 log = logging .Logger ('google_maps' )
1616
@@ -22,53 +22,50 @@ def __repr__(self):
2222 return '<GoogleMaps %s >' % self .all ()
2323
2424 def clear (self ):
25- self ._data = set ()
25+ self .data = set ()
2626
2727 @staticmethod
28- def validate (data ):
29- """Method should always returns false when data doesn't have city value."""
30- if not data .city :
28+ def validate (location ):
29+ """Method should always returns false when location doesn't have city value."""
30+ if not location .city :
3131 return False
3232
3333 return True
3434
3535 def _to_python (self , json_results ):
3636 """Method should converts json_results to python object."""
3737 for item in json_results :
38- self ._geocode_parser .json_data = item
38+ self .geocode .json_data = item
3939
4040 location = LocationModel ()
4141
42- location .city = self ._geocode_parser .get_city ()
43- location .route = self ._geocode_parser .get_route ()
44- location .street_number = self ._geocode_parser .get_street_number ()
45- location .postal_code = self ._geocode_parser .get_postal_code ()
42+ location .city = self .geocode .get_city ()
43+ location .route = self .geocode .get_route ()
44+ location .street_number = self .geocode .get_street_number ()
45+ location .postal_code = self .geocode .get_postal_code ()
4646
47- location .country = self ._geocode_parser .get_country ()
48- location .country_shortcut = \
49- self ._geocode_parser .get_country_shortcut ()
47+ location .country = self .geocode .get_country ()
48+ location .country_shortcut = self .geocode .get_country_shortcut ()
5049
51- location .administrative_area = \
52- self ._geocode_parser .get_administrative_area ()
50+ location .administrative_area = self .geocode .get_administrative_area ()
5351
54- location .lat = self ._geocode_parser .get_lat ()
55- location .lng = self ._geocode_parser .get_lng ()
52+ location .lat = self .geocode .get_lat ()
53+ location .lng = self .geocode .get_lng ()
5654
57- location .formatted_address = \
58- self ._geocode_parser .get_formatted_address ()
55+ location .formatted_address = self .geocode .get_formatted_address ()
5956
6057 if self .validate (location ):
61- self ._data .add (location )
58+ self .data .add (location )
6259
6360 return self .all ()
6461
6562 def all (self ):
6663 """Method returns location list."""
67- return list (self ._data )
64+ return list (self .data )
6865
6966 def first (self ):
70- if self ._data :
71- return list (self ._data )[0 ]
67+ if self .data :
68+ return list (self .data )[0 ]
7269
7370 return None
7471
0 commit comments