Skip to content

Commit

Permalink
Move version check to AugiasProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
yngwi committed Sep 26, 2024
1 parent e029d24 commit 4226b78
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
17 changes: 2 additions & 15 deletions modules/processors/augias_9_2_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,11 @@

@final
class Augias92Processor(AugiasProcessor):
@override
def _proceed(self) -> bool:
table = self._get_table(self.key_map.version_table_name)
if table is None or table.empty:
return False
version_column = table[self.key_map.version_col_name]
if version_column.empty:
return False
if version_column.isin([920]).any():
version = version_column.iloc[-1].item()
log.info("Augias 9.2 file detected")
log.debug(f"Augias file version: {version}")
return True
return False

@override
def _get_key_map(self) -> KeyMap:
return KeyMap(
valid_versions=[920],
correct_version_message="Augias 9.2 file detected",
version_table_name="Version",
version_col_name="Version",
parish_table_name="M_Bestaende",
Expand Down
18 changes: 18 additions & 0 deletions modules/processors/augias_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def dict(self) -> dict[str, str]:

@dataclass
class KeyMap:
valid_versions: list[int]
correct_version_message: str
version_table_name: str
version_col_name: str
parish_table_name: str
Expand All @@ -86,6 +88,22 @@ def __init__(self, input_file: str, diocese_id: str):
def _get_key_map(self) -> KeyMap:
raise NotImplementedError("Subclasses must implement this method")

@final
@override
def _proceed(self) -> bool:
table = self._get_table(self.key_map.version_table_name)
if table is None or table.empty:
return False
version_column = table[self.key_map.version_col_name]
if version_column.empty:
return False
if version_column.isin(self.key_map.valid_versions).any():
version = version_column.iloc[-1].item()
log.info(self.key_map.correct_version_message)
log.debug(f"Augias db version: {version}")
return True
return False

@final
@override
def _extract_data(self) -> None | MatriculaData:
Expand Down
17 changes: 2 additions & 15 deletions modules/processors/augias_x_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,11 @@

@final
class AugiasXProcessor(AugiasProcessor):
@override
def _proceed(self) -> bool:
table = self._get_table(self.key_map.version_table_name)
if table is None or table.empty:
return False
version_column = table[self.key_map.version_col_name]
if version_column.empty:
return False
if version_column.isin([10004]).any():
version = version_column.iloc[-1].item()
log.info("Augias X file detected")
log.debug(f"Augias database version: {version}")
return True
return False

@override
def _get_key_map(self) -> KeyMap:
return KeyMap(
valid_versions=[10004],
correct_version_message="Augias X file detected",
version_table_name="DB_VERSION",
version_col_name="VERSION",
parish_table_name="M_BESTAENDE",
Expand Down

0 comments on commit 4226b78

Please sign in to comment.