From ef9444f78ac9780856094b7e670378e1dd766d4d Mon Sep 17 00:00:00 2001 From: Maruan Al-Shedivat Date: Thu, 20 Aug 2015 01:58:45 +0300 Subject: [PATCH] Bug fixes. --- jrnl/cli.py | 5 +++-- jrnl/install.py | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/jrnl/cli.py b/jrnl/cli.py index b88a75eb..200bd628 100644 --- a/jrnl/cli.py +++ b/jrnl/cli.py @@ -16,6 +16,7 @@ from . import plugins from .util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR import jrnl import argparse +import os import sys import logging @@ -160,9 +161,9 @@ def run(manual_args=None): sys.exit(1) # create a config entry for the new journal - journal_file_path = os.path.join(os.path.expanduser('.'), + default_file_path = os.path.join(os.path.abspath('.'), install.DEFAULT_JOURNAL_NAME) - config = install.create(journal_name, journal_file_path, config) + config = install.create(journal_name, default_file_path, config) sys.exit(0) # If the first textual argument points to a journal file, diff --git a/jrnl/install.py b/jrnl/install.py index 7543f286..0d653d1a 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -91,7 +91,7 @@ def load_or_install_jrnl(): log.debug('Configuration file not found, installing jrnl...') return install() -def create(journal_name, default_journal_file_path=None, config=None): +def create(journal_name, default_file_path=None, config=None): def autocomplete(text, state): expansions = glob.glob(os.path.expanduser(os.path.expandvars(text)) + '*') expansions = [e + "/" if os.path.isdir(e) else e for e in expansions] @@ -106,13 +106,12 @@ def create(journal_name, default_journal_file_path=None, config=None): config = default_config # Set up the default journal file path - if default_journal_file_path is None: - default_journal_file_path = JOURNAL_FILE_PATH + if default_file_path is None: + default_file_path = JOURNAL_FILE_PATH # Where to create the journal? - path_query = 'Path to your journal file (leave blank for {}): '.format(default_journal_file_path) - journal_path = util.py23_input(path_query).strip() or \ - default_journal_file_path + path_query = 'Path to your journal file (leave blank for {}): '.format(default_file_path) + journal_path = util.py23_input(path_query).strip() or default_file_path journal_path = os.path.expanduser(os.path.expandvars(journal_path)) config['journals'][journal_name] = {'journal': journal_path} @@ -129,7 +128,6 @@ def create(journal_name, default_journal_file_path=None, config=None): # Encrypt it? password = getpass.getpass("Enter password for journal (leave blank for no encryption): ") if password: - config['journals'][journal_name]['password'] = password config['journals'][journal_name]['encrypt'] = True if util.yesno("Do you want to store the password in your keychain?", default=True): util.set_keychain(journal_name, password) @@ -141,6 +139,8 @@ def create(journal_name, default_journal_file_path=None, config=None): PlainJournal._create(journal_path) save_config(config) + if password: + config['password'] = password return config def install():