InvalidFileFormatError

class pydriosm.errors.InvalidFileFormatError(osm_file_format, valid_file_formats=None)[source]

Exception raised when an invalid OpenStreetMap file format is specified.

This exception is raised during file validation when an input file format or extension is not recognized by the downloader or reader modules.

Parameters:
  • osm_file_format (str) – File format or extension of the OSM data.

  • valid_file_formats (collections.abc.Iterable | None) – Supported file formats or extensions, defaults to None.

Variables:
  • osm_file_format (str) – Provided file format or extension.

  • valid_file_formats (collections.abc.Iterable | None) – Supported file formats or extensions.

  • message (str) – Formatted exception message.

Examples:

>>> from pydriosm.errors import InvalidFileFormatError
>>> raise InvalidFileFormatError(osm_file_format='abc')
Traceback (most recent call last):
  ...
pydriosm.errors.InvalidFileFormatError:
  `osm_file_format='abc'` -> The input `osm_file_format` is unidentifiable.

>>> from pydriosm.downloader import GeofabrikDownloader, BBBikeDownloader
>>> gfd = GeofabrikDownloader()
>>> gfd.validate_file_format(osm_file_format='abc')
Traceback (most recent call last):
  ...
pydriosm.errors.InvalidFileFormatError:
  `osm_file_format='abc'` -> The input `osm_file_format` is unidentifiable.
    Valid options include: {'.osm.bz2', '.osm.pbf', '.gpkg.zip', '.shp.zip'}.

>>> valid_formats = {'.shp.zip', '.osm.pbf', '.osm.bz2', '.gpkg.zip'}
>>> raise InvalidFileFormatError(
...     osm_file_format='abc', valid_file_formats=valid_formats
... )
Traceback (most recent call last):
  ...
pydriosm.errors.InvalidFileFormatError:
  `osm_file_format='abc'` -> The input `osm_file_format` is unidentifiable.
    Valid options include: {'.osm.bz2', '.osm.pbf', '.gpkg.zip', '.shp.zip'}.