Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_path(dataset):
""" Construct a file path to a dataset.
Parameters
----------
dataset: string
Name of a dataset to access (e.g., "epsg.json", or "RGB.byte.tif")
Returns
-------
A file path (string) to the dataset
"""
earthpy_path = os.path.split(earthpy.__file__)[0]
data_dir = os.path.join(earthpy_path, "data")
data_files = os.listdir(data_dir)
if dataset not in data_files:
raise KeyError(dataset + " not found in earthpy example data.")
return os.path.join(data_dir, dataset)
----------
dataset: string
Name of a dataset to access (e.g., "epsg.json", or "RGB.byte.tif")
Returns
-------
A file path (string) to the dataset
Example
-------
>>> import earthpy.io as eio
>>> eio.path_to_example('rmnp-dem.tif')
'...rmnp-dem.tif'
"""
earthpy_path = os.path.split(earthpy.__file__)[0]
data_dir = os.path.join(earthpy_path, "example-data")
data_files = os.listdir(data_dir)
if dataset not in data_files:
raise KeyError(dataset + " not found in earthpy example data.")
return os.path.join(data_dir, dataset)