production_task_name_placeholders.py 647 B

1234567891011121314151617
  1. """生产任务名称模板占位符:正向替换 / 反向还原。"""
  2. LAB_STORAGE_CODE_PLACEHOLDER = "{lab_storage_code}"
  3. def apply_task_name_placeholders(template: str, *, lab_storage_code: str) -> str:
  4. text = template if template is not None else ""
  5. code = (lab_storage_code or "").strip()
  6. return text.replace(LAB_STORAGE_CODE_PLACEHOLDER, code)
  7. def revert_task_name_placeholders(task_name: str, *, lab_storage_code: str) -> str:
  8. text = task_name if task_name is not None else ""
  9. code = (lab_storage_code or "").strip()
  10. if not code:
  11. return text
  12. return text.replace(code, LAB_STORAGE_CODE_PLACEHOLDER)