Get user profile in paths

This commit is contained in:
Mauricio Baeza 2021-07-09 22:40:24 -05:00
parent 19e211ce0a
commit d983fac3d1
1 changed files with 15 additions and 2 deletions

View File

@ -715,7 +715,8 @@ def sha512(data):
def get_config(key='', prefix='conf', default={}):
name_file = FILE_NAME_CONFIG.format(prefix)
values = None
path = _P.join(_P.config('UserConfig'), name_file)
# ~ path = _P.join(_P.config('UserConfig'), name_file)
path = _P.join(_P.user_config, name_file)
if not _P.exists(path):
return default
@ -728,7 +729,8 @@ def get_config(key='', prefix='conf', default={}):
def set_config(key, value, prefix='conf'):
name_file = FILE_NAME_CONFIG.format(prefix)
path = _P.join(_P.config('UserConfig'), name_file)
# ~ path = _P.join(_P.config('UserConfig'), name_file)
path = _P.join(_P.user_config, name_file)
values = get_config(default={}, prefix=prefix)
values[key] = value
result = _P.to_json(path, values)
@ -6518,6 +6520,17 @@ class Paths(object):
path = sys.executable
return path
@classproperty
def user_profile(self):
path = self.config('UserConfig')
path = str(Path(path).parent)
return path
@classproperty
def user_config(self):
path = self.config('UserConfig')
return path
@classmethod
def dir_tmp(self, only_name=False):
dt = tempfile.TemporaryDirectory()