summaryrefslogtreecommitdiffstats
path: root/pym/portage/repository/config.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-10-28 23:15:21 -0700
committerZac Medico <zmedico@gentoo.org>2011-10-28 23:15:21 -0700
commit486b6ebd44bec7b12f6c4ab36c85b5c270fc3883 (patch)
tree25df8a6774812db9991bbb6865f1e3c31a7eddb5 /pym/portage/repository/config.py
parent290990af18d2c56c26bb4b33f24e641948879522 (diff)
downloadportage-486b6ebd44bec7b12f6c4ab36c85b5c270fc3883.tar.gz
portage-486b6ebd44bec7b12f6c4ab36c85b5c270fc3883.tar.bz2
portage-486b6ebd44bec7b12f6c4ab36c85b5c270fc3883.zip
RepoConfig: add iter_pregenerated_caches method
This will be used by egencache to generate cache for all supported formats.
Diffstat (limited to 'pym/portage/repository/config.py')
-rw-r--r--pym/portage/repository/config.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 06a4d94aa..ed0f64dde 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -124,32 +124,40 @@ class RepoConfig(object):
self.portage1_profiles = True
self.portage1_profiles_compat = False
- def get_pregenerated_cache(self, auxdbkeys, readonly=True, force=False):
+ def iter_pregenerated_caches(self, auxdbkeys, readonly=True, force=False):
"""
- Reads layout.conf cache-formats from left to right and returns a
- cache instance for the first supported type that's found. If no
- cache-formats are specified in layout.conf, 'pms' type is assumed
- if the metadata/cache directory exists or force is True.
+ Reads layout.conf cache-formats from left to right and yields cache
+ instances for each supported type that's found. If no cache-formats
+ are specified in layout.conf, 'pms' type is assumed if the
+ metadata/cache directory exists or force is True.
"""
formats = self.cache_formats
if not formats:
if not force:
- return None
+ return
formats = ('pms',)
for fmt in formats:
+ name = None
if fmt == 'pms':
from portage.cache.metadata import database
name = 'metadata/cache'
- break
elif fmt == 'md5-dict':
from portage.cache.flat_hash import md5_database as database
name = 'metadata/md5-cache'
- break
- else:
- return None
- return database(self.location, name,
- auxdbkeys, readonly=readonly)
+
+ if name is not None:
+ yield database(self.location, name,
+ auxdbkeys, readonly=readonly)
+
+ def get_pregenerated_cache(self, auxdbkeys, readonly=True, force=False):
+ """
+ Returns the first cache instance yielded from
+ iter_pregenerated_caches(), or None if no cache is available or none
+ of the available formats are supported.
+ """
+ return next(self.iter_pregenerated_caches(
+ auxdbkeys, readonly=readonly, force=force), None)
def load_manifest(self, *args, **kwds):
kwds['thin'] = self.thin_manifest