def sanitize_win_path_string(winpath):
 intab = '<>:|?*'
 outtab = ('_' * len(intab))
 trantab = (''.maketrans(intab, outtab) if six.PY3 else string.maketrans(intab, outtab))
 if isinstance(winpath, str):
  winpath = winpath.translate(trantab)
 elif isinstance(winpath, six.text_type):
  winpath = winpath.translate(dict(((ord(c), u'_') for c in intab)))
 return winpath

def sanitize_win_path_string ( winpath ) : intab = '<>:|?*' outtab = ( '_' * len ( intab ) ) trantab = ( '' . maketrans ( intab , outtab ) if six . PY3 else string . maketrans ( intab , outtab ) ) if isinstance ( winpath , str ) : winpath = winpath . translate ( trantab ) elif isinstance ( winpath , six . text_type ) : winpath = winpath . translate ( dict ( ( ( ord ( c ) , u'_' ) for c in intab ) ) ) return winpath
remove illegal path characters for windows .