paths¶
Utility functions for handling paths.
uri_to_path(uri)
¶
Convert URI to pathlib.Path.
Support both Windows and Posix path types.
Information
urllib.parse.urlparse()
leaves an initial slash in front of the drive letter
when parsing a file URL for an absolute path on Windows.
Example: urlparse("file:///C:/Windows").path
-> "/C:/Windows"
To solve this, the initial forward slash is removed prior to casting to
pathlib.Path
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
Union[str, AnyUrl, ParseResult]
|
The URI/IRI/URL. Either as a string or a parsed URL. |
required |
Returns:
Type | Description |
---|---|
Path
|
A properly converted URI/IRI/URL to |
Source code in oteapi/utils/paths.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|