Skip to content

Commit

Permalink
Covers: change file open/close to with block
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Apr 24, 2017
1 parent 01b369f commit 44c9b33
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions xl/covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,8 @@ def load(self):
data = None
for loc in [path, path+".old", path+".new"]:
try:
f = open(loc, 'rb')
data = pickle.load(f)
f.close()
with open(loc, 'rb') as f:
data = pickle.load(f)
except IOError:
pass
except EOFError:
Expand All @@ -378,9 +377,8 @@ def save(self):
"""
path = os.path.join(self.location, 'covers.db')
try:
f = open(path + ".new", 'wb')
pickle.dump(self.db, f, common.PICKLE_PROTOCOL)
f.close()
with open(path + ".new", 'wb') as f:
pickle.dump(self.db, f, common.PICKLE_PROTOCOL)
except IOError:
return
try:
Expand Down

0 comments on commit 44c9b33

Please sign in to comment.