def sanitize_and_trim_path(path):
 path = path.strip()
 new_path = ''
 if sabnzbd.WIN32:
  if path.startswith(u'\\\\?\\UNC\\'):
   new_path = u'\\\\?\\UNC\\'
   path = path[8:]
  elif path.startswith(u'\\\\?\\'):
   new_path = u'\\\\?\\'
   path = path[4:]
 path = path.replace('\\', '/')
 parts = path.split('/')
 if (sabnzbd.WIN32 and (len(parts[0]) == 2) and (':' in parts[0])):
  new_path += (parts[0] + '/')
  parts.pop(0)
 elif path.startswith('//'):
  new_path = '//'
 elif path.startswith('/'):
  new_path = '/'
 for part in parts:
  new_path = os.path.join(new_path, sanitize_foldername(part))
 return os.path.abspath(os.path.normpath(new_path))

def sanitize_and_trim_path ( path ) : path = path . strip ( ) new_path = '' if sabnzbd . WIN32 : if path . startswith ( u'\\\\?\\UNC\\' ) : new_path = u'\\\\?\\UNC\\' path = path [ 8 : ] elif path . startswith ( u'\\\\?\\' ) : new_path = u'\\\\?\\' path = path [ 4 : ] path = path . replace ( '\\' , '/' ) parts = path . split ( '/' ) if ( sabnzbd . WIN32 and ( len ( parts [ 0 ] ) == 2 ) and ( ':' in parts [ 0 ] ) ) : new_path += ( parts [ 0 ] + '/' ) parts . pop ( 0 ) elif path . startswith ( '//' ) : new_path = '//' elif path . startswith ( '/' ) : new_path = '/' for part in parts : new_path = os . path . join ( new_path , sanitize_foldername ( part ) ) return os . path . abspath ( os . path . normpath ( new_path ) )
remove illegal characters and trim element size .