mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 19:48:31 +02:00
Updated docs from master
This commit is contained in:
parent
134d3dc173
commit
377c8524ca
5 changed files with 14 additions and 25 deletions
|
@ -56,7 +56,7 @@ Viewing
|
||||||
|
|
||||||
jrnl -n 10
|
jrnl -n 10
|
||||||
|
|
||||||
will list you the ten latest entries, ::
|
will list you the ten latest entries (if you're lazy, ``jrnl -10`` will do the same), ::
|
||||||
|
|
||||||
jrnl -from "last year" -until march
|
jrnl -from "last year" -until march
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import hashlib
|
||||||
import plistlib
|
import plistlib
|
||||||
import pytz
|
import pytz
|
||||||
import uuid
|
import uuid
|
||||||
|
import tzlocal
|
||||||
|
|
||||||
class Journal(object):
|
class Journal(object):
|
||||||
def __init__(self, name='default', **kwargs):
|
def __init__(self, name='default', **kwargs):
|
||||||
|
@ -333,7 +334,7 @@ class DayOne(Journal):
|
||||||
try:
|
try:
|
||||||
timezone = pytz.timezone(dict_entry['Time Zone'])
|
timezone = pytz.timezone(dict_entry['Time Zone'])
|
||||||
except (KeyError, pytz.exceptions.UnknownTimeZoneError):
|
except (KeyError, pytz.exceptions.UnknownTimeZoneError):
|
||||||
timezone = pytz.timezone(util.get_local_timezone())
|
timezone = tzlocal.get_localzone()
|
||||||
date = dict_entry['Creation Date']
|
date = dict_entry['Creation Date']
|
||||||
date = date + timezone.utcoffset(date)
|
date = date + timezone.utcoffset(date)
|
||||||
raw = dict_entry['Entry Text']
|
raw = dict_entry['Entry Text']
|
||||||
|
@ -357,7 +358,7 @@ class DayOne(Journal):
|
||||||
'Creation Date': utc_time,
|
'Creation Date': utc_time,
|
||||||
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
'Starred': entry.starred if hasattr(entry, 'starred') else False,
|
||||||
'Entry Text': entry.title+"\n"+entry.body,
|
'Entry Text': entry.title+"\n"+entry.body,
|
||||||
'Time Zone': util.get_local_timezone(),
|
'Time Zone': str(tzlocal.get_localzone()),
|
||||||
'UUID': entry.uuid,
|
'UUID': entry.uuid,
|
||||||
'Tags': [tag.strip(self.config['tagsymbols']) for tag in entry.tags]
|
'Tags': [tag.strip(self.config['tagsymbols']) for tag in entry.tags]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.9'
|
__version__ = '1.7.10'
|
||||||
__author__ = 'Manuel Ebert'
|
__author__ = 'Manuel Ebert'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
||||||
|
|
12
jrnl/cli.py
12
jrnl/cli.py
|
@ -35,7 +35,7 @@ def parse_args(args=None):
|
||||||
reading.add_argument('-until', '-to', dest='end_date', metavar="DATE", help='View entries before this date')
|
reading.add_argument('-until', '-to', dest='end_date', metavar="DATE", help='View entries before this date')
|
||||||
reading.add_argument('-and', dest='strict', action="store_true", help='Filter by tags using AND (default: OR)')
|
reading.add_argument('-and', dest='strict', action="store_true", help='Filter by tags using AND (default: OR)')
|
||||||
reading.add_argument('-starred', dest='starred', action="store_true", help='Show only starred entries')
|
reading.add_argument('-starred', dest='starred', action="store_true", help='Show only starred entries')
|
||||||
reading.add_argument('-n', dest='limit', default=None, metavar="N", help='Shows the last n entries matching the filter', nargs="?", type=int)
|
reading.add_argument('-n', dest='limit', default=None, metavar="N", help="Shows the last n entries matching the filter. '-n 3' and '-3' have the same effect.", nargs="?", type=int)
|
||||||
|
|
||||||
exporting = parser.add_argument_group('Export / Import', 'Options for transmogrifying your journal')
|
exporting = parser.add_argument_group('Export / Import', 'Options for transmogrifying your journal')
|
||||||
exporting.add_argument('--short', dest='short', action="store_true", help='Show only titles or line containing the search tags')
|
exporting.add_argument('--short', dest='short', action="store_true", help='Show only titles or line containing the search tags')
|
||||||
|
@ -119,13 +119,19 @@ def run(manual_args=None):
|
||||||
util.prompt("According to your jrnl_conf, your journal is encrypted, however PyCrypto was not found. To open your journal, install the PyCrypto package from http://www.pycrypto.org.")
|
util.prompt("According to your jrnl_conf, your journal is encrypted, however PyCrypto was not found. To open your journal, install the PyCrypto package from http://www.pycrypto.org.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# If the first textual argument points to a journal file,
|
# If the first textual argument points to a journal file,
|
||||||
# use this!
|
# use this!
|
||||||
journal_name = args.text[0] if (args.text and args.text[0] in config['journals']) else 'default'
|
journal_name = args.text[0] if (args.text and args.text[0] in config['journals']) else 'default'
|
||||||
if journal_name is not 'default':
|
if journal_name is not 'default':
|
||||||
args.text = args.text[1:]
|
args.text = args.text[1:]
|
||||||
|
# If the first remaining argument looks like e.g. '-3', interpret that as a limiter
|
||||||
|
if not args.limit and args.text and args.text[0].startswith("-"):
|
||||||
|
try:
|
||||||
|
args.limit = int(args.text[0].lstrip("-"))
|
||||||
|
args.text = args.text[1:]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
journal_conf = config['journals'].get(journal_name)
|
journal_conf = config['journals'].get(journal_name)
|
||||||
if type(journal_conf) is dict: # We can override the default config on a by-journal basis
|
if type(journal_conf) is dict: # We can override the default config on a by-journal basis
|
||||||
config.update(journal_conf)
|
config.update(journal_conf)
|
||||||
|
|
18
jrnl/util.py
18
jrnl/util.py
|
@ -88,24 +88,6 @@ def yesno(prompt, default=True):
|
||||||
raw = py23_input(prompt)
|
raw = py23_input(prompt)
|
||||||
return {'y': True, 'n': False}.get(raw.lower(), default)
|
return {'y': True, 'n': False}.get(raw.lower(), default)
|
||||||
|
|
||||||
def get_local_timezone():
|
|
||||||
"""Returns the Olson identifier of the local timezone.
|
|
||||||
In a happy world, tzlocal.get_localzone would do this, but there's a bug on OS X
|
|
||||||
that prevents that right now: https://github.com/regebro/tzlocal/issues/6"""
|
|
||||||
global __cached_tz
|
|
||||||
if not __cached_tz and "darwin" in sys.platform:
|
|
||||||
__cached_tz = os.popen("systemsetup -gettimezone").read().replace("Time Zone: ", "").strip()
|
|
||||||
if not __cached_tz or __cached_tz not in pytz.all_timezones_set:
|
|
||||||
link = os.readlink("/etc/localtime")
|
|
||||||
# This is something like /usr/share/zoneinfo/America/Los_Angeles.
|
|
||||||
# Find second / from right and take the substring
|
|
||||||
__cached_tz = link[link.rfind('/', 0, link.rfind('/'))+1:]
|
|
||||||
elif not __cached_tz:
|
|
||||||
__cached_tz = str(get_localzone())
|
|
||||||
if not __cached_tz or __cached_tz not in pytz.all_timezones_set:
|
|
||||||
__cached_tz = "UTC"
|
|
||||||
return __cached_tz
|
|
||||||
|
|
||||||
def load_and_fix_json(json_path):
|
def load_and_fix_json(json_path):
|
||||||
"""Tries to load a json object from a file.
|
"""Tries to load a json object from a file.
|
||||||
If that fails, tries to fix common errors (no or extra , at end of the line).
|
If that fails, tries to fix common errors (no or extra , at end of the line).
|
||||||
|
|
Loading…
Add table
Reference in a new issue