From 57dc3808c14dbeab74a16959b3319cf0eeb0a141 Mon Sep 17 00:00:00 2001 From: seinfield Date: Sat, 6 Dec 2014 06:16:31 -0500 Subject: [PATCH 1/5] Update Journal.py --- jrnl/Journal.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 92a6774f..4da5821a 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -112,6 +112,18 @@ class Journal(object): def _parse(self, journal_txt): """Parses a journal that's stored in a string and returns a list of entries""" + def get_date_length(myline): + j='' + print 'myproc line is: ' + myline + for i in [x for x in myline.split(' ') ]: + try: + dateutil.parser.parse(j+' ' +i) + j=j+' ' +i + except: + break + print 'j is ' + j + return len(j.strip()) + # Entries start with a line that looks like 'date title' - let's figure out how # long the date will be by constructing one date_length = len(datetime.today().strftime(self.config['timeformat'])) @@ -123,6 +135,7 @@ class Journal(object): for line in journal_txt.splitlines(): line = line.rstrip() try: + date_length=get_date_length(line) # try to parse line as date => new entry begins new_date = datetime.strptime(line[:date_length], self.config['timeformat']) From 0affd5749fa75a19889d335e65c6bcc31d544f2a Mon Sep 17 00:00:00 2001 From: seinfield Date: Sat, 6 Dec 2014 06:27:37 -0500 Subject: [PATCH 2/5] Update Journal.py --- jrnl/Journal.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 4da5821a..d4b38ec7 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -8,6 +8,7 @@ from . import time import codecs import re from datetime import datetime +import dateutil.parser import sys try: from Crypto.Cipher import AES From 5aabbb781289188c613815940de137204e781221 Mon Sep 17 00:00:00 2001 From: seinfield Date: Sat, 6 Dec 2014 06:33:13 -0500 Subject: [PATCH 3/5] Update Journal.py --- jrnl/Journal.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index d4b38ec7..2a56a9d9 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -115,14 +115,12 @@ class Journal(object): def get_date_length(myline): j='' - print 'myproc line is: ' + myline for i in [x for x in myline.split(' ') ]: try: dateutil.parser.parse(j+' ' +i) j=j+' ' +i except: break - print 'j is ' + j return len(j.strip()) # Entries start with a line that looks like 'date title' - let's figure out how From 319345b5d47a44c9f1d90afa81a49ae88e7ebff7 Mon Sep 17 00:00:00 2001 From: seinfield Date: Sat, 6 Dec 2014 08:32:09 -0500 Subject: [PATCH 4/5] fix issue #316 Added extra check to make sure that the file specified is the same as in the configuration. If yes, then flip the encrypt flag. --- jrnl/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jrnl/cli.py b/jrnl/cli.py index 90feda09..35764734 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -256,14 +256,14 @@ def run(manual_args=None): elif args.encrypt is not False: encrypt(journal, filename=args.encrypt) # Not encrypting to a separate file: update config! - if not args.encrypt: + if not args.encrypt or args.encrypt == config['journal']: update_config(original_config, {"encrypt": True}, journal_name, force_local=True) install.save_config(original_config, config_path=CONFIG_PATH) elif args.decrypt is not False: decrypt(journal, filename=args.decrypt) # Not decrypting to a separate file: update config! - if not args.decrypt: + if not args.decrypt or args.decrypt == config['journal']: update_config(original_config, {"encrypt": False}, journal_name, force_local=True) install.save_config(original_config, config_path=CONFIG_PATH) From 62ab6d36ff673eb2eb7d7ba90a1ce98ca88ccff1 Mon Sep 17 00:00:00 2001 From: lmckiwo Date: Sat, 6 Dec 2014 08:42:54 -0500 Subject: [PATCH 5/5] udpated variable name and spacing --- jrnl/Journal.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 2a56a9d9..f562a4c7 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -114,14 +114,14 @@ class Journal(object): """Parses a journal that's stored in a string and returns a list of entries""" def get_date_length(myline): - j='' + tmpdate='' for i in [x for x in myline.split(' ') ]: try: - dateutil.parser.parse(j+' ' +i) - j=j+' ' +i + dateutil.parser.parse(tmpdate + ' ' + i) + tmpdate = tmpdate + ' ' + i except: break - return len(j.strip()) + return len(tmpdate.strip()) # Entries start with a line that looks like 'date title' - let's figure out how # long the date will be by constructing one