Return a POSIX ``path`` stripped from its first path segment unless there is only one segment in which case we return this segment. The returned path has no leading and trailing slashes. For example:: >>> strip_first_path_segment('') '' >>> strip_first_path_
(path)
| 1655 | |
| 1656 | |
| 1657 | def strip_first_path_segment(path): |
| 1658 | """ |
| 1659 | Return a POSIX ``path`` stripped from its first path segment unless there is |
| 1660 | only one segment in which case we return this segment. The returned path has |
| 1661 | no leading and trailing slashes. |
| 1662 | |
| 1663 | For example:: |
| 1664 | >>> strip_first_path_segment('') |
| 1665 | '' |
| 1666 | >>> strip_first_path_segment('foo') |
| 1667 | '' |
| 1668 | >>> strip_first_path_segment('foo/bar/baz') |
| 1669 | 'bar/baz' |
| 1670 | >>> strip_first_path_segment('/foo/bar/baz/') |
| 1671 | 'bar/baz' |
| 1672 | >>> strip_first_path_segment('foo/') |
| 1673 | '' |
| 1674 | """ |
| 1675 | path = clean_path(path) |
| 1676 | if "/" in path: |
| 1677 | _root, _, path = path.partition("/") |
| 1678 | return path |
| 1679 | else: |
| 1680 | return "" |
| 1681 | |
| 1682 | |
| 1683 | def get_codebase_cache_dir(temp_dir): |
no test coverage detected