Source code for hepi.data.data

import importlib.resources
import os

[docs] def get_json_dir(): """ Get the path to the data directory Returns ------- importlib.resources.abc.Traversable Path-like handle to the packaged JSON data directory. """ return importlib.resources.files(".".join(__name__.split(".")[:-1])).joinpath( "json" )
[docs] def list_json_files(): """ List all files in the data directory Returns ------- list List of files in the data directory """ return [ os.path.basename(b) for b in get_json_dir() .iterdir() ]
[docs] def list_files(): return list_json_files()
[docs] def get_json_file(filename : str): """ Get the content of a file in the data directory Parameters ---------- filename : str Name of the file Returns ------- importlib.resources.abc.Traversable Path-like handle to the file """ return ( get_json_dir() .joinpath(filename))
[docs] def get_file(filename : str): return get_json_file(filename)