MCPcopy Create free account
hub / github.com/apache/mesos / PathSplitToList

Function PathSplitToList

support/cpplint.py:1789–1812  ·  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

1787 return 0
1788
1789def PathSplitToList(path):
1790 """Returns the path split into a list by the separator.
1791
1792 Args:
1793 path: An absolute or relative path (e.g. '/a/b/c/' or '../a')
1794
1795 Returns:
1796 A list of path components (e.g. ['a', 'b', 'c]).
1797 """
1798 lst = []
1799 while True:
1800 (head, tail) = os.path.split(path)
1801 if head == path: # absolute paths end
1802 lst.append(head)
1803 break
1804 if tail == path: # relative paths end
1805 lst.append(tail)
1806 break
1807
1808 path = head
1809 lst.append(tail)
1810
1811 lst.reverse()
1812 return lst
1813
1814def GetHeaderGuardCPPVariable(filename):
1815 """Returns the CPP variable that should be used as a header guard.

Callers 1

FixupPathFromRootFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected