FileList raise exception if write failse
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
6271e27eb5
commit
589b5a68b9
1 changed files with 4 additions and 7 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue