Classes:
-
IriToFileResolver–An
OpenerDirectorthat remaps specific URLs to local files.
Functions:
-
install_resolver–Implements default behaviours for resolver installation
IriToFileResolver
IriToFileResolver(url_map, download=True, quiet=False)
Bases: OpenerDirector
An 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.
-
quiet(bool, default:False) –If
FalseanddownloadisTruewill print where the file will be downloaded to.
Source code in src/rdf_utils/resolver.py
33 34 35 36 37 38 39 | |
install_resolver
install_resolver(resolver=None, url_map=None, download=True, quiet=False)
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
-
quiet(bool, default:False) –Option for more verbose output, created for printing caching location in
IriToFileResolver
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
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |