You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
911 B

# - GPLv3
# The Pyrocko Developers, 21st Century
# ---|P------/S----------~Lg----------
import os
from pyrocko import util
import logging
logger = logging.getLogger('pyrocko.example')
def get_example_data(filename, url=None, recursive=False):
Download example data file needed in tutorials.
The file is downloaded to given ``filename``. If there already exists a
file with that name, nothing is done.
:param filename: name of the required file
:param url: if not ``None`` get file from given URL otherwise fetch it from<filename>.
:returns: ``filename``
if not os.path.exists(filename):
url = '' + filename
if recursive:
util.download_dir(url, filename)
util.download_file(url, filename)
return filename