Utilities

ocdskit.util.grouper(iterable, n, fillvalue=None)[source]
class ocdskit.util.SerializableGenerator(iterable)[source]
ocdskit.util.iterencode(data, ensure_ascii=False, **kwargs)[source]

Returns a generator that yields each string representation as available.

ocdskit.util.json_dump(data, io, ensure_ascii=False, **kwargs)[source]

Dumps JSON to a file-like object.

ocdskit.util.json_dumps(data, ensure_ascii=False, indent=None, sort_keys=False, **kwargs)[source]

Dumps JSON to a string, and returns it.

ocdskit.util.get_ocds_minor_version(data)[source]

Returns the OCDS minor version of the record package, release package, record or release.

ocdskit.util.is_package(data)[source]

Returns whether the data is a record package or release package.

ocdskit.util.is_record_package(data)[source]

Returns whether the data is a record package.

A record package has a required records field. Its other required fields are shared with release packages.

ocdskit.util.is_record(data)[source]

Returns whether the data is a record.

A record has required releases and ocid fields.

ocdskit.util.is_release_package(data)[source]

Returns whether the data is a release package.

A release package has a required releases field. Its other required fields are shared with record packages. To distinguish a release package from a record, we test for the absence of the ocid field.

ocdskit.util.is_release(data)[source]

Returns whether the data is a release (embedded or linked, individual or compiled).

ocdskit.util.is_compiled_release(data)[source]

Returns whether the data is a compiled release (embedded or linked).

ocdskit.util.is_linked_release(data)[source]

Returns whether the data is a linked release.

A linked release has required url and date fields and an optional tag field. An embedded release has required date and tag fields (among others), and it can have a url field as an additional field.

To distinguish a linked release from an embedded release, we test for the presence of the required url field and test whether the number of fields is fewer than three.