def strip_folders(path):
 unc = (sabnzbd.WIN32 and (path.startswith('//') or path.startswith('\\\\')))
 f = path.strip('/').split('/')
 if (path.strip()[0] in '/\\'):
  f.insert(0, '')
 def strip_all(x):
  ' Strip all leading/trailing underscores also dots for Windows '
  x = x.strip().strip('_')
  if sabnzbd.WIN32:
   x = x.strip('.')
  x = x.strip()
  return x
 path = os.path.normpath('/'.join([strip_all(x) for x in f]))
 if unc:
  return ('\\' + path)
 else:
  return path

def strip_folders ( path ) : unc = ( sabnzbd . WIN32 and ( path . startswith ( '//' ) or path . startswith ( '\\\\' ) ) ) f = path . strip ( '/' ) . split ( '/' ) if ( path . strip ( ) [ 0 ] in '/\\' ) : f . insert ( 0 , '' ) def strip_all ( x ) : x = x . strip ( ) . strip ( '_' ) if sabnzbd . WIN32 : x = x . strip ( '.' ) x = x . strip ( ) return x path = os . path . normpath ( '/' . join ( [ strip_all ( x ) for x in f ] ) ) if unc : return ( '\\' + path ) else : return path
return path without leading and trailing spaces and underscores in each element for windows .