Download apps/contracts/services/folder/contract_subdir_path_resolver.py from jun2024/fc: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/contracts/services/folder/contract_subdir_path_resolver.py
- Command line
-
hf download hf://spaces/jun2024/fc/apps/contracts/services/folder/contract_subdir_path_resolver.py
-
curl -L -o contract_subdir_path_resolver.py https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/contracts/services/folder/contract_subdir_path_resolver.py
1.46 kB
| """Business logic services.""" | |
| from __future__ import annotations | |
| import logging | |
| from dataclasses import dataclass | |
| from typing import ClassVar | |
| from apps.core.filesystem.folder_node_path import normalize_folder_node_path | |
| from apps.core.protocols import IDocumentTemplateBindingService | |
| logger = logging.getLogger("apps.contracts") | |
| class ContractSubdirPathResolver: | |
| template_binding_service: IDocumentTemplateBindingService | None | |
| SUBDIR_KEY_TO_CONTRACT_SUB_TYPE: ClassVar = { | |
| "contract_documents": "contract", | |
| "supplementary_agreements": "supplementary_agreement", | |
| } | |
| def resolve(self, *, case_type: str, subdir_key: str) -> str | None: | |
| contract_sub_type = self.SUBDIR_KEY_TO_CONTRACT_SUB_TYPE.get(subdir_key) | |
| if not contract_sub_type: | |
| return None | |
| if self.template_binding_service is None: | |
| return None | |
| try: | |
| folder_node_path = self.template_binding_service.get_contract_subdir_path_internal( | |
| case_type=case_type, | |
| contract_sub_type=contract_sub_type, | |
| ) | |
| if not folder_node_path: | |
| return None | |
| return normalize_folder_node_path(folder_node_path) | |
| except Exception: | |
| logger.exception( | |
| "resolve_contract_subdir_path_failed", extra={"case_type": case_type, "subdir_key": subdir_key} | |
| ) | |
| raise | |