#NEWLINE# def to_slug( value , incoming = None , errors = 'strict' ) : #NEWLINE# #INDENT# "Normalize string.\n\n    Convert to lowercase, remove non-word characters, and convert spaces\n    to hyphens.\n\n    Inspired by Django's `slugify` filter.\n\n    :param value: Text to slugify\n    :param incoming: Text's current encoding\n    :param errors: Errors handling policy. See here for valid\n        values http://docs.python.org/2/library/codecs.html\n    :returns: slugified unicode representation of `value`\n    :raises TypeError: If text is not an instance of str\n    " #NEWLINE# value = safe_decode ( value , incoming , errors ) #NEWLINE# value = unicodedata . normalize ( 'NFKD' , value ) . encode ( 'ascii' , 'ignore' ) . decode ( 'ascii' ) #NEWLINE# value = SLUGIFY_STRIP_RE . sub ( '' , value ) . strip ( ) . lower ( ) #NEWLINE# return SLUGIFY_HYPHENATE_RE . sub ( '-' , value )