From 8a01a2b87b7f1d2739af0535dd770aac73e43404 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Tue, 23 Jan 2024 13:51:47 -0800 Subject: [PATCH 1/3] is_compatible --- modelscan/modelscan.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modelscan/modelscan.py b/modelscan/modelscan.py index 9100784..d39f98f 100644 --- a/modelscan/modelscan.py +++ b/modelscan/modelscan.py @@ -174,6 +174,20 @@ def _generate_results(self) -> Dict[str, Any]: return report + def is_compatible(self, path: str) -> bool: + # Determines whether a single file path is compatible with any of the available scanners + compatible: bool = False + + for scanner_path, scanner_settings in self._settings["scanners"].items(): + if ( + "supported_extensions" in scanner_settings.keys() + and Path(path).suffix + in self._settings["scanners"][scanner_path]["supported_extensions"] + ): + compatible = True + + return compatible + @property def issues(self) -> Issues: return self._issues From 3b95079b8149ad966bd9733e6b37cbb07e368a15 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Tue, 23 Jan 2024 14:09:52 -0800 Subject: [PATCH 2/3] zipfile --- modelscan/modelscan.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modelscan/modelscan.py b/modelscan/modelscan.py index d39f98f..df7e1ea 100644 --- a/modelscan/modelscan.py +++ b/modelscan/modelscan.py @@ -175,16 +175,18 @@ def _generate_results(self) -> Dict[str, Any]: return report def is_compatible(self, path: str) -> bool: - # Determines whether a single file path is compatible with any of the available scanners + # Determines whether a file path is compatible with any of the available scanners compatible: bool = False + if Path(path).suffix in self._settings["supported_zip_extensions"]: + return True for scanner_path, scanner_settings in self._settings["scanners"].items(): if ( "supported_extensions" in scanner_settings.keys() and Path(path).suffix in self._settings["scanners"][scanner_path]["supported_extensions"] ): - compatible = True + return True return compatible From 2c556089b63e50ad5bf0226f3763121ebf9fd0f5 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Tue, 23 Jan 2024 14:12:39 -0800 Subject: [PATCH 3/3] return False --- modelscan/modelscan.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modelscan/modelscan.py b/modelscan/modelscan.py index df7e1ea..66312b9 100644 --- a/modelscan/modelscan.py +++ b/modelscan/modelscan.py @@ -176,8 +176,6 @@ def _generate_results(self) -> Dict[str, Any]: def is_compatible(self, path: str) -> bool: # Determines whether a file path is compatible with any of the available scanners - compatible: bool = False - if Path(path).suffix in self._settings["supported_zip_extensions"]: return True for scanner_path, scanner_settings in self._settings["scanners"].items(): @@ -188,7 +186,7 @@ def is_compatible(self, path: str) -> bool: ): return True - return compatible + return False @property def issues(self) -> Issues: