# ----------------------------------------------------------------------------# SymForce - Copyright 2022, Skydio, Inc.# This source code is under the Apache 2.0 license found in the LICENSE file.# ----------------------------------------------------------------------------importjsonimporttypingasTfrompathlibimportPath
class_Manifest:""" Internal class to manage loading data from the build manifest and caching that data. Not intended for use outside of path_util.py. """_manifest:T.Optional[T.Dict[str,str]]=None@classmethoddef_ensure_loaded(cls)->None:ifcls._manifestisNone:manifest_path=Path(__file__).parent.parent/"build"/"manifest.json"try:withopen(manifest_path)asf:cls._manifest=json.load(f)exceptFileNotFoundErrorasex:raiseMissingManifestException(f"Manifest not found at {manifest_path}")fromex@classmethoddefget_entry(cls,key:str)->Path:cls._ensure_loaded()assertcls._manifestisnotNonereturnPath(cls._manifest[key]).resolve()@classmethoddefget_entries(cls,key:str)->T.List[Path]:cls._ensure_loaded()assertcls._manifestisnotNonereturn[Path(s).resolve()forsincls._manifest[key]]
[docs]defsymforce_root()->Path:""" The root directory of the symforce project """returnPath(__file__).parent.parent
[docs]defsymforce_data_root()->Path:""" The root directory of the symforce project, for use accessing data that might need to be updated (such as generated files). Most of the time this is the same as :func:`symforce_root`, but when the ``--update`` flag is passed to a test, this is guaranteed to point to the *resolved* version, i.e. the actual symforce location on disk regardless of whether this path is a symlink. """fromsymforce.test_util.test_case_mixinimportSymforceTestCaseMixinifSymforceTestCaseMixin.should_update():returnPath(__file__).resolve().parent.parentelse:returnsymforce_root()