Michał Górny avatar Michał Górny committed 6cb2443

Add --drop-unmatched-flags action.

Comments (0)

Files changed (2)


+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([x.name 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)


 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 == '--':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.