_util.py
1 """Shared utilities for locating bundled data files.""" 2 3 import os 4 from importlib.resources import files 5 6 7 def get_data_path(filename): 8 """Resolve a bundled data file, checking cwd first for user overrides.""" 9 # Check current working directory first (user can override with local files) 10 if os.path.isfile(filename): 11 return filename 12 # Then check package data 13 resource_path = str(files('ppp.data').joinpath(filename)) 14 if os.path.isfile(resource_path): 15 return resource_path 16 return None