MCPcopy Create free account
hub / github.com/alibaba/GraphScope / PathSplitToList

Function PathSplitToList

analytical_engine/misc/cpplint.py:2265–2288  ·  view source on GitHub ↗

Returns the path split into a list by the separator. Args: path: An absolute or relative path (e.g. '/a/b/c/' or '../a') Returns: A list of path components (e.g. ['a', 'b', 'c]).

(path)

Source from the content-addressed store, hash-verified

2263 return 0
2264
2265def PathSplitToList(path):
2266 """Returns the path split into a list by the separator.
2267
2268 Args:
2269 path: An absolute or relative path (e.g. '/a/b/c/' or '../a')
2270
2271 Returns:
2272 A list of path components (e.g. ['a', 'b', 'c]).
2273 """
2274 lst = []
2275 while True:
2276 (head, tail) = os.path.split(path)
2277 if head == path: # absolute paths end
2278 lst.append(head)
2279 break
2280 if tail == path: # relative paths end
2281 lst.append(tail)
2282 break
2283
2284 path = head
2285 lst.append(tail)
2286
2287 lst.reverse()
2288 return lst
2289
2290def GetHeaderGuardCPPVariable(filename):
2291 """Returns the CPP variable that should be used as a header guard.

Callers 1

FixupPathFromRootFunction · 0.85

Calls 3

splitMethod · 0.80
appendMethod · 0.65
reverseMethod · 0.45

Tested by

no test coverage detected