Profile Builder#

from ocdsextensionregistry import ProfileBuilder

builder = ProfileBuilder('1__1__4', {
    'lots': 'v1.1.4',
    'bids': 'v1.1.4',
})

This initializes a profile of OCDS 1.1.4 with two extensions. Alternately, you can pass a list of extensions’ metadata URLs, base URLs, download URLs, and/or absolute paths to local directories, for example:

builder = ProfileBuilder('1__1__4', [
  'https://raw.githubusercontent.com/open-contracting-extensions/ocds_coveredBy_extension/master/extension.json',
  'https://raw.githubusercontent.com/open-contracting-extensions/ocds_options_extension/master/',
  'https://github.com/open-contracting-extensions/ocds_techniques_extension/archive/master.zip',
  'file:///absolute/path/to/ocds_lots_extension',
])

After initializing the profile, you can then:

class ocdsextensionregistry.profile_builder.ProfileBuilder(standard_tag, extension_versions, registry_base_url=None, standard_base_url=None, schema_base_url=None)[source]#
__init__(standard_tag, extension_versions, registry_base_url=None, standard_base_url=None, schema_base_url=None)[source]#

Accepts an OCDS version and either a dictionary of extension identifiers and versions, or a list of extensions’ metadata URLs, base URLs and/or download URLs, and initializes a reader of the extension registry.

Parameters:
  • standard_tag (str) – the OCDS version tag, e.g. '1__1__4'

  • extension_versions (dict or list) – the extension versions

  • registry_base_url (str) – the registry’s base URL, defaults to 'https://raw.githubusercontent.com/open-contracting/extension_registry/main/'

  • standard_base_url (str) – the standard’s base URL, defaults to 'https://codeload.github.com/open-contracting/standard/zip/' + standard_tag

  • schema_base_url (str) – the schema’s base URL, e.g. 'https://standard.open-contracting.org/profiles/ppp/schema/1__0__0__beta/'

extensions()[source]#

Returns the matching extension versions from the registry.

release_schema_patch(extension_field=None, language='en')[source]#

Returns the consolidated release schema patch.

Parameters:
  • extension_field (str) – the property with which to annotate each definition and field with the name of the extension in which the definition or field is defined

  • language (str) – the language to use for the name of the extension

patched_release_schema(schema=None, extension_field=None, language='en')[source]#

Returns the patched release schema.

Parameters:
  • schema (dict) – the release schema

  • extension_field (str) – the property with which to annotate each definition and field with the name of the extension in which the definition or field is defined

  • language (str) – the language to use for the name of the extension

release_package_schema(schema=None, embed=False)[source]#

Returns a release package schema. If the profile builder was initialized with schema_base_url, updates schema URLs.

Parameters:
  • schema (dict) – the release schema

  • embed (bool) – whether to embed or $ref’erence the patched release schema

record_package_schema(schema=None, embed=False)[source]#

Returns a record package schema. If the profile builder was initialized with schema_base_url, updates schema URLs.

Parameters:
  • schema (dict) – the record schema

  • embed (bool) – whether to embed or $ref’erence the patched release schema

standard_codelists()[source]#

Returns the standard’s codelists as Codelist objects.

extension_codelists()[source]#

Returns the extensions’ codelists as Codelist objects.

The extensions’ codelists may be new, or may add codes to (+name.csv), remove codes from (-name.csv) or replace (name.csv) the codelists of the standard or other extensions.

Codelist additions and removals are merged across extensions. If new codelists or codelist replacements differ across extensions, an error is raised.

patched_codelists()[source]#

Returns patched and new codelists as Codelist objects.

get_standard_file_contents(basename)[source]#

Returns the contents of the file within the standard.

Downloads the given version of the standard, and caches the contents of files in the schema/ directory.