cleanup on the write functions

This commit is contained in:
Thomas Nagy 2012-05-17 13:49:09 +02:00
parent 5ec0cbed4c
commit 5d6c12be1f
2 changed files with 3 additions and 5 deletions

View File

@ -170,13 +170,11 @@ class Node(object):
:type flags: string
:param flags: Write mode
"""
f = None
f = open(self.abspath(), flags)
try:
f = open(self.abspath(), flags)
f.write(data)
finally:
if f:
f.close()
f.close()
def chmod(self, val):
"""

View File

@ -153,7 +153,7 @@ def writef(fname, data, m='w'):
"""
f = open(fname, m)
try:
txt = f.write(data)
f.write(data)
finally:
f.close()