Skip to content

Commit c094c8a

Browse files
committed
cmdline options
1 parent 937779c commit c094c8a

18 files changed

Lines changed: 574 additions & 150 deletions

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
# Run on push only for dev/sandbox
4+
# Otherwise it may trigger concurrently `push & pull_request` on PRs.
5+
on:
6+
push:
7+
branches:
8+
- ci
9+
- staging
10+
11+
jobs:
12+
build:
13+
name: Python ${{ matrix.python }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: setup python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -e .
29+
pip install coveralls --upgrade
30+
- name: Run flake8
31+
run: |
32+
pip install flake8 --upgrade
33+
flake8 --exclude=build --ignore=E501,F403,F401,E241,E225,E128 .
34+
- name: Run pycodestyle
35+
run: |
36+
pip install pycodestyle --upgrade
37+
pycodestyle --ignore=E128,E261,E225,E501,W605 slugify test.py setup.py
38+
- name: Run test
39+
run: |
40+
coverage run --source=slugify test.py
41+
- name: Coveralls
42+
run: coveralls --service=github
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dev.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: DEV
2+
3+
# Run on push only for dev/sandbox
4+
# Otherwise it may trigger concurrently `push & pull_request` on PRs.
5+
on:
6+
push:
7+
branches:
8+
- sandbox
9+
- dev
10+
11+
jobs:
12+
build:
13+
name: Python ${{ matrix.python }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: setup python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -e .
29+
pip install coveralls --upgrade
30+
- name: Run flake8
31+
run: |
32+
pip install flake8 --upgrade
33+
flake8 --exclude=build --ignore=E501,F403,F401,E241,E225,E128 .
34+
- name: Run pycodestyle
35+
run: |
36+
pip install pycodestyle --upgrade
37+
pycodestyle --ignore=E128,E261,E225,E501,W605 slugify test.py setup.py
38+
- name: Run test
39+
run: |
40+
coverage run --source=slugify test.py
41+
- name: Coveralls
42+
run: coveralls --service=github
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Main
2+
3+
# Run on push only for dev/sandbox
4+
# Otherwise it may trigger concurrently `push & pull_request` on PRs.
5+
on:
6+
push:
7+
branches:
8+
- master
9+
10+
jobs:
11+
build:
12+
name: Python ${{ matrix.python }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: setup python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python }}
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e .
28+
pip install coveralls --upgrade
29+
- name: Run flake8
30+
run: |
31+
pip install flake8 --upgrade
32+
flake8 --exclude=build --ignore=E501,F403,F401,E241,E225,E128 .
33+
- name: Run pycodestyle
34+
run: |
35+
pip install pycodestyle --upgrade
36+
pycodestyle --ignore=E128,E261,E225,E501,W605 slugify test.py setup.py
37+
- name: Run test
38+
run: |
39+
coverage run --source=slugify test.py
40+
- name: Coveralls
41+
run: coveralls --service=github
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.python-version

Lines changed: 0 additions & 5 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"python.linting.pylintEnabled": false,
33
"python.pythonPath": "/usr/bin/python3",
4-
}
4+
"cSpell.words": ["Neekman", "shch", "xlate"]
5+
}

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## 6.1.2
2+
3+
- Reintroduce the cli options
4+
5+
## 6.1.1
6+
7+
- Remove type hinting (temporarily)
8+
9+
## 6.1.0
10+
11+
- Add `allow_unicode` flag to allow unicode characters in the slug
12+
13+
## 6.0.1
14+
15+
- Rework regex_pattern to mean the opposite (disallowed chars instead of allowed)
16+
- Thanks to @yyyyyyyan for the initial PR followed by the final PR by @mrezzamoradi
17+
18+
## 6.0.0
19+
20+
- Enable github action
21+
- Remove tox, as we run the test on github action, the end users can refer to those test
22+
123
## 5.0.2
224

325
- Enable twine publish

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
include CHANGELOG.md
21
include LICENSE
32
include README.md
4-
include test.py
3+
include CHANGELOG.md

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def slugify(
4242
stopwords=(),
4343
regex_pattern=None,
4444
lowercase=True,
45-
replacements=()
45+
replacements=(),
46+
allow_unicode=False
4647
):
4748
"""
4849
Make a slug from the given text.
@@ -55,9 +56,10 @@ def slugify(
5556
:param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order
5657
:param separator (str): separator between words
5758
:param stopwords (iterable): words to discount
58-
:param regex_pattern (str): regex pattern for allowed characters
59+
:param regex_pattern (str): regex pattern for disallowed characters
5960
:param lowercase (bool): activate case sensitivity by setting it to False
6061
:param replacements (iterable): list of replacement rules e.g. [['|', 'or'], ['%', 'percent']]
62+
:param allow_unicode (bool): allow unicode characters
6163
:return (str): slugify text
6264
"""
6365
```
@@ -75,6 +77,10 @@ txt = '影師嗎'
7577
r = slugify(txt)
7678
self.assertEqual(r, "ying-shi-ma")
7779

80+
txt = '影師嗎'
81+
r = slugify(txt, allow_unicode=True)
82+
self.assertEqual(r, "影師嗎")
83+
7884
txt = 'C\'est déjà l\'été.'
7985
r = slugify(txt)
8086
self.assertEqual(r, "c-est-deja-l-ete")
@@ -133,6 +139,14 @@ txt = 'ÜBER Über German Umlaut'
133139
r = slugify(txt, replacements=[['Ü', 'UE'], ['ü', 'ue']])
134140
self.assertEqual(r, "ueber-ueber-german-umlaut")
135141

142+
txt = 'i love 🦄'
143+
r = slugify(txt, allow_unicode=True)
144+
self.assertEqual(r, "i-love")
145+
146+
txt = 'i love 🦄'
147+
r = slugify(txt, allow_unicode=True, regex_pattern=r'[^🦄]+')
148+
self.assertEqual(r, "🦄")
149+
136150
```
137151

138152
For more examples, have a look at the [test.py](test.py) file.
@@ -164,10 +178,6 @@ quick-brown-fox-jumps-over-lazy-dog
164178

165179
# Running the tests
166180

167-
To run the tests against all environments:
168-
169-
tox
170-
171181
To run the tests against the current environment:
172182

173183
python test.py
@@ -188,8 +198,8 @@ X.Y.Z Version
188198
`MINOR` version -- when you add functionality in a backwards-compatible manner, and
189199
`PATCH` version -- when you make backwards-compatible bug fixes.
190200

191-
[status-image]: https://travis-ci.org/un33k/python-slugify.svg?branch=master
192-
[status-link]: https://travis-ci.org/un33k/python-slugify
201+
[status-image]: https://github.com/un33k/python-slugify/actions/workflows/ci.yml/badge.svg
202+
[status-link]: https://github.com/un33k/python-slugify/actions/workflows/ci.yml
193203
[version-image]: https://img.shields.io/pypi/v/python-slugify.svg
194204
[version-link]: https://pypi.python.org/pypi/python-slugify
195205
[coverage-image]: https://coveralls.io/repos/un33k/python-slugify/badge.svg

dev.requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
pycodestyle==2.7.0
2-
twine==3.4.1
1+
pycodestyle==2.8.0
2+
twine==3.4.1
3+
flake8==4.0.1

0 commit comments

Comments
 (0)