Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.
(a, *p)
| 70 | # Insert a '/' unless the first part is empty or already ends in '/'. |
| 71 | |
| 72 | def join(a, *p): |
| 73 | """Join two or more pathname components, inserting '/' as needed. |
| 74 | If any component is an absolute path, all previous path components |
| 75 | will be discarded. An empty last part will result in a path that |
| 76 | ends with a separator.""" |
| 77 | a = os.fspath(a) |
| 78 | sep = _get_sep(a) |
| 79 | path = a |
| 80 | try: |
| 81 | for b in p: |
| 82 | b = os.fspath(b) |
| 83 | if b.startswith(sep) or not path: |
| 84 | path = b |
| 85 | elif path.endswith(sep): |
| 86 | path += b |
| 87 | else: |
| 88 | path += sep + b |
| 89 | except (TypeError, AttributeError, BytesWarning): |
| 90 | genericpath._check_arg_types('join', a, *p) |
| 91 | raise |
| 92 | return path |
| 93 | |
| 94 | |
| 95 | # Split a path in head (everything up to the last '/') and tail (the |
no test coverage detected