Michał Górny  committed 6cb2443

Add --drop-unmatched-flags action.

  • Participants
  • Parent commits ebc477b

Comments (0)

Files changed (2)

File lib/flaggie/

+class DropUnmatchedFlags(BaseCleanupAction):
+	def __call__(self, pkgs, pfiles):
+		if pkgs:
+			raise AssertionError('pkgs not empty in cleanup action')
+		for k, f in pfiles.files.items():
+			cache = self._cache[k]
+			for pe in f:
+				flags = cache[pe.package]
+				for flag in set([ for x in pe]):
+					if k == 'kw' and flag == '**':
+						pass
+					elif flag not in flags:
+						del pe[flag]
 class DropUnmatchedPkgs(BaseCleanupAction):
 	def _perform(self, f):
 		cache = {}
 		for pe in f:
-cleanupact_order = (DropUnmatchedPkgs, DropIneffective, SortEntries, SortFlags)
+cleanupact_order = (DropUnmatchedPkgs, DropUnmatchedFlags, DropIneffective, \
+		SortEntries, SortFlags)

File lib/flaggie/

 from flaggie.action import Action, ActionSet, ParserError, ParserWarning
 from flaggie.cache import Caches
 from flaggie.cleanup import DropIneffective, DropUnmatchedPkgs, \
-		SortEntries, SortFlags
+		DropUnmatchedFlags, SortEntries, SortFlags
 from flaggie.packagefile import PackageFiles
 def parse_actions(args, dbapi, settings, quiet = False, strict = False, \
 	--drop-unmatched-pkgs	Drop packages which no longer are available
 				in portdb
+	--drop-unmatched-flags	Drop flags which are not found in package's
+				IUSE, KEYWORDS and/or LICENSE variables
 Global actions are applied to the make.conf file. Actions are applied to
 the package.* files, for the packages preceding them.
 			elif a == '--drop-unmatched-pkgs':
+			elif a == '--drop-unmatched-flags':
+				cleanup_actions.add(DropUnmatchedFlags)
 			elif a == '--':