mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Simplify cache code..
This commit is contained in:
parent
e14d156650
commit
06e72c0e86
1 changed files with 2 additions and 5 deletions
|
@ -25,7 +25,7 @@ def get_cachedir(subdir='', make_dir=True):
|
|||
return path
|
||||
|
||||
|
||||
def open_cachefile(filename, mode='r', **kwargs):
|
||||
def open_cachefile(filename, mode='r', subdir=''):
|
||||
"""Open a cache file and return a stream
|
||||
|
||||
Attempt to open in 'mode' the cache file 'filename' from the
|
||||
|
@ -39,9 +39,6 @@ def open_cachefile(filename, mode='r', **kwargs):
|
|||
- **kwargs -- Optional arguments for get_cachedir
|
||||
|
||||
"""
|
||||
# Set make_dir if not given
|
||||
kwargs['make_dir'] = kwargs.get('make_dir',
|
||||
True if mode[0] == 'w' else False)
|
||||
cache_dir = get_cachedir(**kwargs)
|
||||
cache_dir = get_cachedir(subdir, make_dir=True if mode[0] == 'w' else False)
|
||||
file_path = os.path.join(cache_dir, filename)
|
||||
return open(file_path, mode)
|
||||
|
|
Loading…
Add table
Reference in a new issue