How to use the jrnl.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.py View on Github external
with open(tmpfile) as f:
                    raw = f.read()
                os.remove(tmpfile)
            else:
                print('nothing saved to file')
                raw = ''
        else:
            raw = raw_input("Compose Entry: ")

        if raw:
            args.text = [raw]
        else:
            compose = False

    # open journal
    journal = Journal(config=config)

    # Writing mode
    if compose:
        raw = " ".join(args.text).strip()
        journal.new_entry(raw, args.date)
        print("Entry added.")
        journal.write()

    elif not export: # read mode
        journal.filter(tags=args.text,
                       start_date=args.start_date, end_date=args.end_date,
                       strict=args.strict,
                       short=args.short)
        journal.limit(args.limit)
        print(journal)
github jrnl-org / jrnl / jrnl / upgrade.py View on Github external
)

    try:
        cont = util.yesno("\nContinue upgrading jrnl?", default=False)
        if not cont:
            raise KeyboardInterrupt
    except KeyboardInterrupt:
        raise UserAbort("jrnl NOT upgraded, exiting.")

    for journal_name, path in encrypted_journals.items():
        print(
            f"\nUpgrading encrypted '{journal_name}' journal stored in {path}...",
            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
github jrnl-org / jrnl / jrnl / upgrade.py View on Github external
f"\nUpgrading encrypted '{journal_name}' journal stored in {path}...",
            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,
        )
github jrnl-org / jrnl / features / steps / core.py View on Github external
def open_journal(journal_name="default"):
    config = util.load_config(install.CONFIG_FILE_PATH)
    journal_conf = config["journals"][journal_name]
    if (
        type(journal_conf) is dict
    ):  # We can override the default config on a by-journal basis
        config.update(journal_conf)
    else:  # But also just give them a string to point to the journal file
        config["journal"] = journal_conf
    return Journal.open_journal(journal_name, config)
github jrnl-org / jrnl / jrnl / DayOneJournal.py View on Github external
from . import Entry
from . import Journal
from . import time as jrnl_time
import os
import re
from datetime import datetime
import time
import fnmatch
import plistlib
import pytz
import uuid
import tzlocal
from xml.parsers.expat import ExpatError


class DayOne(Journal.Journal):
    """A special Journal handling DayOne files"""

    # InvalidFileException was added to plistlib in Python3.4
    PLIST_EXCEPTIONS = (
        (ExpatError, plistlib.InvalidFileException)
        if hasattr(plistlib, "InvalidFileException")
        else ExpatError
    )

    def __init__(self, **kwargs):
        self.entries = []
        self._deleted_entries = []
        super().__init__(**kwargs)

    def open(self):
        filenames = [