summaryrefslogtreecommitdiff
path: root/morphlib/cachedir.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-03-01 15:01:56 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-03-02 17:13:29 +0000
commit4ce8550592aea90db883a199de9264e279c4dda2 (patch)
tree8d5f0f42e1ac621a46e3c145c7b25867adcdb06b /morphlib/cachedir.py
parentfafeea2dfcf5de44c72bde892e3e053b652479cf (diff)
downloadmorph-4ce8550592aea90db883a199de9264e279c4dda2.tar.gz
Allow passing arguments to open() in CacheDir.open
Diffstat (limited to 'morphlib/cachedir.py')
-rw-r--r--morphlib/cachedir.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/morphlib/cachedir.py b/morphlib/cachedir.py
index 6bd75608..a7daaf3b 100644
--- a/morphlib/cachedir.py
+++ b/morphlib/cachedir.py
@@ -64,7 +64,7 @@ class CacheDir(object):
return os.path.join(self.dirname, key + suffix)
- def open(self, relative_name_or_cache_key, suffix=''):
+ def open(self, relative_name_or_cache_key, suffix='', **kwargs):
'''Open a file for writing in the cache.
The file will be written with a temporary name, and renamed to
@@ -81,5 +81,7 @@ class CacheDir(object):
else:
path = os.path.join(self.dirname, relative_name_or_cache_key)
path += suffix
- return morphlib.savefile.SaveFile(path, 'w')
+ if 'mode' not in kwargs:
+ kwargs['mode'] = 'w'
+ return morphlib.savefile.SaveFile(path, **kwargs)