def path_components(path):
 if (not path.startswith('/')):
  raise Exception, ('path must start with "/": %s' % path)
 result = [('', '/')]
 norm_path = os.path.abspath(path)
 if (norm_path == '/'):
  return result
 full_path = ''
 for p in norm_path.split('/')[1:]:
  full_path += ('/' + p)
  result.append((p, full_path))
 return result

def path_components ( path ) : if ( not path . startswith ( '/' ) ) : raise Exception , ( 'path must start with "/": %s' % path ) result = [ ( '' , '/' ) ] norm_path = os . path . abspath ( path ) if ( norm_path == '/' ) : return result full_path = '' for p in norm_path . split ( '/' ) [ 1 : ] : full_path += ( '/' + p ) result . append ( ( p , full_path ) ) return result
return the individual components of a given file path string .