From 0672c5b1bcde3b7f174d97da328ba1601bb35c0b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 25 May 2007 07:06:41 +0000 Subject: [PATCH] To ease the namespace transition, automatically translate cache.* to portage.cache.* if an ImportError occurs. svn path=/main/trunk/; revision=6620 --- pym/portage/__init__.py | 11 +++++++++-- pym/portage/dbapi/porttree.py | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index f79b525ed..191d6d070 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1557,11 +1557,18 @@ class config: def load_best_module(self,property_string): best_mod = best_from_dict(property_string,self.modules,self.module_priority) + mod = None try: mod = load_mod(best_mod) except ImportError: - dump_traceback(red("Error: Failed to import module '%s'") % best_mod, noiselevel=0) - sys.exit(1) + if best_mod.startswith("cache."): + best_mod = "portage." + best_mod + try: + mod = load_mod(best_mod) + except ImportError: + pass + if mod is None: + raise return mod def lock(self): diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index b1177a4a0..86d70416f 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -136,6 +136,9 @@ class portdbapi(dbapi): pass def close_caches(self): + if not hasattr(self, "auxdb"): + # unhandled exception thrown from constructor + return for x in self.auxdb.keys(): self.auxdb[x].sync() self.auxdb.clear() -- 2.26.2