Skip to content

Commit

Permalink
Implement match case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmymathews committed Jul 28, 2023
1 parent 128089f commit fb1bf7f
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions spatialprofilingtoolbox/db/feature_matrix_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,24 @@ def extract(self,
continuous_also: bool=False,
):
extraction = None
if self.db_source == DBSource.CURSOR:
extraction = self._extract(
specimen=specimen,
study=study,
continuous_also=continuous_also,
)
if self.db_source == DBSource.CONFIG_FILE:
with DatabaseConnectionMaker(self.database_config_file) as dcm:
with dcm.get_connection().cursor() as cursor:
self.cursor = cursor
extraction = self._extract(
specimen=specimen,
study=study,
continuous_also=continuous_also,
)
if self.db_source == DBSource.UNKNOWN:
logger.error('The database source can not be determined.')
match self.db_source:
case DBSource.CURSOR:
extraction = self._extract(
specimen=specimen,
study=study,
continuous_also=continuous_also,
)
case DBSource.CONFIG_FILE:
with DatabaseConnectionMaker(self.database_config_file) as dcm:
with dcm.get_connection().cursor() as cursor:
self.cursor = cursor
extraction = self._extract(
specimen=specimen,
study=study,
continuous_also=continuous_also,
)
case DBSource.UNKNOWN:
logger.error('The database source can not be determined.')
return extraction

def _extract(self,
Expand Down

0 comments on commit fb1bf7f

Please sign in to comment.