31 lines
976 B
Python
31 lines
976 B
Python
from pathlib import Path
|
|
|
|
from database.connect import BACKEND_DIR
|
|
|
|
|
|
OPENAPI_DATA_DIR = BACKEND_DIR / 'openapi' / 'data'
|
|
LOCALES = {'cn', 'kr'}
|
|
|
|
|
|
def openapi_locale_path(locale: str, job_id: str, job_grow_id: str, *parts: str) -> Path:
|
|
return OPENAPI_DATA_DIR / locale / job_id / job_grow_id / Path(*parts)
|
|
|
|
|
|
def logical_skill_detail_path(prefix: str) -> Path:
|
|
parts = prefix.split('/')
|
|
if len(parts) < 5 or parts[2] not in LOCALES:
|
|
return OPENAPI_DATA_DIR / f'{prefix}.json'
|
|
|
|
job_id, job_grow_id, locale = parts[:3]
|
|
return openapi_locale_path(locale, job_id, job_grow_id, *parts[3:]).with_suffix('.json')
|
|
|
|
|
|
def logical_skill_detail_prefix(path: Path) -> str:
|
|
relative = path.relative_to(OPENAPI_DATA_DIR).with_suffix('')
|
|
parts = relative.parts
|
|
if len(parts) >= 5 and parts[0] in LOCALES:
|
|
locale, job_id, job_grow_id = parts[:3]
|
|
return '/'.join((job_id, job_grow_id, locale, *parts[3:]))
|
|
|
|
return relative.as_posix()
|