def get_filename_safe_string(string):
invalid_filename_chars = ['<STR_LIT:\\>', '<STR_LIT:/>', '<STR_LIT::>', '<STR_LIT:">', '<STR_LIT:*>', '<STR_LIT:?>', '<STR_LIT:|>', '<STR_LIT:\n>',<EOL>'<STR_LIT:\r>']<EOL>if string is None:<EOL><INDENT>string = "<STR_LIT:None>"<EOL><DEDENT>for char in invalid_filename_chars:<EOL><INDENT>string = string.replace(char, "<STR_LIT>")<EOL><DEDENT>string = string.rstrip("<STR_LIT:.>")<EOL>return string<EOL>
Converts a string to a string that is safe for a filename
Args:
    string (str): A string to make safe for a filename

Returns:
    str: A string safe for a filename