Commits

Michał Górny  committed baf8403

Support removing global flags through the '%' action.

  • Participants
  • Parent commits e46d2f2

Comments (0)

Files changed (2)

File lib/flaggie/action.py

 		def __call__(self, pkgs, pfiles):
 			for ns in self.ns:
 				puse = pfiles[ns]
-				for p in pkgs:
+				for p in pkgs or (None,):
 					for pe in puse[p]:
 						for f in self.args:
 							del pe[f]
-				if not pkgs:
-					raise NotImplementedError('Global actions are not supported yet.')
 
 	class output(BaseAction):
 		def __call__(self, pkgs, pfiles):

File lib/flaggie/makeconf.py

 				if isinstance(f, self.MakeConfFlag):
 					yield f
 
+	def __delitem__(self, flag):
+		""" Remove all occurences of a flag. """
+		self.parseflags()
+
+		for mv, t in self._flattokens:
+			flags = []
+			wasflag = False
+			for f in t.flags:
+				if isinstance(f, self.MakeConfFlag) and flag == f.name:
+					flags.append(f)
+					wasflag = True
+				else:
+					if isinstance(f, self.Whitespace) and wasflag:
+						flags.append(f)
+					wasflag = False
+			for f in flags:
+				t.flags.remove(f)
+
+			t.modified = True
+
 	def __repr__(self):
 		return 'MakeConfVariable(%s, %s)' % (self._key, self._tokens)