Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
swashko committed Jan 12, 2024
1 parent c093bc5 commit 3d554d6
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions modelscan/modelscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def __init__(
self._load_scanners()

def _load_scanners(self) -> None:
scanner_classes: Dict[str, ScanBase] = {}

for scanner_path, scanner_settings in self._settings["scanners"].items():
if (
"enabled" in scanner_settings.keys()
Expand All @@ -48,8 +46,10 @@ def _load_scanners(self) -> None:
imported_module = importlib.import_module(
name=modulename, package=classname
)
scanner_class = getattr(imported_module, classname)
scanner_classes[scanner_path] = scanner_class

scanner_class: ScanBase = getattr(imported_module, classname)
self._scanners_to_run.append(scanner_class)

except Exception as e:
logger.error(f"Error importing scanner {scanner_path}")
self._init_errors.append(
Expand All @@ -58,13 +58,6 @@ def _load_scanners(self) -> None:
)
)

scanners_to_run: List[ScanBase] = []
for scanner_class, scanner in scanner_classes.items():
is_enabled: bool = self._settings["scanners"][scanner_class]["enabled"]
if is_enabled:
scanners_to_run.append(scanner)
self._scanners_to_run = scanners_to_run

def scan(
self,
path: Union[str, Path],
Expand Down

0 comments on commit 3d554d6

Please sign in to comment.