aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <brian.dolbec@gmail.com>2011-02-23 17:21:19 -0800
committerBrian Dolbec <brian.dolbec@gmail.com>2011-02-23 17:44:39 -0800
commite4e20b423a6ed12e939ae32eac75bf4823fe265d (patch)
treefc6f2d150f523ca43f2c55e16de2a743c2ee1417
parentcode the rebuild keywords module. (diff)
downloadgentoolkit-e4e20b423a6ed12e939ae32eac75bf4823fe265d.tar.gz
gentoolkit-e4e20b423a6ed12e939ae32eac75bf4823fe265d.tar.bz2
gentoolkit-e4e20b423a6ed12e939ae32eac75bf4823fe265d.zip
fix the rebuild_keywords slot appended bug.
re-factor rebuild_use to do the same slotted packages entries. fix some errors where I edited rebuild_use instead of rebuild_keywords print statements.
-rw-r--r--pym/gentoolkit/analyse/output.py28
-rw-r--r--pym/gentoolkit/analyse/rebuild.py37
2 files changed, 41 insertions, 24 deletions
diff --git a/pym/gentoolkit/analyse/output.py b/pym/gentoolkit/analyse/output.py
index a67e8c6..b193d54 100644
--- a/pym/gentoolkit/analyse/output.py
+++ b/pym/gentoolkit/analyse/output.py
@@ -216,9 +216,9 @@ class RebuildPrinter(CpvValueWrapper):
self.lines = [self.header()]
- def __call__(self, key, values):
- if self.target in ["keywords"]:
- self._format_atoms(key, values)
+ def __call__(self, key, values, cp_count):
+ if self.target in ["keywords", "use"]:
+ self._format_atoms(key, values, cp_count)
else:
self._format_key(key, values)
@@ -236,9 +236,11 @@ class RebuildPrinter(CpvValueWrapper):
self.data[_key] = values
self.print_fn( _key, values)
- def print_use(self, key, values):
+ def print_use(self, key, atom=None, values=None):
"""Prints a USE flag string.
"""
+ if atom and not values:
+ values = atom.use
if self.pretend:
flags = []
for flag in values:
@@ -248,31 +250,31 @@ class RebuildPrinter(CpvValueWrapper):
line = ' '.join([key, ' '.join(values)])
self.lines.append(line)
- def _format_atoms(self, key, atoms):
+ def _format_atoms(self, key, atoms, count):
"""Determines if there are more than one atom in the values and
calls the predetermined print function for each atom.
"""
#print("_format_atoms(),", key, atoms)
if self.exact:
for atom in atoms:
- self.print_fn(str(atom), atom.keyword)
+ self.print_fn(str(atom), atom=atom)
return
- many = False
- if len(atoms) >1:
- many = True
- if self.slot or many:
+ #print("_format_atoms(), count =", count)
+ if self.slot or count > 1:
for atom in atoms:
_key = str(atom.cp) + ":" + atom.slot
- self.print_fn(_key, atom.keyword)
+ self.print_fn(_key, atom=atom)
else:
for atom in atoms:
_key = str(atom.cp)
- self.print_fn(_key, atom.keyword)
+ self.print_fn(_key, atom=atom)
return
- def print_keyword(self, key, keyword):
+ def print_keyword(self, key, atom=None, keyword=None):
"""prints a pkg key and a keyword"""
#print("print_keyword(),", key, keyword)
+ if atom and not keyword:
+ keyword = atom.keyword
if self.pretend:
print(self._format_values(key, keyword))
else:
diff --git a/pym/gentoolkit/analyse/rebuild.py b/pym/gentoolkit/analyse/rebuild.py
index 0c1ce6e..091df3a 100644
--- a/pym/gentoolkit/analyse/rebuild.py
+++ b/pym/gentoolkit/analyse/rebuild.py
@@ -58,6 +58,7 @@ def cpv_all_diff_use(
cpvs = VARDB.cpv_all()
cpvs.sort()
data = {}
+ cp_counts = {}
# pass them in to override for tests
flags = FlagAnalyzer(system_flags,
filter_defaults=True,
@@ -67,11 +68,19 @@ def cpv_all_diff_use(
)
for cpv in cpvs:
plus, minus, unset = flags.analyse_cpv(cpv)
+ atom = Atom("="+cpv)
+ atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0]
for flag in minus:
plus.add("-"+flag)
if len(plus):
- data[cpv] = list(plus)
- return data
+ if atom.cp not in data:
+ data[atom.cp] = []
+ if atom.cp not in cp_counts:
+ cp_counts[atom.cp] = 0
+ atom.use = list(plus)
+ data[atom.cp].append(atom)
+ cp_counts[atom.cp] += 1
+ return data, cp_counts
def cpv_all_diff_keywords(
@@ -97,6 +106,7 @@ def cpv_all_diff_keywords(
if cpvs is None:
cpvs = VARDB.cpv_all()
keyword_users = {}
+ cp_counts = {}
for cpv in cpvs:
if cpv.startswith("virtual"):
continue
@@ -111,16 +121,20 @@ def cpv_all_diff_keywords(
atom = Atom("="+cpv)
if atom.cp not in keyword_users:
keyword_users[atom.cp] = []
+ if atom.cp not in cp_counts:
+ cp_counts[atom.cp] = 0
if key in ["~"]:
atom.keyword = keyword
atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0]
keyword_users[atom.cp].append(atom)
+ cp_counts[atom.cp] += 1
elif key in ["-"]:
#print "adding cpv to missing:", cpv
atom.keyword = "**"
atom.slot = VARDB.aux_get(atom.cpv, ["SLOT"])[0]
keyword_users[atom.cp].append(atom)
- return keyword_users
+ cp_counts[atom.cp] += 1
+ return keyword_users, cp_counts
class Rebuild(ModuleBase):
@@ -213,8 +227,9 @@ class Rebuild(ModuleBase):
print(" do not match the default settings")
system_use = portage.settings["USE"].split()
output = RebuildPrinter(
- "use", self.options["pretend"], self.options["exact"])
- pkgs = cpv_all_diff_use(system_flags=system_use)
+ "use", self.options["pretend"], self.options["exact"],
+ self.options['slot'])
+ pkgs, cp_counts = cpv_all_diff_use(system_flags=system_use)
pkg_count = len(pkgs)
if self.options["verbose"]:
print()
@@ -227,15 +242,15 @@ class Rebuild(ModuleBase):
if self.options["pretend"] and not self.options["quiet"]:
print()
print(pp.globaloption(
- " -- These are the installed packages & keywords " +
+ " -- These are the installed packages & use flags " +
"that were detected"))
- print(pp.globaloption(" to need keyword settings other " +
+ print(pp.globaloption(" to need use flag settings other " +
"than the defaults."))
print()
elif not self.options["quiet"]:
print(" -- preparing pkgs for file entries")
for pkg in pkg_keys:
- output(pkg, pkgs[pkg])
+ output(pkg, pkgs[pkg], cp_counts[pkg])
if self.options['verbose']:
message = (pp.emph(" ") +
pp.number(str(pkg_count)) +
@@ -248,7 +263,7 @@ class Rebuild(ModuleBase):
#unique.sort()
#print unique
if not self.options["pretend"]:
- filepath = os.path.expanduser('~/package.keywords.test')
+ filepath = os.path.expanduser('~/package.use.test')
self.save_file(filepath, output.lines)
def rebuild_keywords(self):
@@ -282,7 +297,7 @@ class Rebuild(ModuleBase):
cpvs = VARDB.cpv_all()
#print "Total number of installed ebuilds =", len(cpvs)
- pkgs = cpv_all_diff_keywords(
+ pkgs, cp_counts = cpv_all_diff_keywords(
cpvs=cpvs,
system_keywords=system_keywords,
use_portage=self.options['portage'],
@@ -303,7 +318,7 @@ class Rebuild(ModuleBase):
elif not self.options["quiet"]:
print(" -- preparing pkgs for file entries")
for pkg in pkg_keys:
- output(pkg, pkgs[pkg])
+ output(pkg, pkgs[pkg], cp_counts[pkg])
if not self.options['quiet']:
if self.analyser.mismatched:
print("_________________________________________________")