summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Ebert <manuel@1450.me>2014-11-06 11:33:36 +0100
committerManuel Ebert <manuel@1450.me>2014-11-06 11:33:36 +0100
commitb45e52f74340fc29544a1d53c89ef7cbf186151a (patch)
tree908b470d01d9facf1794f13316ad61add9e6841e
parentacf41a153ad01c923f1afa230bde4544eda463ec (diff)
parent474bf0a71abd72b9c713f41aeb4be5c648f3c30f (diff)
Merge pull request #304 from maebert/unicode-fixes1.9.7
Unicode fixes
-rw-r--r--CHANGELOG.md1
-rw-r--r--features/regression.feature7
-rw-r--r--features/steps/core.py11
-rw-r--r--jrnl/__init__.py2
-rw-r--r--jrnl/util.py4
5 files changed, 16 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d513a596..0f0379f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ Changelog
### 1.9 (July 21, 2014)
+* __1.9.7__ Fixes writing non-ascii entries on the prompt
* __1.9.6__ Fuzzy time parsing improvements (thanks to @pcarranza)
* __1.9.5__ Multi-word tags for DayOne Journals
* __1.9.4__ Fixed: Order of journal entries in file correct after --edit'ing
diff --git a/features/regression.feature b/features/regression.feature
index 1672afb4..f975a4b1 100644
--- a/features/regression.feature
+++ b/features/regression.feature
@@ -59,3 +59,10 @@ Feature: Zapped bugs should stay dead.
2014-04-24 09:00 Ran 6.2 miles today in 1:02:03.
| I'm feeling sore because I forgot to stretch.
"""
+
+ Scenario: Writing an entry at the prompt with non-ascii characters
+ # https://github.com/maebert/jrnl/issues/295
+ Given we use the config "basic.json"
+ When we run "jrnl" and enter "Crème brûlée & Mötorhead"
+ Then we should get no error
+ and the journal should contain "Crème brûlée & Mötorhead"
diff --git a/features/steps/core.py b/features/steps/core.py
index 9b0679e0..d0ea8460 100644
--- a/features/steps/core.py
+++ b/features/steps/core.py
@@ -2,9 +2,8 @@ from behave import *
from jrnl import cli, Journal, util
from dateutil import parser as date_parser
import os
-import sys
+import codecs
import json
-import pytz
import keyring
keyring.set_keyring(keyring.backends.file.PlaintextKeyring())
try:
@@ -30,7 +29,7 @@ def _parse_args(command):
def read_journal(journal_name="default"):
with open(cli.CONFIG_PATH) as config_file:
config = json.load(config_file)
- with open(config['journals'][journal_name]) as journal_file:
+ with codecs.open(config['journals'][journal_name], 'r', 'utf-8') as journal_file:
journal = journal_file.read()
return journal
@@ -57,7 +56,7 @@ def run_with_input(context, command, inputs=None):
buffer = StringIO(text.strip())
util.STDIN = buffer
try:
- cli.run(args or None)
+ cli.run(args)
context.exit_status = 0
except SystemExit as e:
context.exit_status = e.code
@@ -66,7 +65,7 @@ def run_with_input(context, command, inputs=None):
def run(context, command):
args = _parse_args(command)
try:
- cli.run(args or None)
+ cli.run(args)
context.exit_status = 0
except SystemExit as e:
context.exit_status = e.code
@@ -184,7 +183,7 @@ def config_var(context, key, value, journal=None):
@then('the journal should have {number:d} entry')
@then('journal "{journal_name}" should have {number:d} entries')
@then('journal "{journal_name}" should have {number:d} entry')
-def check_journal_content(context, number, journal_name="default"):
+def check_num_entries(context, number, journal_name="default"):
journal = open_journal(journal_name)
assert len(journal.entries) == number
diff --git a/jrnl/__init__.py b/jrnl/__init__.py
index 062ca255..29a9cef8 100644
--- a/jrnl/__init__.py
+++ b/jrnl/__init__.py
@@ -8,7 +8,7 @@ jrnl is a simple journal application for your command line.
from __future__ import absolute_import
__title__ = 'jrnl'
-__version__ = '1.9.6'
+__version__ = '1.9.7'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
diff --git a/jrnl/util.py b/jrnl/util.py
index 49a2b467..db8b0af7 100644
--- a/jrnl/util.py
+++ b/jrnl/util.py
@@ -79,11 +79,11 @@ def prompt(msg):
def py23_input(msg=""):
prompt(msg)
- return STDIN.readline().strip()
+ return u(STDIN.readline()).strip()
def py23_read(msg=""):
prompt(msg)
- return STDIN.read()
+ return u(STDIN.read())
def yesno(prompt, default=True):
prompt = prompt.strip() + (" [Y/n]" if default else " [y/N]")