Files
zkxw/backend/app/utils/production_task_name_placeholders.py
T
2026-09-01 11:32:49 +08:00

18 lines
647 B
Python

"""生产任务名称模板占位符:正向替换 / 反向还原。"""
LAB_STORAGE_CODE_PLACEHOLDER = "{lab_storage_code}"
def apply_task_name_placeholders(template: str, *, lab_storage_code: str) -> str:
text = template if template is not None else ""
code = (lab_storage_code or "").strip()
return text.replace(LAB_STORAGE_CODE_PLACEHOLDER, code)
def revert_task_name_placeholders(task_name: str, *, lab_storage_code: str) -> str:
text = task_name if task_name is not None else ""
code = (lab_storage_code or "").strip()
if not code:
return text
return text.replace(code, LAB_STORAGE_CODE_PLACEHOLDER)