Convert *path* to a string or unicode path if possible.
(path)
| 136 | |
| 137 | |
| 138 | def _stringify_path(path): |
| 139 | """ |
| 140 | Convert *path* to a string or unicode path if possible. |
| 141 | """ |
| 142 | if isinstance(path, str): |
| 143 | return os.path.expanduser(path) |
| 144 | |
| 145 | # checking whether path implements the filesystem protocol |
| 146 | try: |
| 147 | return os.path.expanduser(path.__fspath__()) |
| 148 | except AttributeError: |
| 149 | pass |
| 150 | |
| 151 | raise TypeError("not a path-like object") |
| 152 | |
| 153 | |
| 154 | def product(seq): |
no test coverage detected