core: getLocalPath now returns a Path
This commit is contained in:
parent
f48ad8179c
commit
b9fa21ab47
1 changed files with 12 additions and 7 deletions
|
|
@ -856,8 +856,14 @@ class SAT(service.Service):
|
|||
|
||||
# local dirs
|
||||
|
||||
def getLocalPath(self, client, dir_name, *extra_path, **kwargs):
|
||||
"""retrieve path for local data
|
||||
def getLocalPath(
|
||||
self,
|
||||
client,
|
||||
dir_name: str,
|
||||
*extra_path,
|
||||
**kwargs
|
||||
) -> Path:
|
||||
"""Retrieve path for local data
|
||||
|
||||
if path doesn't exist, it will be created
|
||||
@param client(SatXMPPClient, None): client instance
|
||||
|
|
@ -866,7 +872,7 @@ class SAT(service.Service):
|
|||
@param component(bool): if True, path will be prefixed with C.COMPONENTS_DIR
|
||||
@param profile(bool): if True, path will be suffixed by profile name
|
||||
@param *extra_path: extra path element(s) to use
|
||||
@return (unicode): path
|
||||
@return: path
|
||||
"""
|
||||
# FIXME: component and profile are parsed with **kwargs because of python 2
|
||||
# limitations. Once moved to python 3, this can be fixed
|
||||
|
|
@ -882,10 +888,9 @@ class SAT(service.Service):
|
|||
path_elts.extend([regex.pathEscape(p) for p in extra_path])
|
||||
if profile:
|
||||
regex.pathEscape(client.profile)
|
||||
path = os.path.join(*path_elts)
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
local_path = Path(*path_elts)
|
||||
local_path.mkdir(0o700, parents=True, exist_ok=True)
|
||||
return local_path
|
||||
|
||||
## Client management ##
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue