diff --git a/sat/core/sat_main.py b/sat/core/sat_main.py index 707c62a4..4f05c493 100644 --- a/sat/core/sat_main.py +++ b/sat/core/sat_main.py @@ -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 ##