def _get_valid_pathstr(pathstr):
 if (not isinstance(pathstr, (str, bytes))):
  pathstr = to_str(pathstr)
 pathstr = pathstr.replace(os.sep, u'..')
 pathstr = re.sub(u'[][ (){}?:<>#!|"\';]', u'', pathstr)
 pathstr = pathstr.replace(u',', u'.')
 return pathstr

def _get_valid_pathstr ( pathstr ) : if ( not isinstance ( pathstr , ( str , bytes ) ) ) : pathstr = to_str ( pathstr ) pathstr = pathstr . replace ( os . sep , u'..' ) pathstr = re . sub ( u'[][ (){}?:<>#!|"\';]' , u'' , pathstr ) pathstr = pathstr . replace ( u',' , u'.' ) return pathstr
remove disallowed characters from path removes: [][ (){}?:<>#!|";] replaces: .