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)
| 2466 | |
| 2467 | |
| 2468 | def PathSplitToList(path): |
| 2469 | """Returns the path split into a list by the separator. |
| 2470 | |
| 2471 | Args: |
| 2472 | path: An absolute or relative path (e.g. '/a/b/c/' or '../a') |
| 2473 | |
| 2474 | Returns: |
| 2475 | A list of path components (e.g. ['a', 'b', 'c]). |
| 2476 | """ |
| 2477 | lst = [] |
| 2478 | while True: |
| 2479 | (head, tail) = os.path.split(path) |
| 2480 | if head == path: # absolute paths end |
| 2481 | lst.append(head) |
| 2482 | break |
| 2483 | if tail == path: # relative paths end |
| 2484 | lst.append(tail) |
| 2485 | break |
| 2486 | |
| 2487 | path = head |
| 2488 | lst.append(tail) |
| 2489 | |
| 2490 | lst.reverse() |
| 2491 | return lst |
| 2492 | |
| 2493 | |
| 2494 | def GetHeaderGuardCPPVariable(filename): |