Combine¶
- ocdskit.combine.package_records(records, uri='', publisher=None, published_date='', version='1.1', extensions=None)[source]¶
Wrap records in a record package.
- ocdskit.combine.package_releases(releases, uri='', publisher=None, published_date='', version='1.1', extensions=None)[source]¶
Wrap releases in a release package.
- 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.
- 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.
- 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
isTrue
, yields versioned releases. Ifreturn_package
isTrue
, wraps the compiled releases (and versioned releases ifreturn_versioned_release
isTrue
) in a record package.If
return_package
is set andpublisher
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
isTrue
, the record package’suri
publisher (dict | None) – if
return_package
isTrue
, the record package’spublisher
published_date (str) – if
return_package
isTrue
, the record package’spublishedDate
version (str) – if
return_package
isTrue
, the record package’sversion
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
isTrue
, use linked releases instead of full releases, if the input is a release packagereturn_versioned_release (bool) – if
return_package
isTrue
, include versioned releases in the record package; otherwise, yield versioned releases instead of compiled releasesstreaming (bool) – if
return_package
isTrue
, set the package’s records to a generator (this only works if the calling code exhausts the generator beforemerge
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:
InconsistentVersionError – if the versions are inconsistent across items to merge
MissingOcidKeyError – if the release is missing an
ocid
fieldUnknownVersionError – if the OCDS version is not recognized