Skip to main content

Python flexible slugify module

Project description

Python flexible slugify module

Install

pip install awesome-slugify

Function args

slugify

text                  # text for translate. position arg
max_length = None     # output string max length
separator = '-'       # separator string
capitalize = False    # if True upper first letter

Retuns translated text.

get_slugify

pretranslate = None               # function or dict for replace before translation
translate = unidecode.unidecode   # function for slugifying or None
safe_chars = ''                   # additional safe chars
# + slugify's keyword args

Returns slugify function.

Examples

from slugify import slugify, slugify_unicode, slugify_ru
from slugify import get_slugify


slugify('one kožušček')                       # one-kozuscek
slugify('one two three', separator='.')       # one.two.three
slugify('one two three four', max_length=12)  # one-two-four   (12 chars)
slugify('one TWO', capitalize=True)           # One-TWO

slugify('Я ♥ борщ')                           # Ia-borshch  (standard translation)
slugify_ru('Я ♥ борщ')                        # Ya-borsch   (alternative russian translation)
slugify_unicode('Я ♥ борщ')                   # Я-борщ      (sanitize only)

filename_slugify = get_slugify(safe_chars='-_.', separator='_')
filename_slugify(u'Дrаft №2.txt')             # Draft_2.txt

my_slugify = get_slugify(pretranslate={'я': 'i', '♥': 'love', 'щ': 'sch'}, separator='.')
my_slugify('Я ♥ борщ')                        # I.love.borsch  (custom translate)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awesome-slugify-1.2.1.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file awesome-slugify-1.2.1.tar.gz.

File metadata

File hashes

Hashes for awesome-slugify-1.2.1.tar.gz
Algorithm Hash digest
SHA256 e0ed05d13047c27379845a1fb633051ee0897e7b9ccc17b3de0f5d9a1ff18af8
MD5 d00efc042f49e3e2a7c073911c7963d0
BLAKE2b-256 1c478ec749cb3f862e9cd25f1ed82c2bfa6a2c68ee6a3a342325550362fc53f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page