mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-08 01:06:12 +02:00
Updated docs from master
This commit is contained in:
parent
0bcfdb2bde
commit
af070b1ca3
12 changed files with 1164 additions and 6 deletions
|
@ -42,11 +42,11 @@ class Entry:
|
|||
if not short and self.journal.config['linewrap']:
|
||||
title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap'])
|
||||
body = "\n".join([
|
||||
textwrap.fill(line+" ",
|
||||
textwrap.fill((line + " ") if (len(line) == 0) else line,
|
||||
self.journal.config['linewrap'],
|
||||
initial_indent="| ",
|
||||
subsequent_indent="| ",
|
||||
drop_whitespace=False).replace(' ', ' ')
|
||||
drop_whitespace=False)
|
||||
for line in self.body.strip().splitlines()
|
||||
])
|
||||
else:
|
||||
|
|
|
@ -25,6 +25,7 @@ import pytz
|
|||
import uuid
|
||||
import tzlocal
|
||||
|
||||
|
||||
class Journal(object):
|
||||
def __init__(self, name='default', **kwargs):
|
||||
self.config = {
|
||||
|
@ -318,6 +319,7 @@ class Journal(object):
|
|||
entry.modified = not any(entry == old_entry for old_entry in self.entries)
|
||||
self.entries = mod_entries
|
||||
|
||||
|
||||
class DayOne(Journal):
|
||||
"""A special Journal handling DayOne files"""
|
||||
def __init__(self, **kwargs):
|
||||
|
@ -342,7 +344,7 @@ class DayOne(Journal):
|
|||
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
|
||||
entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"])
|
||||
entry.uuid = dict_entry["UUID"]
|
||||
entry.tags = dict_entry.get("Tags", [])
|
||||
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
||||
self.entries.append(entry)
|
||||
self.sort()
|
||||
|
||||
|
@ -353,7 +355,7 @@ class DayOne(Journal):
|
|||
if not hasattr(entry, "uuid"):
|
||||
entry.uuid = uuid.uuid1().hex
|
||||
utc_time = datetime.utcfromtimestamp(time.mktime(entry.date.timetuple()))
|
||||
filename = os.path.join(self.config['journal'], "entries", entry.uuid+".doentry")
|
||||
filename = os.path.join(self.config['journal'], "entries", entry.uuid + ".doentry")
|
||||
entry_plist = {
|
||||
'Creation Date': utc_time,
|
||||
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
||||
|
@ -430,4 +432,3 @@ class DayOne(Journal):
|
|||
self._deleted_entries = [e for e in self.entries if e.uuid not in edited_uuids]
|
||||
self.entries[:] = [e for e in self.entries if e.uuid in edited_uuids]
|
||||
return entries
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
|
|||
from __future__ import absolute_import
|
||||
|
||||
__title__ = 'jrnl'
|
||||
__version__ = '1.7.10'
|
||||
__version__ = '1.7.12'
|
||||
__author__ = 'Manuel Ebert'
|
||||
__license__ = 'MIT License'
|
||||
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
||||
|
|
13
jrnl/cli.py
13
jrnl/cli.py
|
@ -26,6 +26,7 @@ PYCRYPTO = install.module_exists("Crypto")
|
|||
def parse_args(args=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-v', '--version', dest='version', action="store_true", help="prints version information and exits")
|
||||
parser.add_argument('-ls', dest='ls', action="store_true", help="displays accessible journals")
|
||||
|
||||
composing = parser.add_argument_group('Composing', 'To write an entry simply write it on the command line, e.g. "jrnl yesterday at 1pm: Went to the gym."')
|
||||
composing.add_argument('text', metavar='', nargs="*")
|
||||
|
@ -87,6 +88,14 @@ def touch_journal(filename):
|
|||
util.prompt("[Journal created at {0}]".format(filename))
|
||||
open(filename, 'a').close()
|
||||
|
||||
def list_journals(config):
|
||||
"""List the journals specified in the configuration file"""
|
||||
|
||||
sep = "\n"
|
||||
journal_list = sep.join(config['journals'])
|
||||
|
||||
return journal_list
|
||||
|
||||
def update_config(config, new_config, scope, force_local=False):
|
||||
"""Updates a config dict with new values - either global if scope is None
|
||||
or config['journals'][scope] is just a string pointing to a journal file,
|
||||
|
@ -113,6 +122,10 @@ def run(manual_args=None):
|
|||
config = util.load_and_fix_json(CONFIG_PATH)
|
||||
install.upgrade_config(config, config_path=CONFIG_PATH)
|
||||
|
||||
if args.ls:
|
||||
print(util.py2encode(list_journals(config)))
|
||||
sys.exit(0)
|
||||
|
||||
original_config = config.copy()
|
||||
# check if the configuration is supported by available modules
|
||||
if config['encrypt'] and not PYCRYPTO:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue