#NEWLINE# def fix_filename( s ) : #NEWLINE# #INDENT# "fix string to be a 'good' filename.\n        This may be a more restrictive than the OS, but\n        avoids nasty cases." #NEWLINE# t = s . translate ( s . maketrans ( BAD_FILECHARS , GOOD_FILECHARS ) ) #NEWLINE# if ( t . count ( '.' ) > 1 ) : #NEWLINE# #INDENT# for i in range ( ( t . count ( '.' ) - 1 ) ) : #NEWLINE# #INDENT# idot = t . find ( '.' ) #NEWLINE# t = ( '%s_%s' % ( t [ : idot ] , t [ ( idot + 1 ) : ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# return t