(filename, extension=None)
return filename
Returns a filename with FAT32-, NTFS- and HFS+-illegal characters removed.

    Unicode or bytestring datatype of filename is preserved.

    >>> safe_filename(u'spam*?: 𐍃𐍀𐌰𐌼-&.txt')
    u'spam 𐍃𐍀𐌰𐌼-&.txt'
Returns a filename with FAT32-, NTFS- and HFS+-illegal characters removed.
Returns a filename with FAT32 - NTFS - and HFS + - illegal characters removed .
def safe_filename(filename, extension=None):
    """
    Returns a filename with FAT32-, NTFS- and HFS+-illegal characters removed.

    Unicode or bytestring datatype of filename is preserved.

    >>> safe_filename(u'spam*?: 𐍃𐍀𐌰𐌼-&.txt')
    u'spam 𐍃𐍀𐌰𐌼-&.txt'
    """
    filename = filename if isinstance(filename, str) else filename.decode('utf8')
    if extension is not None:
        filename = "{}.{}".format(filename, extension)
    unsafe_chars = ':*?"<>|/\\\r\n'
    for c in unsafe_chars:
        filename = filename.replace(c, '')
    return filename
def safe_filename ( filename , extension = None ) : filename = filename if isinstance ( filename , str ) else filename . decode ( 'utf8' ) if extension is not None : filename = "{}.{}" . format ( filename , extension ) unsafe_chars = ':*?"<>|/\\\r\n' for c in unsafe_chars : filename = filename . replace ( c , '' ) return filename