mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Port slugify to Python3
This commit is contained in:
parent
1304e5ca82
commit
c3d6a38e45
6 changed files with 16 additions and 7 deletions
|
@ -4,6 +4,7 @@ Changelog
|
||||||
|
|
||||||
### 1.7 (December 22, 2013)
|
### 1.7 (December 22, 2013)
|
||||||
|
|
||||||
|
* __1.7.6__ Python 3 port for slugify
|
||||||
* __1.7.5__ Colorama is only needed on windows. Smaller fixes
|
* __1.7.5__ Colorama is only needed on windows. Smaller fixes
|
||||||
* __1.7.3__ Touches temporary files before opening them to allow more external editors.
|
* __1.7.3__ Touches temporary files before opening them to allow more external editors.
|
||||||
* __1.7.2__ Dateutil added to requirements.
|
* __1.7.2__ Dateutil added to requirements.
|
||||||
|
|
|
@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__title__ = 'jrnl'
|
__title__ = 'jrnl'
|
||||||
__version__ = '1.7.5'
|
__version__ = '1.7.6'
|
||||||
__author__ = 'Manuel Ebert'
|
__author__ = 'Manuel Ebert'
|
||||||
__license__ = 'MIT License'
|
__license__ = 'MIT License'
|
||||||
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert'
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
try: from slugify import slugify
|
|
||||||
except ImportError: import slugify
|
|
||||||
try: import simplejson as json
|
try: import simplejson as json
|
||||||
except ImportError: import json
|
except ImportError: import json
|
||||||
try: from .util import u
|
try: from .util import u, slugify
|
||||||
except (SystemError, ValueError): from util import u
|
except (SystemError, ValueError): from util import u, slugify
|
||||||
|
|
||||||
|
|
||||||
def get_tags_count(journal):
|
def get_tags_count(journal):
|
||||||
|
|
12
jrnl/util.py
12
jrnl/util.py
|
@ -15,6 +15,7 @@ import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
import codecs
|
import codecs
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
PY3 = sys.version_info[0] == 3
|
PY3 = sys.version_info[0] == 3
|
||||||
PY2 = sys.version_info[0] == 2
|
PY2 = sys.version_info[0] == 2
|
||||||
|
@ -144,3 +145,14 @@ def colorize(string):
|
||||||
"""Returns the string wrapped in cyan ANSI escape"""
|
"""Returns the string wrapped in cyan ANSI escape"""
|
||||||
return u"\033[36m{}\033[39m".format(string)
|
return u"\033[36m{}\033[39m".format(string)
|
||||||
|
|
||||||
|
def slugify(string):
|
||||||
|
"""Slugifies a string.
|
||||||
|
Based on public domain code from https://github.com/zacharyvoase/slugify
|
||||||
|
and ported to deal with all kinds of python 2 and 3 strings
|
||||||
|
"""
|
||||||
|
string = u(string)
|
||||||
|
ascii_string = str(unicodedata.normalize('NFKD', string).encode('ascii', 'ignore'))
|
||||||
|
no_punctuation = re.sub(r'[^\w\s-]', '', ascii_string).strip().lower()
|
||||||
|
slug = re.sub(r'[-\s]+', '-', no_punctuation)
|
||||||
|
return u(slug)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,5 @@ pytz >= 2013b
|
||||||
pycrypto >= 2.6
|
pycrypto >= 2.6
|
||||||
argparse==1.2.1
|
argparse==1.2.1
|
||||||
tzlocal == 1.0
|
tzlocal == 1.0
|
||||||
slugify==0.0.1
|
|
||||||
keyring==3.0.5
|
keyring==3.0.5
|
||||||
python-dateutil==2.2
|
python-dateutil==2.2
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -73,7 +73,6 @@ setup(
|
||||||
"parsedatetime>=1.1.2",
|
"parsedatetime>=1.1.2",
|
||||||
"pytz>=2013b",
|
"pytz>=2013b",
|
||||||
"tzlocal==1.0",
|
"tzlocal==1.0",
|
||||||
"slugify>=0.0.1",
|
|
||||||
"keyring>=3.3",
|
"keyring>=3.3",
|
||||||
"python-dateutil>=2.2"
|
"python-dateutil>=2.2"
|
||||||
] + [p for p, cond in conditional_dependencies.items() if cond],
|
] + [p for p, cond in conditional_dependencies.items() if cond],
|
||||||
|
|
Loading…
Add table
Reference in a new issue