Permalink
Browse files

Replaced 'with open(path) as f:' with 'fh = open(path)'. There were p…

…roblem with the first method on Mac OS X if I remember correctly.
  • Loading branch information...
1 parent 311caa8 commit 7fc6f455d1417575bdc5a29782b3d90461446d30 Frank Smit committed Feb 6, 2010
Showing with 32 additions and 11 deletions.
  1. +12 −4 lib/config.py
  2. +14 −5 lib/utils.py
  3. +6 −2 lib/widgets.py
View
@@ -81,11 +81,19 @@ def __init__(self, al):
def _save_settings(self, widget=None):
# Private. Save a pickled, base64 encoded version of self.settings in settings.cfg.
- with open(self.al.HOME + '/settings.cfg', 'wb') as f:
- f.write(base64.b64encode(cPickle.dumps((self.user_verified, self.settings), cPickle.HIGHEST_PROTOCOL)))
+ #with open(self.al.HOME + '/settings.cfg', 'wb') as f:
+ # f.write(base64.b64encode(cPickle.dumps((self.user_verified, self.settings), cPickle.HIGHEST_PROTOCOL)))
+
+ fh = open(self.al.HOME + '/settings.cfg', 'wb')
+ fh.write(base64.b64encode(cPickle.dumps((self.user_verified, self.settings), cPickle.HIGHEST_PROTOCOL)))
+ fh.close()
def _load_settings(self):
# Private. Load contents from settings.cfg, base64 decode, unpickle and assign it to self.settings.
- with open(self.al.HOME + '/settings.cfg', 'rb') as f:
- self.user_verified, self.settings = cPickle.loads(base64.b64decode(f.read()))
+ #with open(self.al.HOME + '/settings.cfg', 'rb') as f:
+ # self.user_verified, self.settings = cPickle.loads(base64.b64decode(f.read()))
+
+ fh = open(self.al.HOME + '/settings.cfg', 'rb')
+ self.user_verified, self.settings = cPickle.loads(base64.b64decode(fh.read()))
+ fh.close()
View
@@ -58,15 +58,24 @@ def optimize_pickle(p):
def cache_data(path, data):
"""Pickle data and write if to the disk."""
- with open(path, 'wb') as f:
- pickle = optimize_pickle(cPickle.dumps(data, cPickle.HIGHEST_PROTOCOL))
- f.write(pickle)
+ #with open(path, 'wb') as f:
+ # pickle = optimize_pickle(cPickle.dumps(data, cPickle.HIGHEST_PROTOCOL))
+ # f.write(pickle)
+
+ fh = open(path, 'wb')
+ pickle = optimize_pickle(cPickle.dumps(data, cPickle.HIGHEST_PROTOCOL))
+ fh.write(pickle)
+ fh.close()
def get_cache(path):
"""Get data from disk and upickle it."""
- with open(path, 'rb') as f:
- contents = cPickle.load(f)
+ #with open(path, 'rb') as f:
+ # contents = cPickle.load(f)
+
+ fh = open(path, 'rb')
+ contents = cPickle.load(fh)
+ fh.close()
return contents
View
@@ -216,8 +216,12 @@ def _read_licence_file(self):
# Private. Get the contents of the license file (COPYING) and return it.
try:
- with open('%s/COPYING' % self.al.path, 'r') as f:
- contents = f.read()
+ #with open('%s/COPYING' % self.al.path, 'r') as f:
+ # contents = f.read()
+
+ fh = open('%s/COPYING' % self.al.path, 'r')
+ contents = fh.read()
+ fh.close()
except IOError:
contents = 'No license file found.'

0 comments on commit 7fc6f45

Please sign in to comment.