MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / PathSplitToList

Function PathSplitToList

src/tests/coding/cpplint.py:2261–2284  ·  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

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

Callers 1

FixupPathFromRootFunction · 0.85

Calls 2

splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected