Converts a URI to a file path. Works on both Linux and Windows. This method was obtained from https://stackoverflow.com/a/61922504
(uri: str)
| 73 | """ |
| 74 | @staticmethod |
| 75 | def uri_to_path(uri: str) -> str: |
| 76 | """ |
| 77 | Converts a URI to a file path. Works on both Linux and Windows. |
| 78 | |
| 79 | This method was obtained from https://stackoverflow.com/a/61922504 |
| 80 | """ |
| 81 | from urllib.parse import urlparse, unquote |
| 82 | from urllib.request import url2pathname |
| 83 | parsed = urlparse(uri) |
| 84 | host = "{0}{0}{mnt}{0}".format(os.path.sep, mnt=parsed.netloc) |
| 85 | return os.path.normpath(os.path.join(host, url2pathname(unquote(parsed.path)))) |
| 86 | |
| 87 | class FileUtils: |
| 88 | """ |
no test coverage detected