get_parent_pksk_from_path utils function
This commit is contained in:
parent
4f14965ba1
commit
010d54bc87
3 changed files with 18 additions and 15 deletions
1
utils/__init__.py
Normal file
1
utils/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from .get_parent_pksk_from_path import get_parent_pksk_from_path
|
||||
14
utils/get_parent_pksk_from_path.py
Normal file
14
utils/get_parent_pksk_from_path.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue