Return the common part shared with the other path, or None if there is no common part. If one path is relative and one is absolute, returns None.
(path1: Path, path2: Path)
| 996 | |
| 997 | |
| 998 | def commonpath(path1: Path, path2: Path) -> Path | None: |
| 999 | """Return the common part shared with the other path, or None if there is |
| 1000 | no common part. |
| 1001 | |
| 1002 | If one path is relative and one is absolute, returns None. |
| 1003 | """ |
| 1004 | try: |
| 1005 | return Path(os.path.commonpath((str(path1), str(path2)))) |
| 1006 | except ValueError: |
| 1007 | return None |
| 1008 | |
| 1009 | |
| 1010 | def bestrelpath(directory: Path, dest: Path) -> str: |
no outgoing calls