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 2c21ac1..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' @@ -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):