1 |
commit: e4e20b423a6ed12e939ae32eac75bf4823fe265d |
2 |
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Feb 24 01:21:19 2011 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Thu Feb 24 01:44:39 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=e4e20b42 |
7 |
|
8 |
fix the rebuild_keywords slot appended bug. |
9 |
re-factor rebuild_use to do the same slotted packages entries. |
10 |
fix some errors where I edited rebuild_use instead of rebuild_keywords print statements. |
11 |
|
12 |
--- |
13 |
pym/gentoolkit/analyse/output.py | 28 +++++++++++++++------------- |
14 |
pym/gentoolkit/analyse/rebuild.py | 37 ++++++++++++++++++++++++++----------- |
15 |
2 files changed, 41 insertions(+), 24 deletions(-) |
16 |
|
17 |
diff --git a/pym/gentoolkit/analyse/output.py b/pym/gentoolkit/analyse/output.py |
18 |
index a67e8c6..b193d54 100644 |
19 |
--- a/pym/gentoolkit/analyse/output.py |
20 |
+++ b/pym/gentoolkit/analyse/output.py |
21 |
@@ -216,9 +216,9 @@ class RebuildPrinter(CpvValueWrapper): |
22 |
self.lines = [self.header()] |
23 |
|
24 |
|
25 |
- def __call__(self, key, values): |
26 |
- if self.target in ["keywords"]: |
27 |
- self._format_atoms(key, values) |
28 |
+ def __call__(self, key, values, cp_count): |
29 |
+ if self.target in ["keywords", "use"]: |
30 |
+ self._format_atoms(key, values, cp_count) |
31 |
else: |
32 |
self._format_key(key, values) |
33 |
|
34 |
@@ -236,9 +236,11 @@ class RebuildPrinter(CpvValueWrapper): |
35 |
self.data[_key] = values |
36 |
self.print_fn( _key, values) |
37 |
|
38 |
- def print_use(self, key, values): |
39 |
+ def print_use(self, key, atom=None, values=None): |
40 |
"""Prints a USE flag string. |
41 |
""" |
42 |
+ if atom and not values: |
43 |
+ values = atom.use |
44 |
if self.pretend: |
45 |
flags = [] |
46 |
for flag in values: |
47 |
@@ -248,31 +250,31 @@ class RebuildPrinter(CpvValueWrapper): |
48 |
line = ' '.join([key, ' '.join(values)]) |
49 |
self.lines.append(line) |
50 |
|
51 |
- def _format_atoms(self, key, atoms): |
52 |
+ def _format_atoms(self, key, atoms, count): |
53 |
"""Determines if there are more than one atom in the values and |
54 |
calls the predetermined print function for each atom. |
55 |
""" |
56 |
#print("_format_atoms(),", key, atoms) |
57 |
if self.exact: |
58 |
for atom in atoms: |
59 |
- self.print_fn(str(atom), atom.keyword) |
60 |
+ self.print_fn(str(atom), atom=atom) |
61 |
return |
62 |
- many = False |
63 |
- if len(atoms) >1: |
64 |
- many = True |
65 |
- if self.slot or many: |
66 |
+ #print("_format_atoms(), count =", count) |
67 |
+ if self.slot or count > 1: |
68 |
for atom in atoms: |
69 |
_key = str(atom.cp) + ":" + atom.slot |
70 |
- self.print_fn(_key, atom.keyword) |
71 |
+ self.print_fn(_key, atom=atom) |
72 |
else: |
73 |
for atom in atoms: |
74 |
_key = str(atom.cp) |
75 |
- self.print_fn(_key, atom.keyword) |
76 |
+ self.print_fn(_key, atom=atom) |
77 |
return |
78 |
|
79 |
- def print_keyword(self, key, keyword): |
80 |
+ def print_keyword(self, key, atom=None, keyword=None): |
81 |
"""prints a pkg key and a keyword""" |
82 |
#print("print_keyword(),", key, keyword) |
83 |
+ if atom and not keyword: |
84 |
+ keyword = atom.keyword |
85 |
if self.pretend: |
86 |
print(self._format_values(key, keyword)) |
87 |
else: |
88 |
|
89 |
diff --git a/pym/gentoolkit/analyse/rebuild.py b/pym/gentoolkit/analyse/rebuild.py |
90 |
index 0c1ce6e..091df3a 100644 |
91 |
--- a/pym/gentoolkit/analyse/rebuild.py |
92 |
+++ b/pym/gentoolkit/analyse/rebuild.py |
93 |
@@ -58,6 +58,7 @@ def cpv_all_diff_use( |
94 |
cpvs = VARDB.cpv_all() |
95 |
cpvs.sort() |
96 |
data = {} |
97 |
+ cp_counts = {} |
98 |
# pass them in to override for tests |
99 |
flags = FlagAnalyzer(system_flags, |
100 |
filter_defaults=True, |
101 |
@@ -67,11 +68,19 @@ def cpv_all_diff_use( |
102 |
) |
103 |
for cpv in cpvs: |
104 |
plus, minus, unset = flags.analyse_cpv(cpv) |
105 |
+ atom = Atom("="+cpv) |
106 |
+ atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0] |
107 |
for flag in minus: |
108 |
plus.add("-"+flag) |
109 |
if len(plus): |
110 |
- data[cpv] = list(plus) |
111 |
- return data |
112 |
+ if atom.cp not in data: |
113 |
+ data[atom.cp] = [] |
114 |
+ if atom.cp not in cp_counts: |
115 |
+ cp_counts[atom.cp] = 0 |
116 |
+ atom.use = list(plus) |
117 |
+ data[atom.cp].append(atom) |
118 |
+ cp_counts[atom.cp] += 1 |
119 |
+ return data, cp_counts |
120 |
|
121 |
|
122 |
def cpv_all_diff_keywords( |
123 |
@@ -97,6 +106,7 @@ def cpv_all_diff_keywords( |
124 |
if cpvs is None: |
125 |
cpvs = VARDB.cpv_all() |
126 |
keyword_users = {} |
127 |
+ cp_counts = {} |
128 |
for cpv in cpvs: |
129 |
if cpv.startswith("virtual"): |
130 |
continue |
131 |
@@ -111,16 +121,20 @@ def cpv_all_diff_keywords( |
132 |
atom = Atom("="+cpv) |
133 |
if atom.cp not in keyword_users: |
134 |
keyword_users[atom.cp] = [] |
135 |
+ if atom.cp not in cp_counts: |
136 |
+ cp_counts[atom.cp] = 0 |
137 |
if key in ["~"]: |
138 |
atom.keyword = keyword |
139 |
atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0] |
140 |
keyword_users[atom.cp].append(atom) |
141 |
+ cp_counts[atom.cp] += 1 |
142 |
elif key in ["-"]: |
143 |
#print "adding cpv to missing:", cpv |
144 |
atom.keyword = "**" |
145 |
atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0] |
146 |
keyword_users[atom.cp].append(atom) |
147 |
- return keyword_users |
148 |
+ cp_counts[atom.cp] += 1 |
149 |
+ return keyword_users, cp_counts |
150 |
|
151 |
|
152 |
class Rebuild(ModuleBase): |
153 |
@@ -213,8 +227,9 @@ class Rebuild(ModuleBase): |
154 |
print(" do not match the default settings") |
155 |
system_use = portage.settings["USE"].split() |
156 |
output = RebuildPrinter( |
157 |
- "use", self.options["pretend"], self.options["exact"]) |
158 |
- pkgs = cpv_all_diff_use(system_flags=system_use) |
159 |
+ "use", self.options["pretend"], self.options["exact"], |
160 |
+ self.options['slot']) |
161 |
+ pkgs, cp_counts = cpv_all_diff_use(system_flags=system_use) |
162 |
pkg_count = len(pkgs) |
163 |
if self.options["verbose"]: |
164 |
print() |
165 |
@@ -227,15 +242,15 @@ class Rebuild(ModuleBase): |
166 |
if self.options["pretend"] and not self.options["quiet"]: |
167 |
print() |
168 |
print(pp.globaloption( |
169 |
- " -- These are the installed packages & keywords " + |
170 |
+ " -- These are the installed packages & use flags " + |
171 |
"that were detected")) |
172 |
- print(pp.globaloption(" to need keyword settings other " + |
173 |
+ print(pp.globaloption(" to need use flag settings other " + |
174 |
"than the defaults.")) |
175 |
print() |
176 |
elif not self.options["quiet"]: |
177 |
print(" -- preparing pkgs for file entries") |
178 |
for pkg in pkg_keys: |
179 |
- output(pkg, pkgs[pkg]) |
180 |
+ output(pkg, pkgs[pkg], cp_counts[pkg]) |
181 |
if self.options['verbose']: |
182 |
message = (pp.emph(" ") + |
183 |
pp.number(str(pkg_count)) + |
184 |
@@ -248,7 +263,7 @@ class Rebuild(ModuleBase): |
185 |
#unique.sort() |
186 |
#print unique |
187 |
if not self.options["pretend"]: |
188 |
- filepath = os.path.expanduser('~/package.keywords.test') |
189 |
+ filepath = os.path.expanduser('~/package.use.test') |
190 |
self.save_file(filepath, output.lines) |
191 |
|
192 |
def rebuild_keywords(self): |
193 |
@@ -282,7 +297,7 @@ class Rebuild(ModuleBase): |
194 |
|
195 |
cpvs = VARDB.cpv_all() |
196 |
#print "Total number of installed ebuilds =", len(cpvs) |
197 |
- pkgs = cpv_all_diff_keywords( |
198 |
+ pkgs, cp_counts = cpv_all_diff_keywords( |
199 |
cpvs=cpvs, |
200 |
system_keywords=system_keywords, |
201 |
use_portage=self.options['portage'], |
202 |
@@ -303,7 +318,7 @@ class Rebuild(ModuleBase): |
203 |
elif not self.options["quiet"]: |
204 |
print(" -- preparing pkgs for file entries") |
205 |
for pkg in pkg_keys: |
206 |
- output(pkg, pkgs[pkg]) |
207 |
+ output(pkg, pkgs[pkg], cp_counts[pkg]) |
208 |
if not self.options['quiet']: |
209 |
if self.analyser.mismatched: |
210 |
print("_________________________________________________") |