mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Better utf8 support
This commit is contained in:
parent
8842b8589f
commit
884881546d
3 changed files with 13 additions and 6 deletions
|
@ -4,8 +4,9 @@ Changelog
|
||||||
### 1.0.4
|
### 1.0.4
|
||||||
|
|
||||||
* [Improved] Python 2.6 compatibility
|
* [Improved] Python 2.6 compatibility
|
||||||
|
* [Improved] Better utf-8 support
|
||||||
* [New] Python 3 compatibility
|
* [New] Python 3 compatibility
|
||||||
* [New] Respects the `XDG_CONFIG_HOME` environment variable for storing your configuration file
|
* [New] Respects the `XDG_CONFIG_HOME` environment variable for storing your configuration file (Thanks [evaryont](https://github.com/evaryont))
|
||||||
|
|
||||||
### 1.0.3 (April 17, 2013)
|
### 1.0.3 (April 17, 2013)
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,9 @@ class Journal(object):
|
||||||
Entries have the form (date, title, body)."""
|
Entries have the form (date, title, body)."""
|
||||||
filename = filename or self.config['journal']
|
filename = filename or self.config['journal']
|
||||||
journal = None
|
journal = None
|
||||||
with codecs.open(filename, "r", "utf-8") as f:
|
|
||||||
journal = f.read()
|
|
||||||
if self.config['encrypt']:
|
if self.config['encrypt']:
|
||||||
|
with open(filename, "rb") as f:
|
||||||
|
journal = f.read()
|
||||||
decrypted = None
|
decrypted = None
|
||||||
attempts = 0
|
attempts = 0
|
||||||
while decrypted is None:
|
while decrypted is None:
|
||||||
|
@ -121,6 +121,9 @@ class Journal(object):
|
||||||
print("Extremely wrong password.")
|
print("Extremely wrong password.")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
journal = decrypted
|
journal = decrypted
|
||||||
|
else:
|
||||||
|
with codecs.open(filename, "r", "utf-8") as f:
|
||||||
|
journal = f.read()
|
||||||
return journal
|
return journal
|
||||||
|
|
||||||
def parse(self, journal):
|
def parse(self, journal):
|
||||||
|
@ -181,8 +184,11 @@ class Journal(object):
|
||||||
journal = "\n".join([str(e) for e in self.entries])
|
journal = "\n".join([str(e) for e in self.entries])
|
||||||
if self.config['encrypt']:
|
if self.config['encrypt']:
|
||||||
journal = self._encrypt(journal)
|
journal = self._encrypt(journal)
|
||||||
with codecs.open(filename, 'w', "utf-8") as journal_file:
|
with open(filename, 'wb') as journal_file:
|
||||||
journal_file.write(journal)
|
journal_file.write(journal)
|
||||||
|
else:
|
||||||
|
with codecs.open(filename, 'w', "utf-8") as journal_file:
|
||||||
|
journal_file.write(journal)
|
||||||
|
|
||||||
def sort(self):
|
def sort(self):
|
||||||
"""Sorts the Journal's entries by date"""
|
"""Sorts the Journal's entries by date"""
|
||||||
|
|
|
@ -32,7 +32,7 @@ __author__ = 'Manuel Ebert, Stephan Gabler'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
|
|
||||||
xdg_config = os.environ.get('XDG_CONFIG_HOME')
|
xdg_config = os.environ.get('XDG_CONFIG_HOME')
|
||||||
CONFIG_PATH = os.path.join(xdg_config, "jrnl") if xdg_config else os.path.expanduser('~/.jrnl_config'))
|
CONFIG_PATH = os.path.join(xdg_config, "jrnl") if xdg_config else os.path.expanduser('~/.jrnl_config')
|
||||||
PYCRYPTO = install.module_exists("Crypto")
|
PYCRYPTO = install.module_exists("Crypto")
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
|
|
Loading…
Add table
Reference in a new issue