Get user profile in paths
This commit is contained in:
parent
19e211ce0a
commit
d983fac3d1
|
@ -715,7 +715,8 @@ def sha512(data):
|
||||||
def get_config(key='', prefix='conf', default={}):
|
def get_config(key='', prefix='conf', default={}):
|
||||||
name_file = FILE_NAME_CONFIG.format(prefix)
|
name_file = FILE_NAME_CONFIG.format(prefix)
|
||||||
values = None
|
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):
|
if not _P.exists(path):
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
@ -728,7 +729,8 @@ def get_config(key='', prefix='conf', default={}):
|
||||||
|
|
||||||
def set_config(key, value, prefix='conf'):
|
def set_config(key, value, prefix='conf'):
|
||||||
name_file = FILE_NAME_CONFIG.format(prefix)
|
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 = get_config(default={}, prefix=prefix)
|
||||||
values[key] = value
|
values[key] = value
|
||||||
result = _P.to_json(path, values)
|
result = _P.to_json(path, values)
|
||||||
|
@ -6518,6 +6520,17 @@ class Paths(object):
|
||||||
path = sys.executable
|
path = sys.executable
|
||||||
return path
|
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
|
@classmethod
|
||||||
def dir_tmp(self, only_name=False):
|
def dir_tmp(self, only_name=False):
|
||||||
dt = tempfile.TemporaryDirectory()
|
dt = tempfile.TemporaryDirectory()
|
||||||
|
|
Loading…
Reference in New Issue