Lines Matching refs:path
12 def IsDirectory(path):
13 '''Returns whether |path| should be considered a directory.
16 AssertIsValid(path)
17 return path in ('', '.', '..') or path.endswith('/') or path.endswith('/..')
20 def IsValid(path):
21 '''Returns whether |path| is a valid path for the purposes of the docserver.
23 repeat the path separator //.
25 return not path.startswith('/') and not '\\' in path and not '//' in path
28 def AssertIsValid(path):
29 assert IsValid(path), 'Path "%s" is invalid' % path
33 assert all(IsValid(path) for path in paths), paths
37 def SplitParent(path):
38 '''Returns the parent directory and base name of |path| in a tuple.
39 Any trailing slash of |path| is preserved, such that the parent of
42 parent, base = posixpath.split(path.rstrip('/'))
43 if path.endswith('/'):
48 def ToDirectory(path):
49 '''Returns a string representing |path| as a directory, that is,
50 IsDirectory(result) is True (and does not fail assertions). If |path| is
53 return path if IsDirectory(path) else (path + '/')
56 def AssertIsDirectory(path):
57 assert IsDirectory(path), '"%s" is not a directory' % path
60 def AssertIsFile(path):
61 assert not IsDirectory(path), '"%s" is not a file' % path