1. Michał Górny
  2. flaggie

Commits

Michał Górny  committed 0e46310

Prepare the actual output before opening the file.

  • Participants
  • Parent commits 8cf678c
  • Branches master

Comments (0)

Files changed (1)

File lib/flaggie/packagefile.py

View file
  • Ignore whitespace
 			if not self.modified:
 				return
 
+			data = ''
+			for l in self:
+				if not l.modified or l:
+					data += l.toString()
+			data += ''.join(self.trailing_whitespace)
+
 			f = tempfile.NamedTemporaryFile('wb', delete = False, \
 					dir = os.path.dirname(os.path.realpath(self.path)))
 			tmpname = f.name
 
 			try:
 				f = codecs.getwriter('utf8')(f)
-				for l in self:
-					if not l.modified or l:
-						f.write(l.toString())
-				f.write(''.join(self.trailing_whitespace))
+				f.write(data)
 				f.close()
 
 				backup = self.path + '~'