cloudmarker/cloudmarker

Support tilde expansion on filestore path

Closed this issue · 1 comments

susam commented

We should support tilde expansion in any paths read from configuration as much as possible.

For example, currently the filestore plugin module accepts a directory path as path parameter to write output files.

def __init__(self, path='/tmp/cloudmarker'):
"""Initialize object of this class with specified parameters.
Arguments:
path (str): Path of directory where files are written to.
"""
self._path = path

It should expand tilde (~) or (~user) in the path to the home directory of the user.

Python has a os.path.expanduser() function that does this. This should be used to do this task. Here is an example usage:

>>> import os
>>> os.path.expanduser('~susam')
'/Users/susam'
>>> os.path.expanduser('~susam/foo')
'/Users/susam/foo'
>>> os.path.expanduser('~')
'/Users/susam'
>>> os.path.expanduser('~/foo')
'/Users/susam/foo'

Added #21 for the issue.