Skip to content

Get rid of unicode-slugify extras #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,3 @@ jobs:
- name: Run tests
run: python setup.py test
- run: codecov

extras:
needs:
- readme
- lint
runs-on: ubuntu-latest
strategy:
matrix:
extras:
- slugify

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel codecov
python -m pip install -e .[${{ matrix.extras }}]
- name: Run tests
run: python setup.py test
- run: codecov
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Installation

.. code-block:: bash

pip install django-dynamic-filenames[slugify]
pip install django-dynamic-filenames

Samples
~~~~~~~
Expand Down
14 changes: 2 additions & 12 deletions dynamic_filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
import re
import uuid
from string import Formatter


def slugify(value):
try: # use unicode-slugify library if installed
from slugify import slugify as _slugify

return _slugify(value, only_ascii=True)
except ImportError:
from django.utils.text import slugify as _slugify

return _slugify(value, allow_unicode=False)
from django.utils.text import slugify


class SlugFormatter(Formatter):
Expand All @@ -24,7 +14,7 @@ def format_field(self, value, format_spec):
if precision:
precision = int(precision.lstrip("."))
if ftype == "slug":
return slugify(value)[:precision]
return slugify(value, allow_unicode=False)[:precision]
return super().format_field(value=value, format_spec=format_spec)


Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ tests_require =

[options.extras_require]
slugify =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for asking, but is there a reason to keep the empty extra requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to not break the installation right away in case someone was using slugify as extra dependency. But maybe it is actually better to get rid of it completely.

@nschlemm is this causing you issues, or it is just your observation?

unicode-slugify

[aliases]
test = pytest
Expand Down