From aca0fb812c1566b436a4d8c8904a60f142444e8b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 30 Dec 2012 11:41:25 -0500 Subject: [PATCH] swc-installation-test-2.py: Cache check errors Avoid running the same check (e.g. 'python') over and over. --- swc-installation-test-2.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/swc-installation-test-2.py b/swc-installation-test-2.py index 34daeec..f307e8a 100755 --- a/swc-installation-test-2.py +++ b/swc-installation-test-2.py @@ -118,6 +118,7 @@ class Dependency (object): if not or_dependencies: or_dependencies = [] self.or_dependencies = or_dependencies + self._check_error = None def __str__(self): return '<{0} {1}>'.format(type(self).__name__, self.name) @@ -129,8 +130,14 @@ class Dependency (object): return '{0} ({1})'.format(self.long_name, self.name) def check(self): - self._check_dependencies() - self._check() + if self._check_error: + raise self._check_error + try: + self._check_dependencies() + self._check() + except DependencyError as e: + self._check_error = e # cache for future calls + raise def _check_dependencies(self): for dependency in self.and_dependencies: -- 2.26.2