mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
add mapping to processor
This commit is contained in:
parent
7eb06396ef
commit
25923cbc9f
2 changed files with 18 additions and 3 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from backend.condition.domain.mapping.lbwf_mapper import LbwfMapper
|
||||
from backend.condition.domain.mapping.mapper import Mapper
|
||||
from backend.condition.file_type import FileType
|
||||
from backend.condition.parsing.parser import Parser
|
||||
from backend.condition.parsing.lbwf_parser import LbwfParser
|
||||
|
|
@ -7,3 +9,9 @@ def select_parser(file_type: FileType) -> Parser:
|
|||
return LbwfParser()
|
||||
|
||||
raise ValueError("Unrecognised file type, unable to instantiate Parser")
|
||||
|
||||
def select_mapper(file_type: FileType) -> Mapper:
|
||||
if file_type is FileType.LBWF:
|
||||
return LbwfMapper()
|
||||
|
||||
raise ValueError("Unrecognised file type, unable to instantiate Mapper")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
from typing import Any, BinaryIO, List
|
||||
|
||||
from backend.condition.domain.asset_condition import AssetCondition
|
||||
from backend.condition.domain.mapping.mapper import Mapper
|
||||
from backend.condition.parsing.parser import Parser
|
||||
from utils.logger import setup_logger
|
||||
from backend.condition.file_type import FileType, detect_file_type
|
||||
from backend.condition.parsing.factory import select_parser
|
||||
from backend.condition.parsing.factory import select_parser, select_mapper
|
||||
|
||||
def process_file(file_stream: BinaryIO, source_key: str) -> None:
|
||||
print(f"[processor] Received file: {source_key}")
|
||||
|
|
@ -11,8 +13,13 @@ def process_file(file_stream: BinaryIO, source_key: str) -> None:
|
|||
# Instantiation
|
||||
file_type: FileType = detect_file_type(source_key)
|
||||
parser: Parser = select_parser(file_type)
|
||||
mapper: Mapper = select_mapper(file_type)
|
||||
|
||||
# Orchestration
|
||||
records: List[Any] = parser.parse(file_stream)
|
||||
raw_properties: List[Any] = parser.parse(file_stream)
|
||||
|
||||
print(records) # temp
|
||||
assets: List[AssetCondition] = []
|
||||
for p in raw_properties:
|
||||
assets.extend(mapper.map_asset_conditions_for_property(p))
|
||||
|
||||
print(assets) # temp
|
||||
Loading…
Add table
Reference in a new issue