Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def decrypt(journal, filename=None):
""" Decrypts into new file. If filename is not set, we encrypt the journal file itself. """
journal.config['encrypt'] = False
new_journal = PlainJournal.from_journal(journal)
new_journal.write(filename)
print("Journal decrypted to {}.".format(filename or new_journal.config['journal']), file=sys.stderr)
backup(path, binary=True)
old_journal = Journal.open_journal(
journal_name, util.scope_config(config, journal_name), legacy=True
)
all_journals.append(EncryptedJournal.from_journal(old_journal))
for journal_name, path in plain_journals.items():
print(
f"\nUpgrading plain text '{journal_name}' journal stored in {path}...",
file=sys.stderr,
)
backup(path)
old_journal = Journal.open_journal(
journal_name, util.scope_config(config, journal_name), legacy=True
)
all_journals.append(Journal.PlainJournal.from_journal(old_journal))
# loop through lists to validate
failed_journals = [j for j in all_journals if not j.validate_parsing()]
if len(failed_journals) > 0:
print(
"\nThe following journal{} failed to upgrade:\n{}".format(
"s" if len(failed_journals) > 1 else "",
"\n".join(j.name for j in failed_journals),
),
file=sys.stderr,
)
raise UpgradeValidationException
# write all journals - or - don't