# HG changeset patch # User Goffi # Date 1590778940 -7200 # Node ID 4240b44842bbea6e1a4cbd46bb7f340d39405524 # Parent 751d8fa45ced960e2522e2387cdec0b777a6305f core: getLocalPath now returns a Path diff -r 751d8fa45ced -r 4240b44842bb sat/core/sat_main.py --- 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 ##