import __main__ from os.path import dirname as _dirname, abspath as _abspath, join as _join, isfile as _isfile, isdir as _isdir from os import makedirs as _makedirs from uuid import uuid4 as _uuid4 _HERE = _dirname(_dirname(_abspath(__main__.__file__))) _PASSWORD_DIR = _join(_HERE, 'password') def get_uuid(server_name: str) -> str: if not server_name: return dir_name = _join(_PASSWORD_DIR, server_name) if not _isdir(dir_name): _makedirs(dir_name) file_name = _join(dir_name, 'uuid') if not _isfile(file_name): uuid = str(_uuid4()) with open(file_name, 'w') as fh: fh.write(uuid) with open(file_name, 'r') as fh: file_content = fh.read().strip() return file_content def calc_vaulwarden_location(index): if not index: return '/' return '/notifications/hub'