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):
|
def __read(self):
|
||||||
lines = []
|
lines = []
|
||||||
|
# if file does not exist return empty list
|
||||||
try:
|
try:
|
||||||
with open(self.path) as fd:
|
with open(self.path) as fd:
|
||||||
for line in fd:
|
for line in fd:
|
||||||
|
@ -59,13 +60,9 @@ class FileList(collections.MutableSequence):
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
def __write(self, lines):
|
def __write(self, lines):
|
||||||
try:
|
with open(self.path, 'w') as fd:
|
||||||
with open(self.path, 'w') as fd:
|
for line in lines:
|
||||||
for line in lines:
|
fd.write(str(line) + '\n')
|
||||||
fd.write(str(line) + '\n')
|
|
||||||
except EnvironmentError as e:
|
|
||||||
# error ignored
|
|
||||||
raise
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return repr(list(self))
|
return repr(list(self))
|
||||||
|
|
Loading…
Reference in a new issue