Mercurial > libervia-backend
diff sat/core/sat_main.py @ 3285:4240b44842bb
core: getLocalPath now returns a Path
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 29 May 2020 21:02:20 +0200 |
parents | f300d78f08f3 |
children | 9bc3fca290ab |
line wrap: on
line diff
--- a/sat/core/sat_main.py Fri May 29 20:57:23 2020 +0200 +++ b/sat/core/sat_main.py Fri May 29 21:02:20 2020 +0200 @@ -856,8 +856,14 @@ # 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 @@ @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 @@ 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 ##