Commits

Michał Górny  committed 091adf6

Switch to indirect removal of global flags.

  • Participants
  • Parent commits f51b292

Comments (0)

Files changed (1)

File lib/flaggie/makeconf.py

 
 				self._origs = s
 				self._partialflags = lta
+				self._removed = False
 
 			@property
 			def modified(self):
 					raise NotImplementedError('Disable modified for MakeConfFlag is not supported.')
 
 			@property
+			def removed(self):
+				return self._removed
+
+			@removed.setter
+			def removed(self, val):
+				# This also cleans up partial flags.
+				self.modified = True
+				self._removed = val
+
+			@property
 			def modifier(self):
 				return self._modifier
 
 				self.modified = True
 
 			def toString(self, raw = False):
-				if not self.modified:
+				if self.removed:
+					return ''
+				elif not self.modified:
 					return self._origs
 				else:
 					return PackageFileSet.PackageFile.PackageEntry.PackageFlag.toString(self)
 
 		def __delitem__(self, flag):
 			""" Remove all occurences of a flag. """
-			flags = []
-			wasflag = False
 			for f in self.flags:
 				if isinstance(f, self.MakeConfFlag) and flag == f.name:
-					# set modified to clean up partial flags
-					f.modified = True
-					flags.append(f)
-					wasflag = True
-				else:
-					if isinstance(f, self.Whitespace) and wasflag:
-						flags.append(f)
-					wasflag = False
-			for f in flags:
-				self.remove(f)
+					f.removed = True
+					self.modified = True
 
 	def __init__(self, key, tokens):
 		def flattentokens(l):