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)
| 2511 | |
| 2512 | |
| 2513 | def PathSplitToList(path): |
| 2514 | """Returns the path split into a list by the separator. |
| 2515 | |
| 2516 | Args: |
| 2517 | path: An absolute or relative path (e.g. '/a/b/c/' or '../a') |
| 2518 | |
| 2519 | Returns: |
| 2520 | A list of path components (e.g. ['a', 'b', 'c]). |
| 2521 | """ |
| 2522 | lst = [] |
| 2523 | while True: |
| 2524 | (head, tail) = os.path.split(path) |
| 2525 | if head == path: # absolute paths end |
| 2526 | lst.append(head) |
| 2527 | break |
| 2528 | if tail == path: # relative paths end |
| 2529 | lst.append(tail) |
| 2530 | break |
| 2531 | |
| 2532 | path = head |
| 2533 | lst.append(tail) |
| 2534 | |
| 2535 | lst.reverse() |
| 2536 | return lst |
| 2537 | |
| 2538 | |
| 2539 | def GetHeaderGuardCPPVariable(filename): |
no test coverage detected
searching dependent graphs…