Extension Version¶
- class ocdsextensionregistry.extension_version.ExtensionVersion(data, input_url=None, url_pattern=None, file_urls=None)[source]¶
- __init__(data, input_url=None, url_pattern=None, file_urls=None)[source]¶
Accept a row from
extension_versions.csv
and assign values to properties.Attention
Check the arguments to prevent server-side request forgery (SSRF).
- id¶
The Id cell.
- date¶
The Date cell.
- version¶
The Version cell.
- base_url¶
The Base URL cell.
- input_url¶
The URL that was provided in a list to
ocdsextensionregistry.profile_builder.ProfileBuilder.extensions()
.
- allow_schemes¶
The URL schemes to allow.
- download_url¶
The Download URL cell.
- get_url(basename)[source]¶
Return the URL of the file within the extension.
- Raises:
NotImplementedError – if the basename is not in the file URLs and the base URL is not set
- remote(basename, default=None)[source]¶
Return the contents of the file within the extension.
If the
default
is set and the file does not exist, return the provideddefault
value.If the extension has a download URL, cache all the files’ contents. Otherwise, download and cache the requested file’s contents. Raise an HTTPError if a download fails.
- Raises:
DoesNotExist – if the file isn’t in the extension
zipfile.BadZipFile – if the download URL is not a ZIP file
- property files¶
Return the unparsed contents of all files. Decode the contents of CSV, JSON and Markdown files.
If the extension has a download URL, cache all the files’ contents. Otherwise, return an empty dict. Raise an HTTPError if the download fails.
- Raises:
zipfile.BadZipFile – if the download URL is not a ZIP file
- zipfile()[source]¶
If the extension has a download URL, download and return the ZIP archive.
- Raises:
NotAvailableInBulk – if the extension has no download URL
zipfile.BadZipFile – if the download URL is not a ZIP file
- property metadata¶
Retrieve and return the parsed contents of the extension’s extension.json file.
Add language maps if not present.
- property schemas¶
Retrieve and return the parsed contents of the extension’s schemas files.
- property codelists¶
Retrieve and return the parsed contents of the extension’s codelists files.
If the extension has no download URL, and if no codelists are listed in extension.json, return an empty dict.
- Warns ExtensionCodelistWarning:
if the codelist file’s URL is not a supported scheme, if the request fails, if the bulk file is not a ZIP file, or if the codelist file is not UTF-8
- property repository_full_name¶
Return the full name of the extension’s repository, which should be a unique identifier on the hosting service.
Example:
open-contracting-extensions/ocds_bid_extension
- property repository_name¶
Return the short name of the extension’s repository, i.e. omitting any organizational prefix, which can be used to create directories.
Example:
ocds_bid_extension
- property repository_user¶
Return the user or organization to which the extension’s repository belongs.
Example:
open-contracting-extensions
- property repository_ref¶
Return the ref in the extension’s URL if the extension’s files are in the repository’s root.
Example:
v1.1.5
- property repository_user_page¶
Return the URL to the landing page of the user or organization to which the extension’s repository belongs.
Example:
https://github.com/open-contracting-extensions
- property repository_html_page¶
Return the URL to the landing page of the extension’s repository.
Example:
https://github.com/open-contracting-extensions/ocds_bid_extension
- property repository_url¶
Return the URL of the extension’s repository, in a format that can be input to a VCS program without modification.
Example:
https://github.com/open-contracting-extensions/ocds_bid_extension.git
- property repository_ref_download_url¶
Return the download URL for the ref in the extensions’s URL.
Example:
https://github.com/open-contracting-extensions/ocds_bid_extension/archive/v1.1.5.zip