Updated docs from master

This commit is contained in:
Manuel Ebert 2014-03-28 14:54:08 -07:00
parent 25e92c8abf
commit 7227bccbc2
36 changed files with 79 additions and 79 deletions

View file

@ -5,12 +5,13 @@ import re
import textwrap
from datetime import datetime
class Entry:
def __init__(self, journal, date=None, title="", body="", starred=False):
self.journal = journal # Reference to journal mainly to access it's config
self.journal = journal # Reference to journal mainly to access it's config
self.date = date or datetime.now()
self.title = title.strip("\n ")
self.body = body.strip("\n ")
self.title = title.rstrip("\n ")
self.body = body.rstrip("\n ")
self.tags = self.parse_tags()
self.starred = starred
self.modified = False
@ -27,12 +28,11 @@ class Entry:
title = date_str + " " + self.title
if self.starred:
title += " *"
body = self.body.strip()
return u"{title}{sep}{body}\n".format(
title=title,
sep="\n" if self.body else "",
body=body
body=self.body
)
def pprint(self, short=False):
@ -47,11 +47,11 @@ class Entry:
initial_indent="| ",
subsequent_indent="| ",
drop_whitespace=False)
for line in self.body.strip().splitlines()
for line in self.body.rstrip().splitlines()
])
else:
title = date_str + " " + self.title
body = self.body.strip()
body = self.body
# Suppress bodies that are just blanks and new lines.
has_body = len(self.body) > 20 or not all(char in (" ", "\n") for char in self.body)
@ -71,7 +71,7 @@ class Entry:
def __eq__(self, other):
if not isinstance(other, Entry) \
or self.title.strip() != other.title.strip() \
or self.body.strip() != other.body.strip() \
or self.body.rstrip() != other.body.rstrip() \
or self.date != other.date \
or self.starred != other.starred:
return False
@ -82,8 +82,8 @@ class Entry:
def to_dict(self):
return {
'title': self.title.strip(),
'body': self.body.strip(),
'title': self.title,
'body': self.body,
'date': self.date.strftime("%Y-%m-%d"),
'time': self.date.strftime("%H:%M"),
'starred': self.starred
@ -91,8 +91,8 @@ class Entry:
def to_md(self):
date_str = self.date.strftime(self.journal.config['timeformat'])
body_wrapper = "\n\n" if self.body.strip() else ""
body = body_wrapper + self.body.strip()
body_wrapper = "\n\n" if self.body else ""
body = body_wrapper + self.body
space = "\n"
md_head = "###"

Binary file not shown.

View file

@ -123,9 +123,9 @@ class Journal(object):
current_entry = None
for line in journal_txt.splitlines():
line = line.rstrip()
try:
# try to parse line as date => new entry begins
line = line.strip()
new_date = datetime.strptime(line[:date_length], self.config['timeformat'])
# parsing successful => save old entry and create new one
@ -280,7 +280,7 @@ class Journal(object):
raw = raw.replace('\\n ', '\n').replace('\\n', '\n')
starred = False
# Split raw text into title and body
sep = re.search("[\n!?.]+", raw)
sep = re.search("\n|[\?.]+", raw)
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
starred = False
if not date:
@ -372,7 +372,7 @@ class DayOne(Journal):
def editable_str(self):
"""Turns the journal into a string of entries that can be edited
manually and later be parsed with eslf.parse_editable_str."""
return u"\n".join(["# {0}\n{1}".format(e.uuid, e.__unicode__()) for e in self.entries])
return u"\n".join([u"# {0}\n{1}".format(e.uuid, e.__unicode__()) for e in self.entries])
def parse_editable_str(self, edited):
"""Parses the output of self.editable_str and updates it's entries."""
@ -388,7 +388,7 @@ class DayOne(Journal):
for line in edited.splitlines():
# try to parse line as UUID => new entry begins
line = line.strip()
line = line.rstrip()
m = re.match("# *([a-f0-9]+) *$", line.lower())
if m:
if current_entry:

Binary file not shown.

View file

@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
from __future__ import absolute_import
__title__ = 'jrnl'
__version__ = '1.7.12'
__version__ = '1.7.16'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'

Binary file not shown.

View file

@ -59,7 +59,7 @@ def guess_mode(args, config):
elif any((args.start_date, args.end_date, args.limit, args.strict, args.starred)):
# Any sign of displaying stuff?
compose = False
elif args.text and all(word[0] in config['tagsymbols'] for word in " ".join(args.text).split()):
elif args.text and all(word[0] in config['tagsymbols'] for word in u" ".join(args.text).split()):
# No date and only tags?
compose = False
@ -110,7 +110,7 @@ def update_config(config, new_config, scope, force_local=False):
def run(manual_args=None):
args = parse_args(manual_args)
args.text = [p.decode('utf-8') if util.PY2 and not isinstance(p, unicode) else p for p in args.text]
if args.version:
version_str = "{0} version {1}".format(jrnl.__title__, jrnl.__version__)
print(util.py2encode(version_str))
@ -160,7 +160,7 @@ def run(manual_args=None):
"entries" in os.listdir(config['journal']):
journal = Journal.DayOne(**config)
else:
util.prompt("[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
util.prompt(u"[Error: {0} is a directory, but doesn't seem to be a DayOne journal either.".format(config['journal']))
sys.exit(1)
else:
journal = Journal.Journal(journal_name, **config)
@ -241,8 +241,8 @@ def run(manual_args=None):
num_deleted = old_num_entries - len(journal)
num_edited = len([e for e in journal.entries if e.modified])
prompts = []
if num_deleted: prompts.append("{0} entries deleted".format(num_deleted))
if num_edited: prompts.append("{0} entries modified".format(num_edited))
if num_deleted: prompts.append("{0} {1} deleted".format(num_deleted, "entry" if num_deleted == 1 else "entries"))
if num_edited: prompts.append("{0} {1} modified".format(num_edited, "entry" if num_deleted == 1 else "entries"))
if prompts:
util.prompt("[{0}]".format(", ".join(prompts).capitalize()))
journal.entries += other_entries

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.