_Reader.validate_file_path

classmethod _Reader.validate_file_path(path_to_osm_file, osm_filename=None, data_dir=None)

Validate the pathname of an OSM data file.

Parameters
  • path_to_osm_file (str or os.PathLike[str]) – pathname of an OSM data file

  • osm_filename (str) – filename of the OSM data file

  • data_dir (str or os.PathLike[str]) – name or pathname of the data directory

Returns

validated pathname of the specified OSM data file

Return type

str

Tests:

>>> from pydriosm.reader import _Reader
>>> import os

>>> file_path = _Reader.validate_file_path("a\b\c.osm.pbf")
>>> file_path
'a\b\c.osm.pbf'
>>> file_path = _Reader.validate_file_path("a\b\c.osm.pbf", "x.y.z", data_dir="a\b")
>>> os.path.relpath(file_path)
'a\b\x.y.z'