mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
commit
036244fd29
8 changed files with 155 additions and 14 deletions
|
@ -4,6 +4,7 @@ Changelog
|
||||||
|
|
||||||
### 1.7 (December 22, 2013)
|
### 1.7 (December 22, 2013)
|
||||||
|
|
||||||
|
* __1.7.20__ Minor fixes when parsing DayOne journals
|
||||||
* __1.7.19__ Creates full path to journal during installation if it doesn't exist yet
|
* __1.7.19__ Creates full path to journal during installation if it doesn't exist yet
|
||||||
* __1.7.18__ Small update to parsing regex
|
* __1.7.18__ Small update to parsing regex
|
||||||
* __1.7.17__ Fixes writing new lines between entries
|
* __1.7.17__ Fixes writing new lines between entries
|
||||||
|
|
14
features/data/configs/bug153.json
Normal file
14
features/data/configs/bug153.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"default_hour": 9,
|
||||||
|
"timeformat": "%Y-%m-%d %H:%M",
|
||||||
|
"linewrap": 80,
|
||||||
|
"encrypt": false,
|
||||||
|
"editor": "",
|
||||||
|
"default_minute": 0,
|
||||||
|
"highlight": true,
|
||||||
|
"password": "",
|
||||||
|
"journals": {
|
||||||
|
"default": "features/journals/bug153.dayone"
|
||||||
|
},
|
||||||
|
"tagsymbols": "@"
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?xxml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||||
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Creation Date</key>
|
||||||
|
<date>2013-10-27T02:27:27Z</date>
|
||||||
|
<key>Creator</key>
|
||||||
|
<dict>
|
||||||
|
<key>Device Agent</key>
|
||||||
|
<string>iPhone/iPhone3,1</string>
|
||||||
|
<key>Generation Date</key>
|
||||||
|
<date>2013-10-27T07:02:27Z</date>
|
||||||
|
<key>Host Name</key>
|
||||||
|
<string>omrt104001</string>
|
||||||
|
<key>OS Agent</key>
|
||||||
|
<string>iOS/7.0.3</string>
|
||||||
|
<key>Software Agent</key>
|
||||||
|
<string>Day One (iOS)/1.11.4</string>
|
||||||
|
</dict>
|
||||||
|
<key>Entry Text</key>
|
||||||
|
<string>Some text.</string>
|
||||||
|
<key>Location</key>
|
||||||
|
<dict>
|
||||||
|
<key>Administrative Area</key>
|
||||||
|
<string>Östergötlands län</string>
|
||||||
|
<key>Country</key>
|
||||||
|
<string>Sverige</string>
|
||||||
|
<key>Latitude</key>
|
||||||
|
<real>58.383400000000000</real>
|
||||||
|
<key>Locality</key>
|
||||||
|
<string>City</string>
|
||||||
|
<key>Longitude</key>
|
||||||
|
<real>15.577170000000000</real>
|
||||||
|
<key>Place Name</key>
|
||||||
|
<string>Street</string>
|
||||||
|
</dict>
|
||||||
|
<key>Starred</key>
|
||||||
|
<false/>
|
||||||
|
<key>Time Zone</key>
|
||||||
|
<string>Europe/Stockholm</string>
|
||||||
|
<key>UUID</key>
|
||||||
|
<string>B40EE704E15846DE8D45C44118A4D511</string>
|
||||||
|
<key>Weather</key>
|
||||||
|
<dict>
|
||||||
|
<key>Celsius</key>
|
||||||
|
<string>12</string>
|
||||||
|
<key>Description</key>
|
||||||
|
<string>Clear</string>
|
||||||
|
<key>Fahrenheit</key>
|
||||||
|
<string>54</string>
|
||||||
|
<key>IconName</key>
|
||||||
|
<string>sunnyn.png</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,52 @@
|
||||||
|
<dict>
|
||||||
|
<key>Creation Date</key>
|
||||||
|
<date>2013-10-27T02:27:27Z</date>
|
||||||
|
<key>Creator</key>
|
||||||
|
<dict>
|
||||||
|
<key>Device Agent</key>
|
||||||
|
<string>iPhone/iPhone3,1</string>
|
||||||
|
<key>Generation Date</key>
|
||||||
|
<date>2013-10-27T07:02:27Z</date>
|
||||||
|
<key>Host Name</key>
|
||||||
|
<string>omrt104001</string>
|
||||||
|
<key>OS Agent</key>
|
||||||
|
<string>iOS/7.0.3</string>
|
||||||
|
<key>Software Agent</key>
|
||||||
|
<string>Day One (iOS)/1.11.4</string>
|
||||||
|
</dict>
|
||||||
|
<key>Entry Text</key>
|
||||||
|
<string>This is not a valid plist.</string>
|
||||||
|
<key>Location</key>
|
||||||
|
<dict>
|
||||||
|
<key>Administrative Area</key>
|
||||||
|
<string>Östergötlands län</string>
|
||||||
|
<key>Country</key>
|
||||||
|
<string>Sverige</string>
|
||||||
|
<key>Latitude</key>
|
||||||
|
<real>58.383400000000000</real>
|
||||||
|
<key>Locality</key>
|
||||||
|
<string>City</string>
|
||||||
|
<key>Longitude</key>
|
||||||
|
<real>15.577170000000000</real>
|
||||||
|
<key>Place Name</key>
|
||||||
|
<string>Street</string>
|
||||||
|
</dict>
|
||||||
|
<key>Starred</key>
|
||||||
|
<false/>
|
||||||
|
<key>Time Zone</key>
|
||||||
|
<string>Europe/Stockholm</string>
|
||||||
|
<key>UUID</key>
|
||||||
|
<string>B40EE704E15846DE8D45C44118A4D511</string>
|
||||||
|
<key>Weather</key>
|
||||||
|
<dict>
|
||||||
|
<key>Celsius</key>
|
||||||
|
<string>12</string>
|
||||||
|
<key>Description</key>
|
||||||
|
<string>Clear</string>
|
||||||
|
<key>Fahrenheit</key>
|
||||||
|
<string>54</string>
|
||||||
|
<key>IconName</key>
|
||||||
|
<string>sunnyn.png</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -20,3 +20,13 @@ Feature: Zapped bugs should stay dead.
|
||||||
When we run "jrnl 2013-11-30 15:42: Project Started."
|
When we run "jrnl 2013-11-30 15:42: Project Started."
|
||||||
Then we should see the message "Entry added"
|
Then we should see the message "Entry added"
|
||||||
and the journal should contain "2013-11-30 15:42 Project Started."
|
and the journal should contain "2013-11-30 15:42 Project Started."
|
||||||
|
|
||||||
|
Scenario: Loading entry with ambiguous time stamp
|
||||||
|
#https://github.com/maebert/jrnl/issues/153
|
||||||
|
Given we use the config "bug153.json"
|
||||||
|
When we run "jrnl -1"
|
||||||
|
Then we should get no error
|
||||||
|
and the output should be
|
||||||
|
"""
|
||||||
|
2013-10-27 03:27 Some text.
|
||||||
|
"""
|
||||||
|
|
|
@ -24,6 +24,7 @@ import plistlib
|
||||||
import pytz
|
import pytz
|
||||||
import uuid
|
import uuid
|
||||||
import tzlocal
|
import tzlocal
|
||||||
|
from xml.parsers.expat import ExpatError
|
||||||
|
|
||||||
|
|
||||||
class Journal(object):
|
class Journal(object):
|
||||||
|
@ -332,20 +333,24 @@ class DayOne(Journal):
|
||||||
self.entries = []
|
self.entries = []
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
with open(filename, 'rb') as plist_entry:
|
with open(filename, 'rb') as plist_entry:
|
||||||
dict_entry = plistlib.readPlist(plist_entry)
|
|
||||||
try:
|
try:
|
||||||
timezone = pytz.timezone(dict_entry['Time Zone'])
|
dict_entry = plistlib.readPlist(plist_entry)
|
||||||
except (KeyError, pytz.exceptions.UnknownTimeZoneError):
|
except ExpatError:
|
||||||
timezone = tzlocal.get_localzone()
|
pass
|
||||||
date = dict_entry['Creation Date']
|
else:
|
||||||
date = date + timezone.utcoffset(date)
|
try:
|
||||||
raw = dict_entry['Entry Text']
|
timezone = pytz.timezone(dict_entry['Time Zone'])
|
||||||
sep = re.search("[\n!?.]+", raw)
|
except (KeyError, pytz.exceptions.UnknownTimeZoneError):
|
||||||
title, body = (raw[:sep.end()], raw[sep.end():]) if sep else (raw, "")
|
timezone = tzlocal.get_localzone()
|
||||||
entry = Entry.Entry(self, date, title, body, starred=dict_entry["Starred"])
|
date = dict_entry['Creation Date']
|
||||||
entry.uuid = dict_entry["UUID"]
|
date = date + timezone.utcoffset(date, is_dst=False)
|
||||||
entry.tags = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
raw = dict_entry['Entry Text']
|
||||||
self.entries.append(entry)
|
sep = re.search("[\n!?.]+", raw)
|
||||||
|
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 = [self.config['tagsymbols'][0] + tag for tag in dict_entry.get("Tags", [])]
|
||||||
|
self.entries.append(entry)
|
||||||
self.sort()
|
self.sort()
|
||||||
|
|
||||||
def write(self):
|
def write(self):
|
||||||
|
|
|
@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
__title__ = 'jrnl'
|
__title__ = 'jrnl'
|
||||||
__version__ = '1.7.19'
|
__version__ = '1.7.20'
|
||||||
__author__ = 'Manuel Ebert'
|
__author__ = 'Manuel Ebert'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
||||||
|
|
|
@ -233,6 +233,9 @@ def run(manual_args=None):
|
||||||
install.save_config(original_config, config_path=CONFIG_PATH)
|
install.save_config(original_config, config_path=CONFIG_PATH)
|
||||||
|
|
||||||
elif args.edit:
|
elif args.edit:
|
||||||
|
if not config['editor']:
|
||||||
|
util.prompt(u"[You need to specify an editor in {0} to use the --edit function.]".format(CONFIG_PATH))
|
||||||
|
sys.exit(1)
|
||||||
other_entries = [e for e in old_entries if e not in journal.entries]
|
other_entries = [e for e in old_entries if e not in journal.entries]
|
||||||
# Edit
|
# Edit
|
||||||
old_num_entries = len(journal)
|
old_num_entries = len(journal)
|
||||||
|
|
Loading…
Add table
Reference in a new issue