From e9c5f665d24cf7d4b9ef21ad6160f173bc341004 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 30 Dec 2012 13:14:37 -0500 Subject: [PATCH] swc-installation-test-2.py: Refactor PythonPackageDependency._get_version Split it into pieces for easier subclassing. --- swc-installation-test-2.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/swc-installation-test-2.py b/swc-installation-test-2.py index 0617550..e25712a 100755 --- a/swc-installation-test-2.py +++ b/swc-installation-test-2.py @@ -331,14 +331,20 @@ class PythonPackageDependency (Dependency): self.package = package def _get_version(self): + package = self._get_package(self.package) + return self._get_version_from_package(package) + + def _get_package(self, package): try: - package = _importlib.import_module(self.package) + return _importlib.import_module(package) except ImportError as e: raise DependencyError( checker=self, - message="could not import the '{0}' package".format( - self.package), + message="could not import the '{0}' package for {1}".format( + package, self.full_name()), )# from e + + def _get_version_from_package(self, package): try: version = package.__version__ except AttributeError: -- 2.26.2