classmethod _Downloader.validate_subregion_name(subregion_name, valid_subregion_names=None, raise_err=True, **kwargs)[source]

Validate an input name of a geographic (sub)region.

The validation is done by matching the input to a name of a geographic (sub)region available on a free download server.

  • subregion_name (str) – name/URL of a (sub)region available on a free download server

  • valid_subregion_names (Iterable) – names of all (sub)regions available on a free download server

  • raise_err (bool) – (if the input fails to match a valid name) whether to raise the error pydriosm.downloader.InvalidSubregionName, defaults to True

  • kwargs – [optional] parameters of pyhelpers.text.find_similar_str()


valid subregion name that matches (or is the most similar to) the input

Return type:



>>> from pydriosm.downloader import _Downloader

>>> subrgn_name = 'abc'
>>> _Downloader.validate_subregion_name(subrgn_name)
Traceback (most recent call last):
    1) `subregion_name` fails to match any in `<downloader>.valid_subregion_names`; or
    2) The queried (sub)region is not available on the free download server.

>>> avail_subrgn_names = ['Greater London', 'Great Britain', 'Birmingham', 'Leeds']

>>> subrgn_name = 'Britain'
>>> _Downloader.validate_subregion_name(subrgn_name, avail_subrgn_names)
'Great Britain'

>>> subrgn_name = 'london'
>>> _Downloader.validate_subregion_name(subrgn_name, avail_subrgn_names)
'Greater London'