aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_emerge/resolver/slot_collision.py')
-rw-r--r--lib/_emerge/resolver/slot_collision.py139
1 files changed, 55 insertions, 84 deletions
diff --git a/lib/_emerge/resolver/slot_collision.py b/lib/_emerge/resolver/slot_collision.py
index 0b063b5f3..d4f7018ea 100644
--- a/lib/_emerge/resolver/slot_collision.py
+++ b/lib/_emerge/resolver/slot_collision.py
@@ -22,7 +22,7 @@ class slot_conflict_handler:
go away. This class focuses on cases where this can be achieved
with a change in USE settings.
- 1) Find out if what causes a given slot conflict. There are
+ 1) Find out what causes a given slot conflict. There are
three possibilities:
a) One parent needs foo-1:0 and another one needs foo-2:0,
@@ -36,7 +36,7 @@ class slot_conflict_handler:
enabled, this case is treated in the same way as c).
c) Neither a 'version based conflict' nor an 'unspecific
- conflict'. Ignoring use deps would result result in an
+ conflict'. Ignoring use deps would result in an
'unspecific conflict'. This is called a 'specific conflict'.
This is the only conflict we try to find suggestions for.
@@ -63,7 +63,7 @@ class slot_conflict_handler:
* The parent package is 'installed'.
* The conflict package is 'installed'.
- USE of 'installed' packages can't be changed. This always requires an
+ USE of 'installed' packages can't be changed. This always requires a
non-installed package.
During this procedure, contradictions may occur. In this case the
@@ -126,10 +126,10 @@ class slot_conflict_handler:
self._prepare_conflict_msg_and_check_for_specificity()
- # a list of dicts that hold the needed USE values to solve all conflicts
+ # a list of dicts that holds the needed USE values to solve all conflicts
self.solutions = []
- # a list of dicts that hold the needed USE changes to solve all conflicts
+ # a list of dicts that holds the needed USE changes to solve all conflicts
self.changes = []
# configuration = a list of packages with exactly one package from every
@@ -146,7 +146,7 @@ class slot_conflict_handler:
if self.debug:
writemsg("\nNew configuration:\n", noiselevel=-1)
for pkg in config:
- writemsg(" %s\n" % (pkg,), noiselevel=-1)
+ writemsg(f" {pkg}\n", noiselevel=-1)
writemsg("\n", noiselevel=-1)
new_solutions = self._check_configuration(
@@ -218,7 +218,7 @@ class slot_conflict_handler:
to_be_removed.append(change)
if not ignore:
- # Discard all existing change that are a superset of the new change.
+ # Discard all existing changes that are a superset of the new change.
for obsolete_change in to_be_removed:
changes.remove(obsolete_change)
changes.append(new_change)
@@ -228,14 +228,14 @@ class slot_conflict_handler:
new_change = {}
for pkg in solution:
for flag, state in solution[pkg].items():
- real_flag = pkg.iuse.get_real_flag(flag)
- if real_flag is None:
+ flag = pkg.iuse.get_flag(flag)
+ if flag is None:
# Triggered by use-dep defaults.
continue
if state == "enabled" and flag not in _pkg_use_enabled(pkg):
- new_change.setdefault(pkg, {})[real_flag] = True
+ new_change.setdefault(pkg, {})[flag] = True
elif state == "disabled" and flag in _pkg_use_enabled(pkg):
- new_change.setdefault(pkg, {})[real_flag] = False
+ new_change.setdefault(pkg, {})[flag] = False
return new_change
def _prepare_conflict_msg_and_check_for_specificity(self):
@@ -258,22 +258,21 @@ class slot_conflict_handler:
)
for root, slot_atom, pkgs in self.all_conflicts:
- msg.append("%s" % (slot_atom,))
+ msg.append(f"{slot_atom}")
if root != self.depgraph._frozen_config._running_root.root:
- msg.append(" for %s" % (root,))
+ msg.append(f" for {root}")
msg.append("\n\n")
for pkg in pkgs:
msg.append(indent)
msg.append(
- "%s %s"
- % (
- pkg,
+ f"{pkg} "
+ + str(
pkg_use_display(
pkg,
self.depgraph._frozen_config.myopts,
modified_use=self.depgraph._pkg_use_enabled(pkg),
- ),
+ )
)
)
parent_atoms = self.all_parents.get(pkg)
@@ -368,19 +367,12 @@ class slot_conflict_handler:
msg = (
"\n\n!!! BUG: Detected "
"USE dep match inconsistency:\n"
- "\tppkg: %s\n"
- "\tviolated_atom: %s\n"
- "\tatom: %s unevaluated: %s\n"
- "\tother_pkg: %s IUSE: %s USE: %s\n"
- % (
- ppkg,
- violated_atom,
- atom,
- atom.unevaluated_atom,
- other_pkg,
- sorted(other_pkg.iuse.all),
- sorted(_pkg_use_enabled(other_pkg)),
- )
+ f"\tppkg: {ppkg}\n"
+ f"\tviolated_atom: {violated_atom}\n"
+ f"\tatom: {atom} unevaluated: {atom.unevaluated_atom}\n"
+ f"\tother_pkg: {other_pkg} "
+ f"IUSE: {sorted(other_pkg.iuse.all)} "
+ f"USE: {sorted(_pkg_use_enabled(other_pkg))}\n"
)
writemsg(msg, noiselevel=-2)
raise AssertionError(
@@ -454,17 +446,17 @@ class slot_conflict_handler:
modified_use=self.depgraph._pkg_use_enabled(ppkg),
):
selected_for_display.add((ppkg, atom))
- need_rebuild[
- ppkg
- ] = "matched by --useoldpkg-atoms argument"
+ need_rebuild[ppkg] = (
+ "matched by --useoldpkg-atoms argument"
+ )
elif usepkgonly:
# This case is tricky, so keep quiet in order to avoid false-positives.
pass
elif not self.depgraph._equiv_ebuild_visible(ppkg):
selected_for_display.add((ppkg, atom))
- need_rebuild[
- ppkg
- ] = "ebuild is masked or unavailable"
+ need_rebuild[ppkg] = (
+ "ebuild is masked or unavailable"
+ )
for ppkg, atom, other_pkg in parents:
selected_for_display.add((ppkg, atom))
@@ -523,7 +515,7 @@ class slot_conflict_handler:
def highlight_violations(atom, version, use, slot_violated):
"""Colorize parts of an atom"""
- atom_str = "%s" % (atom,)
+ atom_str = f"{atom}"
colored_idx = set()
if version:
op = atom.operator
@@ -614,7 +606,7 @@ class slot_conflict_handler:
atom_str = (
atom_str[:use_part_start]
- + "[%s]" % (",".join(new_tokens),)
+ + f"[{','.join(new_tokens)}]"
+ atom_str[use_part_end + 1 :]
)
@@ -638,16 +630,14 @@ class slot_conflict_handler:
else:
use_display = ""
if atom.soname:
- msg.append(
- "%s required by %s %s\n" % (atom, parent, use_display)
- )
+ msg.append(f"{atom} required by {parent} {use_display}\n")
elif isinstance(parent, PackageArg):
# For PackageArg it's
# redundant to display the atom attribute.
- msg.append("%s\n" % (parent,))
+ msg.append(f"{parent}\n")
elif isinstance(parent, AtomArg):
msg.append(2 * indent)
- msg.append("%s (Argument)\n" % (atom,))
+ msg.append(f"{atom} (Argument)\n")
else:
# Display the specific atom from SetArg or
# Package types.
@@ -675,7 +665,7 @@ class slot_conflict_handler:
if version_violated or slot_violated:
self.is_a_version_conflict = True
- cur_line = "%s required by %s %s\n" % (
+ cur_line = "{} required by {} {}\n".format(
atom_str,
parent,
use_display,
@@ -705,13 +695,11 @@ class slot_conflict_handler:
msg.append(2 * indent)
if len(selected_for_display) > 1:
msg.append(
- "(and %d more with the same problems)\n"
- % omitted_parents
+ f"(and {omitted_parents} more with the same problems)\n"
)
else:
msg.append(
- "(and %d more with the same problem)\n"
- % omitted_parents
+ f"(and {omitted_parents} more with the same problem)\n"
)
else:
msg.append(" (no parents)\n")
@@ -736,7 +724,7 @@ class slot_conflict_handler:
)
msg.append("!!! package(s) cannot be rebuilt for the reason(s) shown:\n\n")
for ppkg, reason in need_rebuild.items():
- msg.append("%s%s: %s\n" % (indent, ppkg, reason))
+ msg.append(f"{indent}{ppkg}: {reason}\n")
msg.append("\n")
msg.append("\n")
@@ -784,7 +772,7 @@ class slot_conflict_handler:
indent
+ "- "
+ pkg.cpv
- + " (Change USE: %s" % " ".join(changes)
+ + f" (Change USE: {' '.join(changes)}"
+ ")\n"
)
mymsg += "\n"
@@ -803,12 +791,12 @@ class slot_conflict_handler:
self, config, all_conflict_atoms_by_slotatom, conflict_nodes
):
"""
- Given a configuartion, required use changes are computed and checked to
+ Given a configuration, required use changes are computed and checked to
make sure that no new conflict is introduced. Returns a solution or None.
"""
_pkg_use_enabled = self.depgraph._pkg_use_enabled
# An installed package can only be part of a valid configuration if it has no
- # pending use changed. Otherwise the ebuild will be pulled in again.
+ # pending use changes. Otherwise the ebuild will be pulled in again.
for pkg in config:
if not pkg.installed:
continue
@@ -826,11 +814,7 @@ class slot_conflict_handler:
):
if self.debug:
writemsg(
- (
- "%s has pending USE changes. "
- "Rejecting configuration.\n"
- )
- % (pkg,),
+ f"{pkg} has pending USE changes. Rejecting configuration.\n",
noiselevel=-1,
)
return False
@@ -859,11 +843,8 @@ class slot_conflict_handler:
# Version range does not match.
if self.debug:
writemsg(
- (
- "%s does not satify all version "
- "requirements. Rejecting configuration.\n"
- )
- % (pkg,),
+ f"{pkg} does not satify all version "
+ "requirements. Rejecting configuration.\n",
noiselevel=-1,
)
return False
@@ -873,11 +854,7 @@ class slot_conflict_handler:
# FIXME: This needs to support use dep defaults.
if self.debug:
writemsg(
- (
- "%s misses needed flags from IUSE."
- " Rejecting configuration.\n"
- )
- % (pkg,),
+ f"{pkg} misses needed flags from IUSE. Rejecting configuration.\n",
noiselevel=-1,
)
return False
@@ -908,21 +885,18 @@ class slot_conflict_handler:
violated_atom.use.enabled or violated_atom.use.disabled
):
# We can't change USE of an installed package (only of an ebuild, but that is already
- # part of the conflict, isn't it?
+ # part of the conflict, isn't it?)
if self.debug:
writemsg(
- (
- "%s: installed package would need USE"
- " changes. Rejecting configuration.\n"
- )
- % (pkg,),
+ f"{pkg}: installed package would need USE changes. "
+ "Rejecting configuration.\n",
noiselevel=-1,
)
return False
# Compute the required USE changes. A flag can be forced to "enabled" or "disabled",
# it can be in the conditional state "cond" that allows both values or in the
- # "contradiction" state, which means that some atoms insist on differnt values
+ # "contradiction" state, which means that some atoms insist on different values
# for this flag and those kill this configuration.
for flag in violated_atom.use.required:
state = involved_flags.get(flag, "")
@@ -975,7 +949,7 @@ class slot_conflict_handler:
if self.debug:
writemsg("All involved flags:\n", noiselevel=-1)
for idx, involved_flags in enumerate(all_involved_flags):
- writemsg(" %s\n" % (config[idx],), noiselevel=-1)
+ writemsg(f" {config[idx]}\n", noiselevel=-1)
for flag, state in involved_flags.items():
writemsg(" " + flag + ": " + state + "\n", noiselevel=-1)
@@ -1013,7 +987,7 @@ class slot_conflict_handler:
def _force_flag_for_package(self, required_changes, pkg, flag, state):
"""
- Adds an USE change to required_changes. Sets the target state to
+ Adds a USE change to required_changes. Sets the target state to
"contradiction" if a flag is forced to conflicting values.
"""
_pkg_use_enabled = self.depgraph._pkg_use_enabled
@@ -1043,7 +1017,7 @@ class slot_conflict_handler:
self, config, all_involved_flags, all_conflict_atoms_by_slotatom
):
"""
- Given a configuartion and all involved flags, all possible settings for the involved
+ Given a configuration and all involved flags, all possible settings for the involved
flags are checked if they solve the slot conflict.
"""
_pkg_use_enabled = self.depgraph._pkg_use_enabled
@@ -1066,7 +1040,7 @@ class slot_conflict_handler:
inner_first = False
else:
msg += ", "
- msg += flag + ": %s" % (state,)
+ msg += flag + f": {state}"
msg += "}"
msg += "]\n"
writemsg(msg, noiselevel=-1)
@@ -1187,11 +1161,8 @@ class slot_conflict_handler:
is_valid_solution = False
if self.debug:
writemsg(
- (
- "new conflict introduced: %s"
- " does not match %s from %s\n"
- )
- % (pkg, new_atom, ppkg),
+ f"new conflict introduced: {pkg} does not match "
+ f"{new_atom} from {ppkg}\n",
noiselevel=-1,
)
break
@@ -1281,7 +1252,7 @@ class _solution_candidate_generator:
return self.value == other.value
def __str__(self):
- return "%s" % (self.value,)
+ return f"{self.value}"
def __init__(self, all_involved_flags):
# A copy of all_involved_flags with all "cond" values