mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Select the Calico parser and mapper by file type 🟩
Registers ConditionFileType.Calico in the parser/mapper factory; the Calico parser requires a UPRN lookup (like Peabody) since references resolve to UPRNs via the property table. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a6b782d5b3
commit
188176d81e
1 changed files with 12 additions and 0 deletions
|
|
@ -1,10 +1,12 @@
|
|||
from typing import Optional
|
||||
from applications.condition.condition_trigger_request import ConditionFileType
|
||||
from domain.condition.mapping.calico.calico_mapper import CalicoMapper
|
||||
from domain.condition.mapping.lbwf.lbwf_mapper import LbwfMapper
|
||||
from domain.condition.mapping.mapper import Mapper
|
||||
from domain.condition.mapping.peabody.peabody_mapper import PeabodyMapper
|
||||
from repositories.condition.uprn_lookup import UprnLookup
|
||||
from infrastructure.condition.parsing.parser import Parser
|
||||
from infrastructure.condition.parsing.calico_parser import CalicoParser
|
||||
from infrastructure.condition.parsing.lbwf_parser import LbwfParser
|
||||
from infrastructure.condition.parsing.peabody_parser import PeabodyParser
|
||||
|
||||
|
|
@ -22,6 +24,13 @@ def select_parser(
|
|||
)
|
||||
return PeabodyParser(uprn_lookup=uprn_lookup)
|
||||
|
||||
if file_type is ConditionFileType.Calico:
|
||||
if not uprn_lookup:
|
||||
raise ValueError(
|
||||
"Cannot instantiate Calico Parser without UPRN lookup being provided"
|
||||
)
|
||||
return CalicoParser(uprn_lookup=uprn_lookup)
|
||||
|
||||
raise ValueError("Unrecognised file type, unable to instantiate Parser")
|
||||
|
||||
|
||||
|
|
@ -32,4 +41,7 @@ def select_mapper(file_type: ConditionFileType) -> Mapper:
|
|||
if file_type is ConditionFileType.Peabody:
|
||||
return PeabodyMapper()
|
||||
|
||||
if file_type is ConditionFileType.Calico:
|
||||
return CalicoMapper()
|
||||
|
||||
raise ValueError("Unrecognised file type, unable to instantiate Mapper")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue