diff options
| author | Val Neekman <val@neekware.com> | 2018-03-25 09:39:21 -0400 |
|---|---|---|
| committer | Val Neekman <val@neekware.com> | 2018-03-25 09:39:21 -0400 |
| commit | 8e360aed732fb0c902e78885c4be89e4048a2d2d (patch) | |
| tree | 51bb26eb4562a4e717330cb3e399576b3b435400 | |
| parent | 874fe140aa68ee1065e2170385f8c4ace5ac644a (diff) | |
| download | python-slugify-8e360aed732fb0c902e78885c4be89e4048a2d2d.tar.gz | |
support for text-unidecode
| -rw-r--r-- | .travis.yml | 10 | ||||
| -rw-r--r-- | CHANGELOG.md | 8 | ||||
| -rw-r--r-- | README.rst | 37 | ||||
| -rwxr-xr-x | pycodestyle.sh (renamed from pep8.sh) | 2 | ||||
| -rw-r--r-- | requirements_alt.txt (renamed from alt_requirements.txt) | 0 | ||||
| -rwxr-xr-x | setup.py | 2 | ||||
| -rw-r--r-- | slugify/__init__.py | 2 | ||||
| -rw-r--r-- | slugify/slugify.py | 4 | ||||
| -rw-r--r-- | test.py | 1 |
9 files changed, 35 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml index 737fa21..4bf2dd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,19 +11,19 @@ python: - pypy env: - - WITH_TEXTUNIDECODE=yes - - WITH_UNIDECODE=yes # this is redundant but otherwise travis will only trigger one build type + - SLUGIFY_USES_TEXT_UNIDECODE=yes + - SLUGIFY_USES_UNIDECODE=yes # dummy: tell travis to run more than one build types install: - pip install pip -U - - if [[ -z "${WITH_TEXTUNIDECODE}" ]]; then pip install -q -r requirements.txt; else pip install -q -r alt_requirements.txt; fi + - if [[ -z "${SLUGIFY_USES_TEXT_UNIDECODE}" ]]; then pip install -q -r requirements.txt; else pip install -q -r requirements_alt.txt; fi - pip install -e . - - pip install pep8 + - pip install pycodestyle - pip install coveralls - pip install https://github.com/un33k/pyflakes/tarball/master before_script: - - "bash pep8.sh" + - "bash pycodestyle.sh" - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pyflakes -x W slugify; fi script: coverage run --source=slugify test.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a16c72a..e292880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,16 @@ +## 1.2.5 + - Add support for using text-unidecode (@bolkedebruin) + - Switch to pycodestyle instead of pep8 + ## 1.2.4 - Remove build artifacts during packaging - Simplify the setup.py file (@reece) ## 1.2.3 + - Remove build artifacts during packaging + - Simplify the setup.py file (@reece) + +## 1.2.3 - Republish - possible corrupt 1.2.2 build ## 1.2.2 @@ -30,7 +30,7 @@ From sources via ``git``: $ git clone http://github.com/un33k/python-slugify $ cd python-slugify - $ python setup.py + $ python setup.py install From sources: @@ -39,7 +39,16 @@ From sources: $ wget https://github.com/un33k/python-slugify/zipball/master # unzip the downloaded file # cd into python-slugify-* directory - $ python setup.py + $ python setup.py install + +Note: + +By default *python-slugify* installs **unidecode** (GPL) for its decoding needs. + +Alternatively *python-slugify* can install and use **text-unidecode** (GPL & Perl Artistic) instead. This is done by setting up +an environment variable *SLUGIFY_USES_TEXT_UNIDECODE=yes* prior to installing and/or upgrading `python-slugify`. + +In cases where both **unidecode** and **text-unidecode** are installed, *python-slugify* always defaults to using **unidecode** regardless of the *SLUGIFY_USES_TEXT_UNIDECODE=yes* environment variable. How to use @@ -117,10 +126,6 @@ How to use r = slugify(txt, max_length=20, word_boundary=True, separator=".") self.assertEqual(r, "jaja.lol.mememeoo.a") - txt = 'jaja---lol-méméméoo--a' - r = slugify(txt, max_length=20, word_boundary=True, separator="ZZZZZZ") - self.assertEqual(r, "jajaZZZZZZlolZZZZZZmememeooZZZZZZa") - txt = 'one two three four five' r = slugify(txt, max_length=13, word_boundary=True, save_order=True) self.assertEqual(r, "one-two-three") @@ -186,6 +191,11 @@ License Released under a (`MIT`_) license. +**Note:** + +*python-slugify* relies on thirdparty **API** for decoding unicode strings. This dependency is kept at the public **API** ONLY in +order to ensure that *python-slugify* never becomes a **derivative work** of any other packages. MIT license holds. + Version ------- @@ -212,18 +222,3 @@ X.Y.Z Version .. _MIT: https://github.com/un33k/python-slugify/blob/master/LICENSE - -GPL ---- - -By default python-slugify depends on **unidecode** which is released under GPL. In case this is -a concern to you it is possible to install slugify with **text-unidecode** which is dual licensed -Perl Artistic and GPL. This can be done by: - -.. code:: bash - - $ export WITH_TEXTUNIDECODE=yes - -And then proceed with the normal installation instructions. Please note that this needs to be specified -for every upgrade. Also be aware that in case **unidecode* is present on the system python-slugify will -still default to using it. @@ -8,4 +8,4 @@ # -- E225 missing whitespace around operator # -- E501 line too long -pep8 --ignore=E128,E261,E225,E501 slugify test.py setup.py +pycodestyle --ignore=E128,E261,E225,E501 slugify test.py setup.py diff --git a/alt_requirements.txt b/requirements_alt.txt index 980e50a..980e50a 100644 --- a/alt_requirements.txt +++ b/requirements_alt.txt @@ -15,7 +15,7 @@ url = 'https://github.com/un33k/python-slugify' author = 'Val Neekman' author_email = 'info@neekware.com' license = 'MIT' -if "WITH_TEXTUNIDECODE" in os.environ: +if "SLUGIFY_USES_TEXT_UNIDECODE" in os.environ: install_requires = ['text-unidecode>=1.2'] else: install_requires = ['Unidecode>=0.04.16'] diff --git a/slugify/__init__.py b/slugify/__init__.py index 79e1d28..02393a1 100644 --- a/slugify/__init__.py +++ b/slugify/__init__.py @@ -3,4 +3,4 @@ from .slugify import * __author__ = 'Val Neekman @ Neekware Inc. [@vneekman]' __description__ = 'A Python slugify application that also handles Unicode' -__version__ = '1.2.4' +__version__ = '1.2.5' diff --git a/slugify/slugify.py b/slugify/slugify.py index 8619184..99afb7f 100644 --- a/slugify/slugify.py +++ b/slugify/slugify.py @@ -112,14 +112,14 @@ def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, w if decimal: try: text = DECIMAL_PATTERN.sub(lambda m: unichr(int(m.group(1))), text) - except: + except Exception: pass # hexadecimal character reference if hexadecimal: try: text = HEX_PATTERN.sub(lambda m: unichr(int(m.group(1), 16)), text) - except: + except Exception: pass # translate @@ -210,5 +210,6 @@ class TestUtils(unittest.TestCase): r = smart_truncate(txt, max_length=100, separator='_') self.assertEqual(r, txt) + if __name__ == '__main__': unittest.main() |
