def canon_path(path, indices=None):
 if (not isinstance(path, str)):
  return tuple(map(ensure_str_or_int, path))
 if (indices is not None):
  path = path.format(**indices)
 path = (path[1:] if path.startswith('/') else path)
 path = (path[:(-1)] if path.endswith('/') else path)
 if (len(path) == 0):
  return ()
 return tuple(map(ensure_str_or_int, path.split('/')))

def canon_path ( path , indices = None ) : if ( not isinstance ( path , str ) ) : return tuple ( map ( ensure_str_or_int , path ) ) if ( indices is not None ) : path = path . format ( ** indices ) path = ( path [ 1 : ] if path . startswith ( '/' ) else path ) path = ( path [ : ( - 1 ) ] if path . endswith ( '/' ) else path ) if ( len ( path ) == 0 ) : return ( ) return tuple ( map ( ensure_str_or_int , path . split ( '/' ) ) )
return path in os-independent form .