trustcafe-api-wrapper/utils/get_parent_pksk_from_path.py
2026-04-01 22:14:57 +01:00

14 lines
No EOL
472 B
Python

def get_parent_pksk_from_path(parent_path):
if parent_path == '/':
return 'maintrunk#maintrunk'
entity, slug = parent_path.strip('/').split('/')
if entity == 'branch':
entity = 'subwiki'
elif entity != 'user':
entity = 'userprofile'
if entity not in ['userprofile', 'subwiki']:
raise ValueError(f"Invalid parent entity: {entity}. Must be 'userprofile' or 'branch'.")
return f"{entity}#{slug}"