Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def read(self, filename=None, password=None, keyfile=None,
transformed_key=None):
self.password = password
self.keyfile = keyfile
if not filename:
filename = self.filename
try:
self.kdbx = KDBX.parse_file(
filename,
password=password,
keyfile=keyfile,
transformed_key=transformed_key
)
except ChecksumError:
raise CredentialsIntegrityError
def save_database(self):
if self.save_running is False and self.changes is True:
self.save_running = True
try:
self.db.save()
self.logging_manager.debug("Saved database")
self.changes = False
except Exception:
self.logging_manager.error("Error occured while saving database")
# Workaround
# Fix created and proposed: https://github.com/pschmitt/pykeepass/pull/102
self.db.kdbx = KDBX.parse_file(self.db.filename, password=self.db.password, keyfile=self.db.keyfile, transformed_key=None)
self.save_running = False
def save(self, filename=None, transformed_key=None):
if not filename:
filename = self.filename
with open(filename, 'wb') as f:
f.write(
KDBX.build(
self.kdbx,
password=self.password,
keyfile=self.keyfile,
transformed_key=transformed_key
)