def slugify(value):
    """
    @type value: str
    """
    sysglob = SystemGlobals()
    hvalue = str(value)

    if hvalue in sysglob.g_slugified_unicode_lut:
        return sysglob.g_slugified_unicode_lut[hvalue]

    value = value.lower().replace("\\", "").replace("/", "")
    value = value.strip()
    slug = ""

    if sysglob.g_safe_alphabet:
        safechars = sysglob.g_safe_alphabet
    else:
        safechars = set(get_safe_alphabet())
    try:
        value = str(value)
    except UnicodeError:
        value = str(value)

    safechars = list(safechars)
    safechars.remove(" ")
    safechars = tuple(safechars)

    for c in value:
        if c in safechars:
            slug += c
        else:
            if isinstance(c, str):
                # noinspection PyArgumentEqualDefault #                                                                                                                                            after keyword 0
                c = c.encode()

            c64 = base64.encodebytes(c)
            slug += c64.decode("utf-8").strip().rstrip("=")

    retval = slug.lower()
    sysglob.g_slugified_unicode_lut[hvalue] = retval
    return retval
def slugify ( value ) : sysglob = SystemGlobals ( ) hvalue = str ( value ) if hvalue in sysglob . g_slugified_unicode_lut : return sysglob . g_slugified_unicode_lut [ hvalue ] value = value . lower ( ) . replace ( "\\" , "" ) . replace ( "/" , "" ) value = value . strip ( ) slug = "" if sysglob . g_safe_alphabet : safechars = sysglob . g_safe_alphabet else : safechars = set ( get_safe_alphabet ( ) ) try : value = str ( value ) except UnicodeError : value = str ( value ) safechars = list ( safechars ) safechars . remove ( " " ) safechars = tuple ( safechars ) for c in value : if c in safechars : slug += c else : if isinstance ( c , str ) : c = c . encode ( ) c64 = base64 . encodebytes ( c ) slug += c64 . decode ( "utf-8" ) . strip ( ) . rstrip ( "=" ) retval = slug . lower ( ) sysglob . g_slugified_unicode_lut [ hvalue ] = retval return retval
@type value: str