From 347373cfa6831819199b4e43f31f7d3724c5b175 Mon Sep 17 00:00:00 2001 From: Scott Hajek Date: Sat, 25 Jul 2015 16:06:29 -0400 Subject: [PATCH 1/2] Add __repr__() methods to the following classes to override the one inherited from `object`: GoogleAutocompleteSearchResult, Prediction, GooglePlacesSearchResult, and Place --- googleplaces/__init__.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/googleplaces/__init__.py b/googleplaces/__init__.py index 2c21ac1..f0ed5c9 100644 --- a/googleplaces/__init__.py +++ b/googleplaces/__init__.py @@ -575,6 +575,13 @@ def raw_response(self): def predictions(self): return self._predictions + def __repr__(self): + """Return a string representation stating number of predictions.""" + return '<{} with {} prediction(s)>'.format( + self.__class__.__name__, + len(self.predictions) + ) + class Prediction(object): """ @@ -709,6 +716,10 @@ def _validate_status(self): 'an explicit call to get_details() is made.') raise GooglePlacesAttributeError(error_detail) + def __repr__(self): + """ Return a string representation with description. """ + return '<{} description="{}">'.format(self.__class__.__name__, self.description) + class GooglePlacesSearchResult(object): """ @@ -748,6 +759,10 @@ def has_attributions(self): """Returns a flag denoting if the response had any html attributions.""" return len(self.html_attributions) > 0 + def __repr__(self): + """ Return a string representation stating the number of results.""" + return '<{} with {} result(s)>'.format(self.__class__.__name__, len(self.places)) + class Place(object): """ @@ -968,6 +983,15 @@ def _validate_status(self): 'an explicit call to get_details() is made.') raise GooglePlacesAttributeError(error_detail) + def __repr__(self): + """ Return a string representation including the name, lat, and lng. """ + return '<{} name="{}", lat={}, lng={}>'.format( + self.__class__.__name__, + self.name, + self.geo_location['lat'], + self.geo_location['lng'] + ) + class Photo(object): def __init__(self, query_instance, attrs): From afd4160e14a948fce386ce1c384ecc10ef3478b8 Mon Sep 17 00:00:00 2001 From: slimkrazy Date: Sun, 26 Jul 2015 08:44:26 +0100 Subject: [PATCH 2/2] Updated patch number and contributors file. --- CONTRIBUTORS | 1 + googleplaces/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a37916c..e2f58fc 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,3 +12,4 @@ twiddle elbaschid commadelimited isms +scottcode diff --git a/googleplaces/__init__.py b/googleplaces/__init__.py index f0ed5c9..2620679 100644 --- a/googleplaces/__init__.py +++ b/googleplaces/__init__.py @@ -34,7 +34,7 @@ __all__ = ['GooglePlaces', 'GooglePlacesError', 'GooglePlacesAttributeError', 'geocode_location'] -__version__ = '1.0.0' +__version__ = '1.0.1' __author__ = 'Samuel Adu' __email__ = 'sam@slimkrazy.com'