How to use the normality.constants.WS function in normality

To help you get started, we’ve selected a few normality examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pudo / normality / normality / cleaning.py View on Github external
def collapse_spaces(text):
    """Remove newlines, tabs and multiple spaces with single spaces."""
    if is_text(text):
        return COLLAPSE_RE.sub(WS, text).strip(WS)
github pudo / normality / normality / __init__.py View on Github external
def slugify(text, sep='-'):
    """A simple slug generator."""
    text = stringify(text)
    if text is None:
        return None
    text = text.replace(sep, WS)
    text = normalize(text, ascii=True)
    if text is None:
        return None
    return text.replace(WS, sep)
github pudo / normality / normality / paths.py View on Github external
def _safe_name(file_name, sep):
    """Convert the file name to ASCII and normalize the string."""
    file_name = stringify(file_name)
    if file_name is None:
        return
    file_name = ascii_text(file_name)
    file_name = category_replace(file_name, UNICODE_CATEGORIES)
    file_name = collapse_spaces(file_name)
    if file_name is None or not len(file_name):
        return
    return file_name.replace(WS, sep)
github pudo / normality / normality / __init__.py View on Github external
def slugify(text, sep='-'):
    """A simple slug generator."""
    text = stringify(text)
    if text is None:
        return None
    text = text.replace(sep, WS)
    text = normalize(text, ascii=True)
    if text is None:
        return None
    return text.replace(WS, sep)