Combine

ocdskit.combine.package_records(records, uri='', publisher=None, published_date='', version='1.1', extensions=None)[source]

Wrap records in a record package.

Parameters:
  • records (list) – a list of records

  • uri (str) – the record package’s uri

  • publisher (dict) – the record package’s publisher

  • published_date (str) – the record package’s publishedDate

  • version (str) – the record package’s version

  • extensions (list) – the record package’s extensions

ocdskit.combine.package_releases(releases, uri='', publisher=None, published_date='', version='1.1', extensions=None)[source]

Wrap releases in a release package.

Parameters:
  • releases (list) – a list of releases

  • uri (str) – the release package’s uri

  • publisher (dict) – the release package’s publisher

  • published_date (str) – the release package’s publishedDate

  • version (str) – the release package’s version

  • extensions (list) – the release package’s extensions

ocdskit.combine.combine_record_packages(packages, uri='', publisher=None, published_date='', version='1.1')[source]

Collect the packages and records from the record packages into one record package.

Warn ~ocdskit.exceptions.MissingRecordsWarning if the “records” field is missing from a record package.

Parameters:
  • packages – an iterable of record packages

  • uri (str) – the record package’s uri

  • publisher (dict) – the record package’s publisher

  • published_date (str) – the record package’s publishedDate

  • version (str) – the record package’s version

ocdskit.combine.combine_release_packages(packages, uri='', publisher=None, published_date='', version='1.1')[source]

Collect the releases from the release packages into one release package.

Warn ~ocdskit.exceptions.MissingReleasesWarning if the “releases” field is missing from a release package.

Parameters:
  • packages – an iterable of release packages

  • uri (str) – the release package’s uri

  • publisher (dict) – the release package’s publisher

  • published_date (str) – the release package’s publishedDate

  • version (str) – the release package’s version

ocdskit.combine.merge(data, uri='', publisher=None, published_date='', version='1.1', schema=None, *, return_versioned_release=False, return_package=False, use_linked_releases=False, streaming=False, force_version=None, ignore_version=False, convert_exceptions_to_warnings=False)[source]

Merge release packages and individual releases.

By default, yields compiled releases. If return_versioned_release is True, yields versioned releases. If return_package is True, wraps the compiled releases (and versioned releases if return_versioned_release is True) in a record package.

If return_package is set and publisher isn’t set, the output record package will have the same publisher as the last input release package.

Attention

This function is vulnerable to server-side request forgery (SSRF). A user can create a release package or record package whose extension URLs point to internal resources, which would receive a GET request.

Parameters:
  • data – an iterable of release packages and individual releases

  • uri (str) – if return_package is True, the record package’s uri

  • publisher (dict | None) – if return_package is True, the record package’s publisher

  • published_date (str) – if return_package is True, the record package’s publishedDate

  • version (str) – if return_package is True, the record package’s version

  • schema (dict | None) – the URL, path or dict of the patched release schema to use

  • return_package (bool) – wrap the compiled releases in a record package

  • use_linked_releases (bool) – if return_package is True, use linked releases instead of full releases, if the input is a release package

  • return_versioned_release (bool) – if return_package is True, include versioned releases in the record package; otherwise, yield versioned releases instead of compiled releases

  • streaming (bool) – if return_package is True, set the package’s records to a generator (this only works if the calling code exhausts the generator before merge returns)

  • force_version (str | None) – version to use instead of the version of the first release package or individual release

  • ignore_version (bool) – do not raise an error if the versions are inconsistent across items to merge

  • convert_exceptions_to_warnings (bool) – whether to convert inconsistent type errors from OCDS Merge to warnings

Raises:
ocdskit.combine.compile_release_packages(*args, **kwargs)[source]