mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Fixed bug when using slugify
slugify requires unicode input Signed-off-by: Aniket Pant <me@aniketpant.com>
This commit is contained in:
parent
d3958316f2
commit
99fa0fd4f0
1 changed files with 3 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import re
|
||||
import os
|
||||
try: from slugify import slugify
|
||||
except ImportError: import slugify
|
||||
|
@ -43,7 +42,7 @@ def to_txt(journal, output):
|
|||
def to_files(journal, output):
|
||||
"""Turns your journal into separate files for each entry."""
|
||||
if output is False:
|
||||
output = os.path.expanduser('~/journal/*.txt') # default path
|
||||
output = journal.config['folder'] + "*.txt" # default path
|
||||
path, extension = os.path.splitext(os.path.expanduser(output))
|
||||
head, tail = os.path.split(path)
|
||||
if tail == '*': # if wildcard is specified
|
||||
|
@ -52,13 +51,13 @@ def to_files(journal, output):
|
|||
os.makedirs(path)
|
||||
for e in journal.entries:
|
||||
date = e.date.strftime('%Y-%m-%d')
|
||||
title = slugify(e.title)
|
||||
title = slugify(unicode(e.title))
|
||||
filename = date + '-' + title
|
||||
result = str(e)
|
||||
fullpath = path + filename + extension
|
||||
print fullpath
|
||||
write_file(result, fullpath)
|
||||
return ("Journal exported to '" + path + "'")
|
||||
return ("Journal exported")
|
||||
|
||||
def write_file(content, path):
|
||||
"""Writes content to the file provided"""
|
||||
|
|
Loading…
Add table
Reference in a new issue