parameters: (path, bases)
docstring: Given a list of directories (bases), return which one contains the given
      path. If several matches are found, the deepest base directory is returned.
          basedir('foo/bar/baz', ['foo', 'baz', 'foo/bar']) returns 'foo/bar'
          ('foo' and 'foo/bar' both match, but 'foo/bar' is the deepest match)
docstring_summary: Given a list of directories (bases), return which one contains the given
      path. If several matches are found, the deepest base directory is returned.
          basedir('foo/bar/baz', ['foo', 'baz', 'foo/bar']) returns 'foo/bar'
          ('foo' and 'foo/bar' both match, but 'foo/bar' is the deepest match)
docstring_tokens: Given a list of directories ( bases ) return which one contains the given path . If several matches are found the deepest base directory is returned . basedir ( foo / bar / baz [ foo baz foo / bar ] ) returns foo / bar ( foo and foo / bar both match but foo / bar is the deepest match )
function: def basedir(path, bases):
      '''
      Given a list of directories (bases), return which one contains the given
      path. If several matches are found, the deepest base directory is returned.
          basedir('foo/bar/baz', ['foo', 'baz', 'foo/bar']) returns 'foo/bar'
          ('foo' and 'foo/bar' both match, but 'foo/bar' is the deepest match)
      '''
      path = normsep(path)
      bases = [normsep(b) for b in bases]
      if path in bases:
          return path
      for b in sorted(bases, reverse=True):
          if b == '' or path.startswith(b + '/'):
              return b
function_tokens: def basedir ( path , bases ) : path = normsep ( path ) bases = [ normsep ( b ) for b in bases ] if path in bases : return path for b in sorted ( bases , reverse = True ) : if b == '' or path . startswith ( b + '/' ) : return b