Skip to content
Snippets Groups Projects
Commit 52b15970 authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add test data and accessor function

parent 23f8da7f
No related branches found
No related tags found
No related merge requests found
include README.rst
include LICENSE
include requirements.txt
include requirements-dev.txt
recursive-include km3net_testdata/data
from __future__ import absolute_import
import os
from pkg_resources import get_distribution, DistributionNotFound
version = get_distribution(__name__).version
import importlib_resources
try:
version = get_distribution(__name__).version
except DistributionNotFound:
version = "unknown version"
__version__ = version
try:
from importlib_resources import as_file
except ImportError:
from importlib_resources.trees import as_file
try:
from contextlib import ExitStack
except ImportError:
from contextlib2 import ExitStack
import atexit
def data_path(filename, raise_missing=True):
"""Return the absolute filepath for a given filename in test data"""
ref = importlib_resources.files("km3net_testdata.data") / filename
file_manager = ExitStack()
atexit.register(file_manager.close)
file_path = file_manager.enter_context(as_file(ref))
if raise_missing and not file_path.exists():
raise RuntimeError("Unknown or missing file: {0}".format(filename))
return str(file_path)
def data_path(*path_elements):
return os.path.join(*path_elements)
__all__ = ["data_path"]
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment