summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to 'portato')
-rw-r--r--portato/backend/flags.py21
-rw-r--r--portato/backend/package.py4
-rw-r--r--portato/backend/portage/package.py11
-rw-r--r--portato/gui/gtk/windows.py24
4 files changed, 50 insertions, 10 deletions
diff --git a/portato/backend/flags.py b/portato/backend/flags.py
index a623973..f171356 100644
--- a/portato/backend/flags.py
+++ b/portato/backend/flags.py
@@ -192,6 +192,27 @@ def invert_use_flag (flag):
else:
return "-"+flag
+def sort_use_flag_list (flaglist):
+ """
+ Sorts a list of useflags. If a use flag starts with "+" or "-" this one is ignored for the matter of sorting.
+ This functions sorts the list itself - thus does not create a new one. But for convenience it returns the list too.
+
+ @param flaglist: the list of useflags
+ @type flaglist: string[]
+
+ @returns: the sorted list (Note: it is the same as the one passed in)
+ @rtype: string[]
+ """
+
+ def flag_key (flag):
+ if flag.startswith(("+","-")):
+ return flag[1:]
+ else:
+ return flag
+
+ flaglist.sort(key = flag_key)
+ return flaglist
+
def set_use_flag (pkg, flag):
"""Sets the useflag for a given package.
diff --git a/portato/backend/package.py b/portato/backend/package.py
index a7f41d7..4d84e90 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -268,11 +268,13 @@ class Package (_Package):
@returns: the reason for masking the package
@rtype: string"""
- def get_iuse_flags (self, installed = False):
+ def get_iuse_flags (self, installed = False, keep = False):
"""Returns a list of _all_ useflags for this package, i.e. all useflags you can set for this package.
@param installed: do not take the ones stated in the ebuild, but the ones it has been installed with
@type installed: boolean
+ @param keep: keep the "+" or "-" signs for forced flags
+ @type keep: boolean
@returns: list of use-flags
@rtype: string[]"""
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py
index e5e5603..bc157cf 100644
--- a/portato/backend/portage/package.py
+++ b/portato/backend/portage/package.py
@@ -130,13 +130,20 @@ class PortagePackage (Package):
else:
return reason
- def get_iuse_flags (self, installed = False):
+ def get_iuse_flags (self, installed = False, keep = False):
if installed or not self.is_in_system():
tree = self._settings.vartree
else:
tree = self._settings.porttree
- return list(set(self.get_package_settings("IUSE", tree = tree).split()).difference(self.forced_flags))
+ flags = self.get_package_settings("IUSE", tree = tree).split()
+
+ if not keep: # remove "+"/"-"
+ for ctr, f in enumerate(flags):
+ if f.startswith(("+","-")):
+ flags[ctr] = f[1:]
+
+ return list(set(flags).difference(self.forced_flags))
def get_matched_dep_packages (self, depvar):
# change the useflags, because we have internally changed some, but not made them visible for portage
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index fb9836c..7ab564c 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -472,8 +472,7 @@ class PackageTable:
def fill_use_list(self):
pkg = self.actual_package()
- pkg_flags = pkg.get_iuse_flags()
- pkg_flags.sort()
+ pkg_flags = flags.sort_use_flag_list(pkg.get_iuse_flags(keep = True))
actual_exp = None
actual_exp_it = None
@@ -484,6 +483,12 @@ class PackageTable:
store = self.useList.get_model()
for use in pkg_flags:
+ if use.startswith(("+","-")):
+ forced = (use[0] == "+")
+ use = use[1:]
+ else:
+ forced = None
+
exp = pkg.use_expanded(use, suggest = actual_exp)
if exp is not None:
if exp != actual_exp:
@@ -493,7 +498,7 @@ class PackageTable:
actual_exp_it = None
actual_exp = None
- enabled = use in euse
+ enabled = forced or use in euse
installed = use in instuse
store.append(actual_exp_it, [enabled, installed, use, system.get_use_desc(use, self.cp)])
@@ -1147,11 +1152,10 @@ class MainWindow (Window):
disabled = []
expanded = set()
- pkg_flags = pkg.get_iuse_flags()
+ pkg_flags = flags.sort_use_flag_list(pkg.get_iuse_flags(keep = True))
if not pkg_flags: # no flags - stop here
return None
- pkg_flags.sort()
actual = pkg.get_actual_use_flags()
if pkg.is_installed():
@@ -1164,15 +1168,21 @@ class MainWindow (Window):
installed = []
for use in pkg_flags:
+ if use.startswith(("+","-")):
+ forced = (use[0] == "+")
+ use = use[1:]
+ else:
+ forced = None
+
exp = pkg.use_expanded(use)
if exp:
expanded.add(exp)
else:
useStr = use
- if installed and ((use in actual) != (use in installed)):
+ if installed and ((use in actual) != (use in installed)) and not (forced == (use in installed)):
useStr += " %"
- if use in actual:
+ if use in actual or forced:
enabled.append(useStr)
else:
disabled.append(useStr)