def clean_path(path):
 split_path = path.rsplit('/', 2)[:(-1)]
 if (len(split_path) == 2):
  split_path[1] = PATH_TOKEN
 return ('/'.join(split_path) + '/')

def clean_path ( path ) : split_path = path . rsplit ( '/' , 2 ) [ : ( - 1 ) ] if ( len ( split_path ) == 2 ) : split_path [ 1 ] = PATH_TOKEN return ( '/' . join ( split_path ) + '/' )
accepts the root the path needs to be under and verifies that the path is under said root .