def stripped_path_components(path, strip_prefixes):
 normalized_path = os.path.abspath(path)
 sorted_strip_prefixes = sorted(strip_prefixes, key=len, reverse=True)
 for bp in sorted_strip_prefixes:
  normalized_bp = os.path.abspath(bp)
  if (normalized_bp == '/'):
   continue
  if normalized_path.startswith(normalized_bp):
   prefix = normalized_path[:len(normalized_bp)]
   result = []
   for p in normalized_path[len(normalized_bp):].split('/'):
    if p:
     prefix += '/'
    prefix += p
    result.append((p, prefix))
   return result
 return path_components(path)

def stripped_path_components ( path , strip_prefixes ) : normalized_path = os . path . abspath ( path ) sorted_strip_prefixes = sorted ( strip_prefixes , key = len , reverse = True ) for bp in sorted_strip_prefixes : normalized_bp = os . path . abspath ( bp ) if ( normalized_bp == '/' ) : continue if normalized_path . startswith ( normalized_bp ) : prefix = normalized_path [ : len ( normalized_bp ) ] result = [ ] for p in normalized_path [ len ( normalized_bp ) : ] . split ( '/' ) : if p : prefix += '/' prefix += p result . append ( ( p , prefix ) ) return result return path_components ( path )
strip any prefix in strip_prefixes from path and return a list of path components where each component is .