MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / _IsParentOrSame

Function _IsParentOrSame

steps/cpplint.py:6870–6886  ·  view source on GitHub ↗

Return true if child is subdirectory of parent. Assumes both paths are absolute and don't contain symlinks.

(parent, child)

Source from the content-addressed store, hash-verified

6868 if _IsParentOrSame(e, os.path.abspath(f)))]
6869
6870def _IsParentOrSame(parent, child):
6871 """Return true if child is subdirectory of parent.
6872 Assumes both paths are absolute and don't contain symlinks.
6873 """
6874 parent = os.path.normpath(parent)
6875 child = os.path.normpath(child)
6876 if parent == child:
6877 return True
6878
6879 prefix = os.path.commonprefix([parent, child])
6880 if prefix != parent:
6881 return False
6882 # Note: os.path.commonprefix operates on character basis, so
6883 # take extra care of situations like '/foo/ba' and '/foo/bar/baz'
6884 child_suffix = child[len(prefix):]
6885 child_suffix = child_suffix.lstrip(os.sep)
6886 return child == os.path.join(prefix, child_suffix)
6887
6888def main():
6889 filenames = ParseArguments(sys.argv[1:])

Callers 1

_FilterExcludedFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected