in keyper/__init__.py [0:0]
def create_temporary() -> "Keychain":
"""Create a new temporary keychain."""
keychain_name = str(uuid.uuid4()) + ".keychain"
keychain_path = os.path.join(tempfile.gettempdir(), keychain_name)
keychain_password = "".join(secrets.choice(_PASSWORD_ALPHABET) for _ in range(50))
if os.path.exists(keychain_path):
raise Exception(
"Cannot create temporary keychain. Path already exists: " + keychain_path
)
keychain = Keychain(keychain_path, keychain_password, is_temporary=True)
# We have a reference, but now we need to create the keychain with the
# system.
Keychain._create_keychain(keychain_path, keychain_password)
log.info("Created temporary keychain: %s", keychain_path)
return keychain