INNER CODE UNIT · Python
uid_for_entry
skarndev/umodel_tools · umodel_tools/asset_db.py:53
def uid_for_entry(self, dir_path: str) -> str:
"""Return an asset catalogue ID for the given path, create one if it does not yet exist.
:param dir_path: Directory relative to ``db_root_path``.
:return: RFC_4122 UUID string.
"""
dir_path = dir_path.replace('\\', '/')
# search already existing UID
for uid, (full_path, _) in self._catalogs.items():
if full_path == dir_path:
return uid
# generate new entry
uid = uuid.uuid1()
assert uid.variant == uuid.RFC_4122
self._catalogs[str(uid)] = dir_path, dir_path.replace('/', '-')