From a647a2bd2ee30cd116a21154ed9413a18b3e73b8 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Tue, 23 Jan 2024 17:48:21 -0800 Subject: [PATCH] Add is_compatible API (#91) --- modelscan/modelscan.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modelscan/modelscan.py b/modelscan/modelscan.py index 9100784..66312b9 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 file path is compatible with any of the available scanners + 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"] + ): + return True + + return False + @property def issues(self) -> Issues: return self._issues