Source code for km3dq_common

import atexit
import sys


try:
    from importlib.metadata import version as get_version
[docs] version = get_version(__name__)
except ImportError: from pkg_resources import get_distribution version = get_distribution(__name__).version from .calc import Calculator if sys.version_info < (3, 9): import importlib_resources try: from importlib_resources import as_file except ImportError: from importlib_resources.trees import as_file else: import importlib.resources as importlib_resources from importlib.resources import as_file try: from contextlib import ExitStack except ImportError: from contextlib2 import ExitStack
[docs] def config_path(filename, raise_missing=True): """Return the absolute filepath for a given filename in Config""" ref = importlib_resources.files("km3dq_common") / f"/pbs/home/t/trocme/KM3Net/infrastructure/km3dq_lw_db/Common/{filename}.toml" 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)