Skip to content

Commit

Permalink
cmdline options
Browse files Browse the repository at this point in the history
  • Loading branch information
un33k committed Apr 27, 2022
1 parent 937779c commit c094c8a
Show file tree
Hide file tree
Showing 18 changed files with 574 additions and 150 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

# Run on push only for dev/sandbox
# Otherwise it may trigger concurrently `push & pull_request` on PRs.
on:
push:
branches:
- ci
- staging

jobs:
build:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]

steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coveralls --upgrade
- name: Run flake8
run: |
pip install flake8 --upgrade
flake8 --exclude=build --ignore=E501,F403,F401,E241,E225,E128 .
- name: Run pycodestyle
run: |
pip install pycodestyle --upgrade
pycodestyle --ignore=E128,E261,E225,E501,W605 slugify test.py setup.py
- name: Run test
run: |
coverage run --source=slugify test.py
- name: Coveralls
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: DEV

# Run on push only for dev/sandbox
# Otherwise it may trigger concurrently `push & pull_request` on PRs.
on:
push:
branches:
- sandbox
- dev

jobs:
build:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]

steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coveralls --upgrade
- name: Run flake8
run: |
pip install flake8 --upgrade
flake8 --exclude=build --ignore=E501,F403,F401,E241,E225,E128 .
- name: Run pycodestyle
run: |
pip install pycodestyle --upgrade
pycodestyle --ignore=E128,E261,E225,E501,W605 slugify test.py setup.py
- name: Run test
run: |
coverage run --source=slugify test.py
- name: Coveralls
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Main

# Run on push only for dev/sandbox
# Otherwise it may trigger concurrently `push & pull_request` on PRs.
on:
push:
branches:
- master

jobs:
build:
name: Python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3]

steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install coveralls --upgrade
- name: Run flake8
run: |
pip install flake8 --upgrade
flake8 --exclude=build --ignore=E501,F403,F401,E241,E225,E128 .
- name: Run pycodestyle
run: |
pip install pycodestyle --upgrade
pycodestyle --ignore=E128,E261,E225,E501,W605 slugify test.py setup.py
- name: Run test
run: |
coverage run --source=slugify test.py
- name: Coveralls
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 0 additions & 5 deletions .python-version

This file was deleted.

22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"python.linting.pylintEnabled": false,
"python.pythonPath": "/usr/bin/python3",
}
"cSpell.words": ["Neekman", "shch", "xlate"]
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 6.1.2

- Reintroduce the cli options

## 6.1.1

- Remove type hinting (temporarily)

## 6.1.0

- Add `allow_unicode` flag to allow unicode characters in the slug

## 6.0.1

- Rework regex_pattern to mean the opposite (disallowed chars instead of allowed)
- Thanks to @yyyyyyyan for the initial PR followed by the final PR by @mrezzamoradi

## 6.0.0

- Enable github action
- Remove tox, as we run the test on github action, the end users can refer to those test

## 5.0.2

- Enable twine publish
Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include CHANGELOG.md
include LICENSE
include README.md
include test.py
include CHANGELOG.md
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def slugify(
stopwords=(),
regex_pattern=None,
lowercase=True,
replacements=()
replacements=(),
allow_unicode=False
):
"""
Make a slug from the given text.
Expand All @@ -55,9 +56,10 @@ def slugify(
:param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order
:param separator (str): separator between words
:param stopwords (iterable): words to discount
:param regex_pattern (str): regex pattern for allowed characters
:param regex_pattern (str): regex pattern for disallowed characters
:param lowercase (bool): activate case sensitivity by setting it to False
:param replacements (iterable): list of replacement rules e.g. [['|', 'or'], ['%', 'percent']]
:param allow_unicode (bool): allow unicode characters
:return (str): slugify text
"""
```
Expand All @@ -75,6 +77,10 @@ txt = '影師嗎'
r = slugify(txt)
self.assertEqual(r, "ying-shi-ma")

txt = '影師嗎'
r = slugify(txt, allow_unicode=True)
self.assertEqual(r, "影師嗎")

txt = 'C\'est déjà l\'été.'
r = slugify(txt)
self.assertEqual(r, "c-est-deja-l-ete")
Expand Down Expand Up @@ -133,6 +139,14 @@ txt = 'ÜBER Über German Umlaut'
r = slugify(txt, replacements=[['Ü', 'UE'], ['ü', 'ue']])
self.assertEqual(r, "ueber-ueber-german-umlaut")

txt = 'i love 🦄'
r = slugify(txt, allow_unicode=True)
self.assertEqual(r, "i-love")

txt = 'i love 🦄'
r = slugify(txt, allow_unicode=True, regex_pattern=r'[^🦄]+')
self.assertEqual(r, "🦄")

```

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

# Running the tests

To run the tests against all environments:

tox

To run the tests against the current environment:

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

[status-image]: https://travis-ci.org/un33k/python-slugify.svg?branch=master
[status-link]: https://travis-ci.org/un33k/python-slugify
[status-image]: https://github.com/un33k/python-slugify/actions/workflows/ci.yml/badge.svg
[status-link]: https://github.com/un33k/python-slugify/actions/workflows/ci.yml
[version-image]: https://img.shields.io/pypi/v/python-slugify.svg
[version-link]: https://pypi.python.org/pypi/python-slugify
[coverage-image]: https://coveralls.io/repos/un33k/python-slugify/badge.svg
Expand Down
5 changes: 3 additions & 2 deletions dev.requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pycodestyle==2.7.0
twine==3.4.1
pycodestyle==2.8.0
twine==3.4.1
flake8==4.0.1
Loading

0 comments on commit c094c8a

Please sign in to comment.