Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/repository/
Date: Sat, 29 Oct 2011 06:15:39
Message-Id: 486b6ebd44bec7b12f6c4ab36c85b5c270fc3883.zmedico@gentoo
1 commit: 486b6ebd44bec7b12f6c4ab36c85b5c270fc3883
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 29 06:15:21 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 29 06:15:21 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=486b6ebd
7
8 RepoConfig: add iter_pregenerated_caches method
9
10 This will be used by egencache to generate cache for all supported
11 formats.
12
13 ---
14 pym/portage/repository/config.py | 32 ++++++++++++++++++++------------
15 1 files changed, 20 insertions(+), 12 deletions(-)
16
17 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
18 index 06a4d94..ed0f64d 100644
19 --- a/pym/portage/repository/config.py
20 +++ b/pym/portage/repository/config.py
21 @@ -124,32 +124,40 @@ class RepoConfig(object):
22 self.portage1_profiles = True
23 self.portage1_profiles_compat = False
24
25 - def get_pregenerated_cache(self, auxdbkeys, readonly=True, force=False):
26 + def iter_pregenerated_caches(self, auxdbkeys, readonly=True, force=False):
27 """
28 - Reads layout.conf cache-formats from left to right and returns a
29 - cache instance for the first supported type that's found. If no
30 - cache-formats are specified in layout.conf, 'pms' type is assumed
31 - if the metadata/cache directory exists or force is True.
32 + Reads layout.conf cache-formats from left to right and yields cache
33 + instances for each supported type that's found. If no cache-formats
34 + are specified in layout.conf, 'pms' type is assumed if the
35 + metadata/cache directory exists or force is True.
36 """
37 formats = self.cache_formats
38 if not formats:
39 if not force:
40 - return None
41 + return
42 formats = ('pms',)
43
44 for fmt in formats:
45 + name = None
46 if fmt == 'pms':
47 from portage.cache.metadata import database
48 name = 'metadata/cache'
49 - break
50 elif fmt == 'md5-dict':
51 from portage.cache.flat_hash import md5_database as database
52 name = 'metadata/md5-cache'
53 - break
54 - else:
55 - return None
56 - return database(self.location, name,
57 - auxdbkeys, readonly=readonly)
58 +
59 + if name is not None:
60 + yield database(self.location, name,
61 + auxdbkeys, readonly=readonly)
62 +
63 + def get_pregenerated_cache(self, auxdbkeys, readonly=True, force=False):
64 + """
65 + Returns the first cache instance yielded from
66 + iter_pregenerated_caches(), or None if no cache is available or none
67 + of the available formats are supported.
68 + """
69 + return next(self.iter_pregenerated_caches(
70 + auxdbkeys, readonly=readonly, force=force), None)
71
72 def load_manifest(self, *args, **kwds):
73 kwds['thin'] = self.thin_manifest