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]#
Accepts a row from extension_versions.csv and assigns values to properties.
- 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()
.
- download_url#
The Download URL cell.
- get_url(basename)[source]#
Returns 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]#
Returns the contents of the file within the extension. If the
default
is set and the file does not exist, returns the provideddefault
value.If the extension has a download URL, caches all the files’ contents. Otherwise, downloads and caches the requested file’s contents. Raises 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#
Returns the unparsed contents of all files. Decodes the contents of CSV, JSON and Markdown files.
If the extension has a download URL, caches all the files’ contents. Otherwise, returns an empty dict. Raises 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, downloads and returns 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#
Retrieves and returns the parsed contents of the extension’s extension.json file.
Adds language maps if not present.
- property schemas#
Retrieves and returns the parsed contents of the extension’s schemas files.
- property codelists#
Retrieves and returns 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, returns an empty dict.
- property repository_full_name#
Returns the full name of the extension’s repository, which should be a unique identifier on the hosting service, e.g. open-contracting-extensions/ocds_bid_extension
- property repository_name#
Returns the short name of the extension’s repository, i.e. omitting any organizational prefix, which can be used to create directories, e.g. ocds_bid_extension
- property repository_user#
Returns the user or organization to which the extension’s repository belongs, e.g. open-contracting-extensions
- property repository_ref#
Returns the ref in the extension’s URL if the extension’s files are in the repository’s root, like v1.1.5
- property repository_user_page#
Returns the URL to the landing page of the user or organization to which the extension’s repository belongs, e.g. https://github.com/open-contracting-extensions
- property repository_html_page#
Returns the URL to the landing page of the extension’s repository, e.g. https://github.com/open-contracting-extensions/ocds_bid_extension
- property repository_url#
Returns the URL of the extension’s repository, in a format that can be input to a VCS program without modification, e.g. https://github.com/open-contracting-extensions/ocds_bid_extension.git
- property repository_ref_download_url#
Returns the download URL for the ref in the extensions’s URL, e.g. https://github.com/open-contracting-extensions/ocds_bid_extension/archive/v1.1.5.zip