How to use the jrnl.Journal.PlainJournal.from_journal function in jrnl

To help you get started, we’ve selected a few jrnl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jrnl-org / jrnl / jrnl / cli.py View on Github external
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)
github jrnl-org / jrnl / jrnl / upgrade.py View on Github external
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