tools/python/google/path_utils.py
def FindAncestor(start_dir, ancestor):
  """Finds an ancestor dir in a path.

  For example, FindAncestor('c:\foo\bar\baz', 'bar') would return
  'c:\foo\bar'.  Unlike FindUpward*, this only looks at direct path ancestors.
  """
  start_dir = os.path.abspath(start_dir)
  path = start_dir
  while True:
    (parent, tail) = os.path.split(path)
    if tail == ancestor:
      return path
    if not tail:
      break
    path = parent
  raise PathNotFound("Unable to find ancestor %s in %s" % (ancestor, start_dir))
Finds an ancestor dir in a path.

  For example, FindAncestor('c:\foo\bar\baz', 'bar') would return
  'c:\foo\bar'.  Unlike FindUpward*, this only looks at direct path ancestors.
  
Finds an ancestor dir in a path.
Finds an ancestor dir in a path .
def FindAncestor(start_dir, ancestor):
  start_dir = os.path.abspath(start_dir)
  path = start_dir
  while True:
    (parent, tail) = os.path.split(path)
    if tail == ancestor:
      return path
    if not tail:
      break
    path = parent
  raise PathNotFound("Unable to find ancestor %s in %s" % (ancestor, start_dir))
def FindAncestor ( start_dir , ancestor ) : start_dir = os . path . abspath ( start_dir ) path = start_dir while True : ( parent , tail ) = os . path . split ( path ) if tail == ancestor : return path if not tail : break path = parent raise PathNotFound ( "Unable to find ancestor %s in %s" % ( ancestor , start_dir ) )
Finds an ancestor dir in a path.
Finds an ancestor dir in a path .
"""Finds an ancestor dir in a path.

  For example, FindAncestor('c:\foo\bar\baz', 'bar') would return
  'c:\foo\bar'.  Unlike FindUpward*, this only looks at direct path ancestors.
  """
start_dir
ancestor