diff -Nru geopy-1.18.1/AUTHORS geopy-1.20.0/AUTHORS --- geopy-1.18.1/AUTHORS 2018-12-02 13:20:46.000000000 +0000 +++ geopy-1.20.0/AUTHORS 2019-05-26 11:28:19.000000000 +0000 @@ -61,9 +61,11 @@ Marco Milanesi Mariana Georgieva Martin +Mesut Öncel Micah Cochran michal Michal Migurski +Mike Hansen Mike Tigas Mike Toews mtmail @@ -81,12 +83,15 @@ Rocky Meza Ryan Nagle scottessner +Sebastian Illing Sebastian Neubauer SemiNormal +Sergey Lyapustin Serphentas svalee Svetlana Konovalova Sébastien Barré +TheRealZeljko Thomas Tom Wallroth tony diff -Nru geopy-1.18.1/debian/changelog geopy-1.20.0/debian/changelog --- geopy-1.18.1/debian/changelog 2019-01-01 15:59:05.000000000 +0000 +++ geopy-1.20.0/debian/changelog 2019-07-22 00:22:20.000000000 +0000 @@ -1,3 +1,17 @@ +geopy (1.20.0-1) unstable; urgency=medium + + [ Ondřej Nový ] + * Use debhelper-compat instead of debian/compat. + * Bump Standards-Version to 4.4.0. + + [ Daniele Tricoli ] + * New upstream release. + * Stop building python-geopy Python 2 package (Closes: #932676) + * debian/copyright + - Update copyright years. + + -- Daniele Tricoli Mon, 22 Jul 2019 02:22:20 +0200 + geopy (1.18.1-1) unstable; urgency=medium * New upstream release. diff -Nru geopy-1.18.1/debian/compat geopy-1.20.0/debian/compat --- geopy-1.18.1/debian/compat 2019-01-01 15:59:05.000000000 +0000 +++ geopy-1.20.0/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru geopy-1.18.1/debian/control geopy-1.20.0/debian/control --- geopy-1.18.1/debian/control 2019-01-01 15:59:05.000000000 +0000 +++ geopy-1.20.0/debian/control 2019-07-22 00:22:20.000000000 +0000 @@ -4,35 +4,16 @@ Section: python Priority: optional Build-Depends: - debhelper (>= 11), + debhelper-compat (= 11), dh-python, - python-all (>= 2.6.6-3), - python-setuptools (>= 0.6b3), python3-all, python3-setuptools -Standards-Version: 4.3.0 +Standards-Version: 4.4.0 Homepage: https://github.com/geopy/geopy Vcs-Git: https://salsa.debian.org/python-team/modules/geopy.git Vcs-Browser: https://salsa.debian.org/python-team/modules/geopy Testsuite: autopkgtest-pkg-python -Package: python-geopy -Architecture: all -Depends: - ${misc:Depends}, - ${python:Depends}, - python-geographiclib -Recommends: - python-tz -Description: geocoding toolbox for Python - geopy makes it easy for developers to locate the coordinates of addresses, - cities, countries, and landmarks across the globe using third-party geocoders - and other sources of data, such as wikis. - It also comes with the necessary means for parsing geographical coordinates - and geodesic distance calculation (using great-circle distance or Vincenty - distance). The distance module also contains useful routines for converting - between length and angle units. - Package: python3-geopy Architecture: all Depends: diff -Nru geopy-1.18.1/debian/copyright geopy-1.20.0/debian/copyright --- geopy-1.18.1/debian/copyright 2019-01-01 15:59:05.000000000 +0000 +++ geopy-1.20.0/debian/copyright 2019-07-22 00:22:20.000000000 +0000 @@ -8,7 +8,7 @@ License: Expat Files: debian/* -Copyright: 2012-2018, Daniele Tricoli +Copyright: 2012-2019, Daniele Tricoli License: Expat License: Expat diff -Nru geopy-1.18.1/debian/rules geopy-1.20.0/debian/rules --- geopy-1.18.1/debian/rules 2019-01-01 15:59:05.000000000 +0000 +++ geopy-1.20.0/debian/rules 2019-07-22 00:22:20.000000000 +0000 @@ -4,4 +4,4 @@ export PYBUILD_NAME=geopy %: - dh $@ --with python2,python3 --buildsystem=pybuild + dh $@ --with python3 --buildsystem=pybuild diff -Nru geopy-1.18.1/geopy/geocoders/base.py geopy-1.20.0/geopy/geocoders/base.py --- geopy-1.18.1/geopy/geocoders/base.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/base.py 2019-03-25 06:26:52.000000000 +0000 @@ -147,6 +147,17 @@ before raising a :class:`geopy.exc.GeocoderTimedOut` exception. Pass `None` to disable timeout. + .. note:: + Currently ``None`` as a value is processed correctly only + for the ``geopy.geocoders.options.default_timeout`` option + value. ``timeout=None`` as a method argument (i.e. + ``geocoder.geocode(..., timeout=None)``) would be treated + as "use timeout, as set in + ``geopy.geocoders.options.default_timeout``", and + a deprecation warning would be raised. + In geopy 2.0 this will change, so that ``timeout=None`` + would actually disable timeout. + default_user_agent User-Agent header to send with the requests to geocoder API. """ diff -Nru geopy-1.18.1/geopy/geocoders/geocodeearth.py geopy-1.20.0/geopy/geocoders/geocodeearth.py --- geopy-1.18.1/geopy/geocoders/geocodeearth.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/geocodeearth.py 2019-03-25 06:29:35.000000000 +0000 @@ -41,8 +41,16 @@ This format is now deprecated in favor of a list/tuple of a pair of geopy Points and will be removed in geopy 2.0. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `boundary_rect` instead. + :param str country_bias: Bias results to this country (ISO alpha-3). + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `country_bias` instead. + :param str domain: Specify a custom domain for Pelias API. :param int timeout: diff -Nru geopy-1.18.1/geopy/geocoders/geolake.py geopy-1.20.0/geopy/geocoders/geolake.py --- geopy-1.18.1/geopy/geocoders/geolake.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/geolake.py 2019-03-25 06:29:35.000000000 +0000 @@ -1,4 +1,4 @@ -from geopy.compat import urlencode +from geopy.compat import string_compare, urlencode from geopy.geocoders.base import DEFAULT_SENTINEL, Geocoder from geopy.location import Location from geopy.util import logger @@ -100,11 +100,18 @@ are one of: `country`, `state`, `city`, `zipcode`, `street`, `address`, `houseNumber` or `subNumber`. - :param str country_codes: Provides the geocoder with a list of country codes - that the query may reside in. This value will limit the geocoder to the - supplied countries. Te country code is a 2 character code as defined by - the ISO-3166-1 alpha-2 standard. + :param country_codes: Provides the geocoder with a list + of country codes that the query may reside in. This value will + limit the geocoder to the supplied countries. The country code + is a 2 character code as defined by the ISO-3166-1 alpha-2 + standard (e.g. ``FR``). Multiple countries can be specified with + a Python list. + + .. versionchanged:: 1.19.0 + Previously only a Python list of countries could be specified. + Now a single country as a string can be specified as well. + :type country_codes: str or list :param bool exactly_one: Return one result or a list of one result. @@ -132,10 +139,11 @@ 'q': self.format_string % query, } - if country_codes is None: + if not country_codes: country_codes = [] - - if len(country_codes): + if isinstance(country_codes, string_compare): + country_codes = [country_codes] + if country_codes: params['countryCodes'] = ",".join(country_codes) url = "?".join((self.api, urlencode(params))) diff -Nru geopy-1.18.1/geopy/geocoders/geonames.py geopy-1.20.0/geopy/geocoders/geonames.py --- geopy-1.18.1/geopy/geocoders/geonames.py 2018-12-16 13:16:12.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/geonames.py 2019-03-25 06:29:35.000000000 +0000 @@ -1,6 +1,6 @@ import warnings -from geopy.compat import urlencode +from geopy.compat import string_compare, urlencode from geopy.exc import ( ConfigurationError, GeocoderAuthenticationFailure, @@ -48,7 +48,12 @@ scheme='http', ): """ - :param str country_bias: + :param str country_bias: Records from the country_bias are listed first. + Two letter country code ISO-3166. + + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `country_bias` instead. :param str username: GeoNames username, required. Sign up here: http://www.geonames.org/login @@ -100,6 +105,15 @@ 'http://www.geonames.org/login' ) self.username = username + if country_bias is not None: + warnings.warn( + '`country_bias` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(country_bias=%(value)r) instead.' + % dict(cls=type(self).__name__, value=country_bias), + DeprecationWarning, + stacklevel=2 + ) self.country_bias = country_bias domain = 'api.geonames.org' self.api = ( @@ -115,7 +129,14 @@ "%s://%s%s" % (self.scheme, domain, self.timezone_path) ) - def geocode(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL): + def geocode( + self, + query, + exactly_one=True, + timeout=DEFAULT_SENTINEL, + country=None, + country_bias=None, + ): """ Return a location point by address. @@ -129,17 +150,41 @@ exception. Set this only if you wish to override, on this call only, the value set during the geocoder's initialization. + :param country: Limit records to the specified countries. + Two letter country code ISO-3166 (e.g. ``FR``). Might be + a single string or a list of strings. + + .. versionadded:: 1.19.0 + + :type country: str or list + + :param str country_bias: Records from the country_bias are listed first. + Two letter country code ISO-3166. + + .. versionadded:: 1.19.0 + :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if ``exactly_one=False``. """ - params = { - 'q': self.format_string % query, - 'username': self.username - } - if self.country_bias: - params['countryBias'] = self.country_bias + params = [ + ('q', self.format_string % query), + ('username', self.username), + ] + + if country_bias is None: + country_bias = self.country_bias + if country_bias: + params.append(('countryBias', country_bias)) + + if not country: + country = [] + if isinstance(country, string_compare): + country = [country] + for country_item in country: + params.append(('country', country_item)) + if exactly_one: - params['maxRows'] = 1 + params.append(('maxRows', 1)) url = "?".join((self.api, urlencode(params))) logger.debug("%s.geocode: %s", self.__class__.__name__, url) return self._parse_json( diff -Nru geopy-1.18.1/geopy/geocoders/googlev3.py geopy-1.20.0/geopy/geocoders/googlev3.py --- geopy-1.18.1/geopy/geocoders/googlev3.py 2018-12-16 13:16:12.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/googlev3.py 2019-03-26 06:08:29.000000000 +0000 @@ -103,7 +103,11 @@ if secret_key and not client_id: raise ConfigurationError('Must provide client_id with secret_key.') - if not api_key: + self.premier = bool(client_id and secret_key) + self.client_id = client_id + self.secret_key = secret_key + + if not self.premier and not api_key: warnings.warn( 'Since July 2018 Google requires each request to have an API key. ' 'Pass a valid `api_key` to GoogleV3 geocoder to hide this warning. ' @@ -115,9 +119,6 @@ self.api_key = api_key self.domain = domain.strip('/') - self.premier = bool(client_id and secret_key) - self.client_id = client_id - self.secret_key = secret_key self.channel = channel self.api = '%s://%s%s' % (self.scheme, self.domain, self.api_path) @@ -163,6 +164,7 @@ bounds=None, region=None, components=None, + place_id=None, language=None, sensor=False, ): @@ -204,6 +206,13 @@ :param dict components: Restricts to an area. Can use any combination of: route, locality, administrative_area, postal_code, country. + :param str place_id: Retrieve a Location using a Place ID. + Cannot be not used with ``query`` or ``bounds`` parameters. + + >>> g.geocode(place_id='ChIJOcfP0Iq2j4ARDrXUa7ZWs34') + + .. versionadded:: 1.19.0 + :param str language: The language in which to return results. :param bool sensor: Whether the geocoding request comes from a @@ -215,10 +224,21 @@ params = { 'sensor': str(sensor).lower() } - if query is None and not components: - raise ValueError('Either `query` or `components` must be set.`') + if place_id and (bounds or query): + raise ValueError( + 'Only one of the `query` or `place id` or `bounds` ' + ' parameters must be entered.') + + if place_id is not None: + params['place_id'] = place_id + if query is not None: params['address'] = self.format_string % query + + if query is None and place_id is None and not components: + raise ValueError('Either `query` or `components` or `place_id` ' + 'must be set.') + if self.api_key: params['key'] = self.api_key if bounds: @@ -226,7 +246,7 @@ warnings.warn( 'GoogleV3 `bounds` format of ' '`[latitude, longitude, latitude, longitude]` is now ' - 'deprecated and will be not supported in geopy 2.0. ' + 'deprecated and will not be supported in geopy 2.0. ' 'Use `[Point(latitude, longitude), Point(latitude, longitude)]` ' 'instead.', DeprecationWarning, diff -Nru geopy-1.18.1/geopy/geocoders/mapbox.py geopy-1.20.0/geopy/geocoders/mapbox.py --- geopy-1.18.1/geopy/geocoders/mapbox.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/mapbox.py 2019-05-26 11:28:19.000000000 +0000 @@ -1,4 +1,4 @@ -from geopy.compat import quote, urlencode +from geopy.compat import quote, string_compare, urlencode from geopy.geocoders.base import DEFAULT_SENTINEL, Geocoder from geopy.location import Location from geopy.point import Point @@ -75,10 +75,9 @@ def parse_feature(feature): location = feature['place_name'] - place = feature['text'] longitude = feature['geometry']['coordinates'][0] latitude = feature['geometry']['coordinates'][1] - return Location(location, (latitude, longitude), place) + return Location(location, (latitude, longitude), feature) if exactly_one: return parse_feature(features[0]) else: @@ -96,11 +95,19 @@ """ Return a location point by address + .. versionchanged:: 1.20.0 + Previously due to a bug the resulting :class:`geopy.location.Location`'s + ``raw`` attribute contained a single string instead of a full + service response. + :param str query: The address or query you wish to geocode. :param bool exactly_one: Return one result or a list of results, if available. + .. versionchanged:: 1.20.0 + Previously due to a bug this parameter wasn't respected. + :param int timeout: Time, in seconds, to wait for the geocoding service to respond before raising a :class:`geopy.exc.GeocoderTimedOut` exception. Set this only if you wish to override, on this call @@ -111,8 +118,15 @@ :type proximity: :class:`geopy.point.Point`, list or tuple of ``(latitude, longitude)``, or string as ``"%(latitude)s, %(longitude)s"``. - :param string country: Country to filter result in form of - ISO 3166-1 alpha-2 country code. + :param country: Country to filter result in form of + ISO 3166-1 alpha-2 country code (e.g. ``FR``). + Might be a Python list of strings. + + .. versionchanged:: 1.19.0 + Previously only a single string could be specified. + Now a Python list of individual countries is supported. + + :type country: str or list :param bbox: The bounding box of the viewport within which to bias geocode results more prominently. @@ -131,8 +145,12 @@ params['bbox'] = self._format_bounding_box( bbox, "%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)s") + if not country: + country = [] + if isinstance(country, string_compare): + country = [country] if country: - params['country'] = country + params['country'] = ",".join(country) if proximity: p = Point(proximity) @@ -144,7 +162,7 @@ logger.debug("%s.geocode: %s", self.__class__.__name__, url) return self._parse_json( - self._call_geocoder(url, timeout=timeout) + self._call_geocoder(url, timeout=timeout), exactly_one ) def reverse( @@ -156,6 +174,11 @@ """ Return an address by location point. + .. versionchanged:: 1.20.0 + Previously due to a bug the resulting :class:`geopy.location.Location`'s + ``raw`` attribute contained a single string instead of a full + service response. + :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude, diff -Nru geopy-1.18.1/geopy/geocoders/opencage.py geopy-1.20.0/geopy/geocoders/opencage.py --- geopy-1.18.1/geopy/geocoders/opencage.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/opencage.py 2019-03-25 06:29:35.000000000 +0000 @@ -113,11 +113,17 @@ This format is now deprecated in favor of a list/tuple of a pair of geopy Points and will be removed in geopy 2.0. - :param str country: Provides the geocoder with a hint to the - country that the query resides in. This value will help the - geocoder but will not restrict the possible results to the - supplied country. The country code is a 3 character code as - defined by the ISO 3166-1 Alpha 3 standard. + :param country: Restricts the results to the specified + country or countries. The country code is a 2 character code as + defined by the ISO 3166-1 Alpha 2 standard (e.g. ``fr``). + Might be a Python list of strings. + + .. versionchanged:: 1.19.0 + This parameter didn't seem to be respected previously. + Also, previously only a single string could be specified. + Now a Python list of individual countries is supported. + + :type country: str or list :param bool exactly_one: Return one result or a list of results, if available. @@ -140,7 +146,7 @@ warnings.warn( 'OpenCage `bounds` format of ' '`"longitude,latitude,longitude,latitude"` is now ' - 'deprecated and will be not supported in geopy 2.0. ' + 'deprecated and will not be supported in geopy 2.0. ' 'Use `[Point(latitude, longitude), Point(latitude, longitude)]` ' 'instead.', DeprecationWarning, @@ -152,8 +158,13 @@ bounds, "%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)s") if language: params['language'] = language + + if not country: + country = [] + if isinstance(country, string_compare): + country = [country] if country: - params['country'] = country + params['countrycode'] = ",".join(country) url = "?".join((self.api, urlencode(params))) diff -Nru geopy-1.18.1/geopy/geocoders/openmapquest.py geopy-1.20.0/geopy/geocoders/openmapquest.py --- geopy-1.18.1/geopy/geocoders/openmapquest.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/openmapquest.py 2019-03-25 06:29:35.000000000 +0000 @@ -23,7 +23,7 @@ api_key=None, format_string=None, view_box=None, - bounded=False, + bounded=None, country_bias=None, timeout=DEFAULT_SENTINEL, proxies=DEFAULT_SENTINEL, @@ -50,15 +50,29 @@ .. versionadded:: 1.17.0 + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `viewbox` instead. + :param bool bounded: Restrict the results to only items contained within the bounding view_box. .. versionadded:: 1.17.0 - :param str country_bias: Bias results to this country. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `bounded` instead. + + :type country_bias: str or list + :param country_bias: Limit search results to a specific country. + This param sets a default value for the `geocode`'s ``country_codes``. .. versionadded:: 1.17.0 + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `country_codes` instead. + :param int timeout: See :attr:`geopy.geocoders.options.default_timeout`. @@ -104,7 +118,7 @@ """ Construct geocoding request url. Overridden. - :param string base_api: Geocoding function base address - self.api + :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. diff -Nru geopy-1.18.1/geopy/geocoders/osm.py geopy-1.20.0/geopy/geocoders/osm.py --- geopy-1.18.1/geopy/geocoders/osm.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/osm.py 2019-03-25 06:29:35.000000000 +0000 @@ -1,6 +1,6 @@ import warnings -from geopy.compat import urlencode +from geopy.compat import string_compare, urlencode from geopy.exc import GeocoderQueryError from geopy.geocoders.base import _DEFAULT_USER_AGENT, DEFAULT_SENTINEL, Geocoder from geopy.location import Location @@ -50,7 +50,7 @@ self, format_string=None, view_box=None, - bounded=False, + bounded=None, country_bias=None, timeout=DEFAULT_SENTINEL, proxies=DEFAULT_SENTINEL, @@ -79,12 +79,26 @@ This format is now deprecated in favor of a list/tuple of a pair of geopy Points and will be removed in geopy 2.0. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `viewbox` instead. + :param bool bounded: Restrict the results to only items contained within the bounding view_box. .. versionadded:: 1.15.0 - :param str country_bias: Bias results to this country. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `bounded` instead. + + :type country_bias: str or list + :param country_bias: Limit search results to a specific country. + This param sets a default value for the `geocode`'s ``country_codes``. + + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `country_codes` instead. :param int timeout: See :attr:`geopy.geocoders.options.default_timeout`. @@ -122,9 +136,40 @@ user_agent=user_agent, ssl_context=ssl_context, ) + + if country_bias is not None: + warnings.warn( + '`country_bias` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(country_codes=%(value)r) instead.' + % dict(cls=type(self).__name__, value=country_bias), + DeprecationWarning, + stacklevel=2 + ) self.country_bias = country_bias + + if view_box is not None: + warnings.warn( + '`view_box` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(viewbox=%(value)r) instead.' + % dict(cls=type(self).__name__, value=view_box), + DeprecationWarning, + stacklevel=2 + ) self.view_box = view_box + + if bounded is not None: + warnings.warn( + '`bounded` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(bounded=%(value)r) instead.' + % dict(cls=type(self).__name__, value=bounded), + DeprecationWarning, + stacklevel=2 + ) self.bounded = bounded + self.domain = domain.strip('/') if (self.domain == _DEFAULT_NOMINATIM_DOMAIN @@ -153,7 +198,7 @@ The method can be overriden in Nominatim-based geocoders in order to extend URL parameters. - :param string base_api: Geocoding function base address - self.api + :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. @@ -172,6 +217,9 @@ language=False, geometry=None, extratags=False, + country_codes=None, + viewbox=None, + bounded=None, # TODO: change default value to `False` in geopy 2.0 ): """ Return a location point by address. @@ -226,6 +274,28 @@ .. versionadded:: 1.17.0 + :param country_codes: Limit search results + to a specific country (or a list of countries). + A country_code should be the ISO 3166-1alpha2 code, + e.g. ``gb`` for the United Kingdom, ``de`` for Germany, etc. + + .. versionadded:: 1.19.0 + + :type country_codes: str or list + + :type viewbox: list or tuple of 2 items of :class:`geopy.point.Point` or + ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``. + + :param viewbox: Coordinates to restrict search within. + Example: ``[Point(22, 180), Point(-22, -180)]``. + + .. versionadded:: 1.19.0 + + :param bool bounded: Restrict the results to only items contained + within the bounding view_box. Defaults to `False`. + + .. versionadded:: 1.19.0 + :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if ``exactly_one=False``. @@ -253,14 +323,14 @@ raise ValueError("Limit cannot be less than 1") params['limit'] = limit - # `viewbox` apparently replaces `view_box` - if self.view_box: + if viewbox is None: viewbox = self.view_box + if viewbox: if len(viewbox) == 4: warnings.warn( - '%s `view_box` format of ' + '%s `viewbox` format of ' '`[longitude, latitude, longitude, latitude]` is now ' - 'deprecated and will be not supported in geopy 2.0. ' + 'deprecated and will not be supported in geopy 2.0. ' 'Use `[Point(latitude, longitude), Point(latitude, longitude)]` ' 'instead.' % type(self).__name__, DeprecationWarning, @@ -271,11 +341,19 @@ params['viewbox'] = self._format_bounding_box( viewbox, "%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)s") - if self.bounded: + if bounded is None: + bounded = self.bounded + if bounded: params['bounded'] = 1 - if self.country_bias: - params['countrycodes'] = self.country_bias + if country_codes is None: + country_codes = self.country_bias + if not country_codes: + country_codes = [] + if isinstance(country_codes, string_compare): + country_codes = [country_codes] + if country_codes: + params['countrycodes'] = ",".join(country_codes) if addressdetails: params['addressdetails'] = 1 diff -Nru geopy-1.18.1/geopy/geocoders/pelias.py geopy-1.20.0/geopy/geocoders/pelias.py --- geopy-1.18.1/geopy/geocoders/pelias.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/pelias.py 2019-03-25 06:29:35.000000000 +0000 @@ -59,8 +59,16 @@ This format is now deprecated in favor of a list/tuple of a pair of geopy Points and will be removed in geopy 2.0. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `boundary_rect` instead. + :param str country_bias: Bias results to this country (ISO alpha-3). + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `country_bias` instead. + :param int timeout: See :attr:`geopy.geocoders.options.default_timeout`. @@ -86,7 +94,25 @@ user_agent=user_agent, ssl_context=ssl_context, ) + if country_bias is not None: + warnings.warn( + '`country_bias` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(country_bias=%(value)r) instead.' + % dict(cls=type(self).__name__, value=country_bias), + DeprecationWarning, + stacklevel=2 + ) self.country_bias = country_bias + if boundary_rect is not None: + warnings.warn( + '`boundary_rect` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(boundary_rect=%(value)r) instead.' + % dict(cls=type(self).__name__, value=boundary_rect), + DeprecationWarning, + stacklevel=2 + ) self.boundary_rect = boundary_rect self.api_key = api_key self.domain = domain.strip('/') @@ -103,6 +129,8 @@ query, exactly_one=True, timeout=DEFAULT_SENTINEL, + boundary_rect=None, + country_bias=None, ): """ Return a location point by address. @@ -118,6 +146,17 @@ exception. Set this only if you wish to override, on this call only, the value set during the geocoder's initialization. + :type boundary_rect: list or tuple of 2 items of :class:`geopy.point.Point` + or ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``. + :param boundary_rect: Coordinates to restrict search within. + Example: ``[Point(22, 180), Point(-22, -180)]``. + + .. versionadded:: 1.19.0 + + :param str country_bias: Bias results to this country (ISO alpha-3). + + .. versionadded:: 1.19.0 + :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if ``exactly_one=False``. """ @@ -128,13 +167,14 @@ 'api_key': self.api_key }) - if self.boundary_rect: + if boundary_rect is None: boundary_rect = self.boundary_rect + if boundary_rect: if len(boundary_rect) == 4: warnings.warn( '%s `boundary_rect` format of ' '`[longitude, latitude, longitude, latitude]` is now ' - 'deprecated and will be not supported in geopy 2.0. ' + 'deprecated and will not be supported in geopy 2.0. ' 'Use `[Point(latitude, longitude), Point(latitude, longitude)]` ' 'instead.' % type(self).__name__, DeprecationWarning, @@ -149,8 +189,10 @@ params['boundary.rect.max_lon'] = lon2 params['boundary.rect.max_lat'] = lat2 - if self.country_bias: - params['boundary.country'] = self.country_bias + if country_bias is None: + country_bias = self.country_bias + if country_bias: + params['boundary.country'] = country_bias url = "?".join((self.geocode_api, urlencode(params))) logger.debug("%s.geocode_api: %s", self.__class__.__name__, url) diff -Nru geopy-1.18.1/geopy/geocoders/pickpoint.py geopy-1.20.0/geopy/geocoders/pickpoint.py --- geopy-1.18.1/geopy/geocoders/pickpoint.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/pickpoint.py 2019-03-25 06:29:35.000000000 +0000 @@ -22,7 +22,7 @@ api_key, format_string=None, view_box=None, - bounded=False, + bounded=None, country_bias=None, timeout=DEFAULT_SENTINEL, proxies=DEFAULT_SENTINEL, @@ -33,7 +33,7 @@ ): """ - :param string api_key: PickPoint API key obtained at + :param str api_key: PickPoint API key obtained at https://pickpoint.io. :param str format_string: @@ -50,11 +50,25 @@ This format is now deprecated in favor of a list/tuple of a pair of geopy Points and will be removed in geopy 2.0. - :param string country_bias: Bias results to this country. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `viewbox` instead. :param bool bounded: Restrict the results to only items contained within the bounding view_box. + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `bounded` instead. + + :type country_bias: str or list + :param country_bias: Limit search results to a specific country. + This param sets a default value for the `geocode`'s ``country_codes``. + + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `country_codes` instead. + :param int timeout: See :attr:`geopy.geocoders.options.default_timeout`. @@ -95,7 +109,7 @@ """ Construct geocoding request url. Overridden. - :param string base_api: Geocoding function base address - self.api + :param str base_api: Geocoding function base address - self.api or self.reverse_api. :param dict params: Geocoding params. diff -Nru geopy-1.18.1/geopy/geocoders/smartystreets.py geopy-1.20.0/geopy/geocoders/smartystreets.py --- geopy-1.18.1/geopy/geocoders/smartystreets.py 2018-12-02 13:53:32.000000000 +0000 +++ geopy-1.20.0/geopy/geocoders/smartystreets.py 2019-03-25 06:29:35.000000000 +0000 @@ -1,3 +1,5 @@ +import warnings + from geopy.compat import urlencode from geopy.exc import ConfigurationError, GeocoderQuotaExceeded from geopy.geocoders.base import DEFAULT_SENTINEL, Geocoder @@ -20,7 +22,7 @@ self, auth_id, auth_token, - candidates=1, + candidates=None, scheme='https', timeout=DEFAULT_SENTINEL, proxies=DEFAULT_SENTINEL, @@ -38,7 +40,11 @@ :param int candidates: An integer between 1 and 10 indicating the max number of candidate addresses to return if a valid address - could be found. + could be found. Defaults to `1`. + + .. deprecated:: 1.19.0 + This argument will be removed in geopy 2.0. + Use `geocode`'s `candidates` instead. :param str scheme: Must be ``https``. @@ -87,14 +93,30 @@ raise ConfigurationError("LiveAddress now requires `https`.") self.auth_id = auth_id self.auth_token = auth_token + if candidates: if not (1 <= candidates <= 10): raise ValueError('candidates must be between 1 and 10') + if candidates is not None: + warnings.warn( + '`candidates` argument of the %(cls)s.__init__ ' + 'is deprecated and will be removed in geopy 2.0. Use ' + '%(cls)s.geocode(candidates=%(value)r) instead.' + % dict(cls=type(self).__name__, value=candidates), + DeprecationWarning, + stacklevel=2 + ) self.candidates = candidates domain = 'api.smartystreets.com' self.api = '%s://%s%s' % (self.scheme, domain, self.geocode_path) - def geocode(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL): + def geocode( + self, + query, + exactly_one=True, + timeout=DEFAULT_SENTINEL, + candidates=None, # TODO: change default value to `1` in geopy 2.0 + ): """ Return a location point by address. @@ -108,10 +130,34 @@ exception. Set this only if you wish to override, on this call only, the value set during the geocoder's initialization. + :param int candidates: An integer between 1 and 10 indicating the max + number of candidate addresses to return if a valid address + could be found. Defaults to `1`. + + .. versionadded:: 1.19.0 + :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if ``exactly_one=False``. """ - url = self._compose_url(self.format_string % query) + + if candidates is None: + candidates = self.candidates + + if candidates is None: + candidates = 1 # TODO: move to default args in geopy 2.0. + + if candidates: + if not (1 <= candidates <= 10): + raise ValueError('candidates must be between 1 and 10') + + query = { + 'auth-id': self.auth_id, + 'auth-token': self.auth_token, + 'street': self.format_string % query, + 'candidates': candidates, + } + url = '{url}?{query}'.format(url=self.api, query=urlencode(query)) + logger.debug("%s.geocode: %s", self.__class__.__name__, url) return self._parse_json(self._call_geocoder(url, timeout=timeout), exactly_one) @@ -123,18 +169,6 @@ if "no active subscriptions found" in message.lower(): raise GeocoderQuotaExceeded(message) - def _compose_url(self, location): - """ - Generate API URL. - """ - query = { - 'auth-id': self.auth_id, - 'auth-token': self.auth_token, - 'street': location, - 'candidates': self.candidates - } - return '{url}?{query}'.format(url=self.api, query=urlencode(query)) - def _parse_json(self, response, exactly_one=True): """ Parse responses as JSON objects. diff -Nru geopy-1.18.1/geopy/util.py geopy-1.20.0/geopy/util.py --- geopy-1.18.1/geopy/util.py 2018-12-16 13:26:01.000000000 +0000 +++ geopy-1.20.0/geopy/util.py 2019-05-26 11:40:14.000000000 +0000 @@ -17,7 +17,7 @@ pass -__version__ = "1.18.1" +__version__ = "1.20.0" logger = logging.getLogger('geopy') diff -Nru geopy-1.18.1/geopy.egg-info/PKG-INFO geopy-1.20.0/geopy.egg-info/PKG-INFO --- geopy-1.18.1/geopy.egg-info/PKG-INFO 2018-12-16 13:27:18.000000000 +0000 +++ geopy-1.20.0/geopy.egg-info/PKG-INFO 2019-05-26 11:41:12.000000000 +0000 @@ -1,12 +1,12 @@ Metadata-Version: 2.1 Name: geopy -Version: 1.18.1 +Version: 1.20.0 Summary: Python Geocoding Toolbox Home-page: https://github.com/geopy/geopy Author: GeoPy Contributors Author-email: uijllji@gmail.com License: MIT -Download-URL: https://github.com/geopy/geopy/archive/1.18.1.tar.gz +Download-URL: https://github.com/geopy/geopy/archive/1.20.0.tar.gz Description: geopy ===== @@ -145,8 +145,8 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy -Provides-Extra: timezone Provides-Extra: dev Provides-Extra: dev-test -Provides-Extra: dev-docs +Provides-Extra: timezone Provides-Extra: dev-lint +Provides-Extra: dev-docs diff -Nru geopy-1.18.1/PKG-INFO geopy-1.20.0/PKG-INFO --- geopy-1.18.1/PKG-INFO 2018-12-16 13:27:19.000000000 +0000 +++ geopy-1.20.0/PKG-INFO 2019-05-26 11:41:12.000000000 +0000 @@ -1,12 +1,12 @@ Metadata-Version: 2.1 Name: geopy -Version: 1.18.1 +Version: 1.20.0 Summary: Python Geocoding Toolbox Home-page: https://github.com/geopy/geopy Author: GeoPy Contributors Author-email: uijllji@gmail.com License: MIT -Download-URL: https://github.com/geopy/geopy/archive/1.18.1.tar.gz +Download-URL: https://github.com/geopy/geopy/archive/1.20.0.tar.gz Description: geopy ===== @@ -145,8 +145,8 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy -Provides-Extra: timezone Provides-Extra: dev Provides-Extra: dev-test -Provides-Extra: dev-docs +Provides-Extra: timezone Provides-Extra: dev-lint +Provides-Extra: dev-docs