Skip to content

Commit

Permalink
Hotfix module loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dbtdsilva committed Mar 13, 2024
1 parent 21deadd commit 671bd63
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/services/transaction_import_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ def __find_account_matching_file(self, file: str) -> Tuple[Account, ModuleType]:
return (match[1], self.__retrieve_module(match[2])) if match is not None else (None, None)

def __retrieve_module(self, module) -> Parser:
logging.info(f'Loading module with the name: {module}')
try:
loaded_module = importlib.import_module(f'.parsers.{module}', __package__)
loaded_module = importlib.import_module(f'.parsers.{module}', 'src')
for _, obj in vars(loaded_module).items():
if isinstance(obj, type) and issubclass(obj, Parser) and obj != Parser:
return obj
logging.info(f'Module ({module}) was not found with class Parser: {vars(loaded_module).items()}')
return None
except ModuleNotFoundError:
except ModuleNotFoundError as e:
logging.info(f'Module ({module}) was not found: {e}')
return None

def __map_transaction_to_firefly(self, parsed_transaction: ParsedTransaction, account: Account, tag: Tag) -> Transaction:
Expand Down

0 comments on commit 671bd63

Please sign in to comment.