mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Fix failing behave tests
This commit is contained in:
parent
84002574e6
commit
044accff6d
4 changed files with 25 additions and 3 deletions
|
@ -41,7 +41,7 @@ def open_journal(journal_name="default"):
|
|||
config.update(journal_conf)
|
||||
else: # But also just give them a string to point to the journal file
|
||||
config['journal'] = journal_conf
|
||||
return Journal.Journal(**config)
|
||||
return Journal.open_journal(journal_name, config)
|
||||
|
||||
|
||||
@given('we use the config "{config_file}"')
|
||||
|
|
|
@ -50,6 +50,7 @@ class DayOne(Journal.Journal):
|
|||
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
||||
self.entries.append(entry)
|
||||
self.sort()
|
||||
return self
|
||||
|
||||
def write(self):
|
||||
"""Writes only the entries that have been modified into plist files."""
|
||||
|
|
|
@ -5,6 +5,8 @@ from __future__ import absolute_import, unicode_literals
|
|||
from . import Entry
|
||||
from . import util
|
||||
from . import time
|
||||
import os
|
||||
import sys
|
||||
import codecs
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
@ -224,3 +226,22 @@ class PlainJournal(Journal):
|
|||
def _store(self, filename, text):
|
||||
with codecs.open(filename, 'w', "utf-8") as f:
|
||||
f.write(text)
|
||||
|
||||
|
||||
def open_journal(name, config):
|
||||
"""
|
||||
Creates a normal, encrypted or DayOne journal based on the passed config.
|
||||
"""
|
||||
if os.path.isdir(config['journal']):
|
||||
if config['journal'].strip("/").endswith(".dayone") or "entries" in os.listdir(config['journal']):
|
||||
from . import DayOneJournal
|
||||
return DayOneJournal.DayOne(**config).open()
|
||||
else:
|
||||
util.prompt(u"[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
|
||||
sys.exit(1)
|
||||
|
||||
if not config['encrypt']:
|
||||
return PlainJournal(name, **config).open()
|
||||
else:
|
||||
from . import EncryptedJournal
|
||||
return EncryptedJournal.EncryptedJournal(name, **config).open()
|
||||
|
|
|
@ -77,7 +77,7 @@ def encrypt(journal, filename=None):
|
|||
new_journal.write(filename)
|
||||
|
||||
if util.yesno("Do you want to store the password in your keychain?", default=True):
|
||||
util.set_keychain(journal.name, password)
|
||||
util.set_keychain(journal.name, journal.config['password'])
|
||||
|
||||
util.prompt("Journal encrypted to {0}.".format(filename or new_journal.config['journal']))
|
||||
|
||||
|
@ -204,7 +204,7 @@ def run(manual_args=None):
|
|||
else:
|
||||
mode_compose = False
|
||||
|
||||
journal = open_journal(journal_name, config)
|
||||
journal = Journal.open_journal(journal_name, config)
|
||||
|
||||
# Writing mode
|
||||
if mode_compose:
|
||||
|
|
Loading…
Add table
Reference in a new issue