From: W. Trevor King Date: Sun, 30 Dec 2012 18:14:37 +0000 (-0500) Subject: swc-installation-test-2.py: Refactor PythonPackageDependency._get_version X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e9c5f665d24cf7d4b9ef21ad6160f173bc341004;p=swc-setup-installation-test.git swc-installation-test-2.py: Refactor PythonPackageDependency._get_version Split it into pieces for easier subclassing. --- 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: