Classes:
-
IriToFileResolver
–A
urllib.request.OpenerDirector
that remaps specific URLs to local files.
Functions:
-
install_resolver
–Implements default behaviours for resolver installation
IriToFileResolver
IriToFileResolver(url_map, download=True)
Bases: OpenerDirector
A urllib.request.OpenerDirector
that remaps specific URLs to local files.
Parameters:
-
url_map
(dict
) –Mapping from a prefix of a URL to a local location. For example,
{ "http://example.org/": "foo/bar/" }
would remap any urllib open request for any resource underhttp://example.org/
to a local directoryfoo/bar/
. -
download
(bool
, default:True
) –If true and the mapped local file does not exist, will attempt to download to the mapped location.
Source code in src/rdf_utils/resolver.py
31 32 33 34 35 36 |
|
install_resolver
install_resolver(resolver=None, url_map=None, download=True)
Implements default behaviours for resolver installation
Parameters:
-
resolver
(Optional[OpenerDirector]
, default:None
) –Resolver to install. If none specified, the default behaviour (using
IriToFileResolver
) is to download the requested files to the user cache directory usingplatformdirs
. For Linux this should be$HOME/.cache/rdf-utils/
. -
url_map
(Optional[dict]
, default:None
) –URL to local path mapping to pass to
IriToFileResolver
-
download
(bool
, default:True
) –Download file if true
Note
Only a single opener can be globally installed in urllib. Only the latest installed resolver will be active.
Source code in src/rdf_utils/resolver.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|