Skip to content

Commit

Permalink
Added support for exclude_ireland option
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Apr 7, 2021
1 parent ca4da37 commit eb9c177
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions geouk/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,40 @@ def random(cls, client, lat, lon, d):
return None

@classmethod
def search(cls, client, q):
def search(cls, client, q, exclude_ireland=False):
"""
Fetch a list of places that match the given query string.
"""

params = {'q': q}
if exclude_ireland:
params['exclude_ireland'] = True

# Fetch the matching places
r = client(
'get',
'places/search',
params={'q': q}
params=params
)

return [cls(client, p) for p in r]

@classmethod
def typeahead(cls, client, q):
def typeahead(cls, client, q, exclude_ireland=False):
"""
Return a list of place names and postcodes starting with the query
string's first 2 characters
"""

params = {'q': q}
if exclude_ireland:
params['exclude_ireland'] = True

# Fetch the typeahead results
r = client(
'get',
'places/typeahead',
params={'q': q}
params=params
)

return r
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.0.5',
version='0.0.6',
description=(
'The GeoUK Python library provides a pythonic interface to the GeoUK '
'API.',
Expand Down

0 comments on commit eb9c177

Please sign in to comment.