From 589b5a68b9dc3815e9595e64097d917659949945 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 13 Oct 2011 17:59:23 +0200 Subject: [PATCH] FileList raise exception if write failse Signed-off-by: Steven Armstrong --- lib/cdist/util/fsproperty.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/cdist/util/fsproperty.py b/lib/cdist/util/fsproperty.py index 50b95ea2..e441533a 100644 --- a/lib/cdist/util/fsproperty.py +++ b/lib/cdist/util/fsproperty.py @@ -49,6 +49,7 @@ class FileList(collections.MutableSequence): def __read(self): lines = [] + # if file does not exist return empty list try: with open(self.path) as fd: for line in fd: @@ -59,13 +60,9 @@ class FileList(collections.MutableSequence): return lines def __write(self, lines): - try: - with open(self.path, 'w') as fd: - for line in lines: - fd.write(str(line) + '\n') - except EnvironmentError as e: - # error ignored - raise + with open(self.path, 'w') as fd: + for line in lines: + fd.write(str(line) + '\n') def __repr__(self): return repr(list(self))