Package: libcoveocds
Command lineCalllibcoveocdsand pass the filename of some JSON data.libcoveocds tests/fixtures/common_checks/basic_1.jsonIt will produce JSON data of the results to standard output. You can pipe this straight into a file to work with.You can also pass--schema-version1.Xto force it to check against a certain version of the schema.In some modes, it will also leave directory of data behind. The following options apply to this mode:Pass--convertto get it to produce spreadsheets of the data.Pass--output-diroutputto specify a directory name (default is a name based on the filename).Pass--deleteto delete the output directory if it already exists (default is to error)Pass--exclude-fileto avoid copying the original file into the output directory (default is to copy)(If none of these are specified, it will not leave any files behind)LibraryTo use this as a Python library as part of a Python script for validating multiple files or testing, you need to:Install the library with pip:pipinstalllibcoveocdsUse it in your Python code, for example:importosimportshutilimporttempfilefromlibcoveocds.apiimportocds_json_outputfromlibcoveocds.configimportLibCoveOCDSConfigdata_directory='path/to/your/directory/with/json/files'temporary_directory=tempfile.mkdtemp(dir=tempfile.gettempdir())config=LibCoveOCDSConfig()config.config['cache_all_requests']=Trueforfile_nameinos.listdir(data_directory):file_path=os.path.join(data_directory,file_name)try:result=ocds_json_output(temporary_directory,file_path,schema_version=None,convert=False,file_type='json',lib_cove_ocds_config=config)finally:shutil.rmtree(temporary_directory)# Do something with the result. For example:ifresult['validation_errors']:forerrorinresult['validation_errors']:print(f'Validation error{error}found in file{file_path}')else:print(f'No validation errors found for{file_path}')Code for use by external usersThe only code that should be used directly by users is thelibcoveocds.configandlibcoveocds.apimodules.Other code (inlibcore,lib, etc.) should not be used by external users of this library directly, as the structure and use of these may change more frequently.Output JSON formatThe output is an object with the following properties:Property (key) nameTypeValuefile_typestringThe type of the file supplied, one ofjson,csv,xlsxorodsversion_usedstringThe version of the OCDS schemas used, e.g.1.1(This is1.0when no version fields exists)schema_urlstringThe URL to the package schema used, e.g.https://standard.open-contracting.org/1.1/en/release-package-schema.jsonextensionsobjectAnextensionsobjectvalidation_errorsarray[object]An array ofvalidation_errorsobjectscommon_error_typesarray[]Always an empty arraydeprecated_fieldsarray[object]An array ofdeprecated_fieldsobjectsreleases_aggregatesobjectAreleases_aggregatesobjectrecords_aggregatesobjectArecords_aggregatesobjectadditional_closed_codelist_valuesobjectA mapping from a codelist field’s JSON Pointer (with array indices removed, e.g.releases/tender/documents/documentType) to anadditional codelist objectadditional_open_codelist_valuesobjectA mapping from a codelist field’s JSON Pointer (with array indices removed, e.g.releases/tender/documents/documentType) to anadditional codelist objectadditional_checksobjectA mapping from an additional check type (currently onlyempty_field) to an array ofadditional check objectsconformance_errorsobjectAconformance_errorsobjectadditional_fieldsarray[object]The top-level additional fields, as an array ofadditional_fieldsobjectsall_additional_fieldsarray[object]All additional fields, including children of other additional fields, as an array ofall_additional_fieldsobjectsjson_deref_errorstringAn exception message for an unresolvable reference (if raised)Note that wherever a schema is used, it is the extended schema (if extensions exist).extensionsProperty (key) nameTypeValueextensionsarray[object]Anextensions/extensionsobjectinvalid_extensionsarray[array[string]]An array of pairs of an extension URL and a human-readable error message, e.g.[["http://etc","404: notfound"]]extended_schema_urlstringThe file the extended schema will be written to, if an output directory has been set, e.g.extended_schema.jsonis_extended_schemabooleanHas the schema been extended?extensions/extensionsProperty (key) nameTypeValueurlstringThe URL of the extension’s metadata file, e.g.https://raw.githubusercontent.com/open-contracting-extensions/ocds_metrics_extension/master/extension.jsonschema_urlstringThe URL of the extension’s release schema file, e.g.https://raw.githubusercontent.com/open-contracting-extensions/ocds_metrics_extension/master/release-schema.jsondescriptionstringExtracted from the metadata filenamestringExtracted from the metadata filedocumentationUrlstringExtracted from the metadata filefailed_codelistsobjectA mapping from an extended codelist name (prefixed with+or-if appropriate) to a human-readable error messagecodelistsarray[string]Extracted from the metadata filevalidation_errorsNote that this list will exclude codelist errors, which instead appear inadditional_closed_codelist_values.lib-cove-ocds uses thejsonschemamodule’suniqueItemsvalidator to check for unique OCIDs and IDs.Property (key) nameTypeValuetypestringThe JSON Schema keyword that caused the validation error, e.g.minLength(full list in the jsonschema lib), unless the keyword istypeorformat, in which case this is the relevanttypeorformat, e.g.arrayordate-timefieldstringThe JSON Pointer to the erroneous data, with array indices removed, e.g.releases/tender/itemsdescriptionstringA human-readable error message, e.g.'id' is missing but required within 'items'pathstringThe JSON Pointer to the erroneous data, e.g.releases/0/tender/items/0valueanyThe value in the data that was erroneous, or""if not applicabledeprecated_fieldsProperty (key) nameTypeValuepathsarray[string]An array of JSON Pointers to parent objects containing deprecated fields, e.g.["releases/0/tender"]explanationarray[string]A pair of the version in which the field was deprecated, and the human-readable deprecation message, e.g.["1.1", "Some explanation text"]fieldstringThe name of the field within the parent object that is deprecated, e.g.amendmentreleases_aggregatesProperty (key) nameTypeValuerelease_countintegerThe number of items in the releases arrayunique_ocidsarray*An array of all ocids, deduplicatedunique_initation_typearray*duplicate_release_idsarray*This is an OCDS implementation error.tagsobjectunique_langarray*unique_award_idarray*planning_countintegertender_countintegeraward_countintegerprocesses_award_countintegercontract_countintegerprocesses_contract_countintegerimplementation_countintegerprocesses_implementation_countintegermin_release_datestring (date-time or “”)max_release_datestring (date-time or “”)min_tender_datestring (date-time or “”)max_tender_datestring (date-time or “”)min_award_datestring (date-time or “”)max_award_datestring (date-time or “”)min_contract_datestring (date-time or “”)max_contract_datestring (date-time or “”)unique_buyers_identifierobjectA mapping from identifier to nameunique_buyers_name_no_idarray*unique_suppliers_identifierobjectA mapping from identifier to nameunique_suppliers_name_no_idarray*unique_procuring_identifierobjectA mapping from identifier to nameunique_procuring_name_no_idarray*unique_tenderers_identifierobjectA mapping from identifier to nameunique_tenderers_name_no_idarray*unique_buyersarray[string]An array of organisation names, with the identifier in brackets if it existsunique_suppliersarray[string]An array of organisation names, with the identifier in brackets if it existsunique_procuringarray[string]An array of organisation names, with the identifier in brackets if it existsunique_tenderersarray[string]An array of organisation names, with the identifier in brackets if it existsunique_buyers_countintegerunique_suppliers_countintegerunique_procuring_countintegerunique_tenderers_countintegerunique_org_identifier_countintegerunique_org_name_countintegerunique_org_countintegerunique_organisation_schemesarray*organisations_with_addressintegerorganisations_with_contact_pointintegertotal_item_countintegerThe sum of the following 3 item counts:tender_item_countintegeraward_item_countintegercontract_item_countintegerunique_item_ids_countintegeritem_identifier_schemesarray*unique_currencyarray*planning_doc_countintegertender_doc_countintegertender_milestones_doc_countintegeraward_doc_countintegercontract_doc_countintegerimplementation_doc_countintegerimplementation_milestones_doc_countintegerplanning_doctypeobjectA mapping fromdocumentType, to the number of occurrencestender_doctypeobjectA mapping fromdocumentType, to the number of occurrencestender_milestones_doctypeobjectA mapping fromdocumentType, to the number of occurrencesaward_doctypeobjectA mapping fromdocumentType, to the number of occurrencescontract_doctypeobjectA mapping fromdocumentType, to the number of occurrencesimplementation_doctypeobjectA mapping fromdocumentType, to the number of occurrencesimplementation_milestones_doctypeobjectA mapping fromdocumentType, to the number of occurrencescontracts_without_awardsarrayAn array of contract objects that don’t have awards.This is an OCDS implementation error.records_aggregatesProperty (key) nameTypeValuecountintegerThe number of items in the records arrayunique_ocidsarray*An array of all ocids, deduplicatedadditional codelist objectProperty (key) nameTypeValuepathstringThe JSON Pointer to the parent object, with array indices removed, e.g.releases/tender/documentsfieldstringThe name of the codelist field, e.g.documentTypecodeliststringThe filename of the codelist, e.g.documentType.csvcodelist_urlstringThe URL of the codelist, e.g.https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/codelists/documentType.csvcodelist_amend_urlsarray[array[string]The URLs of the codelist patches in extensions that modify the codelist, as an array of pairs of+or-and the URL, e.g.[["+","https://raw.githubusercontent.com/open-contracting-extensions/ocds_tariffs_extension/d9df2969030b0a555c24c7db685262c714b4da24/codelists/+documentType.csv"]]isopenbooleanIs this an open codelist?valuesarray*Values of the field that are not in the codelistextension_codelistbooleanIs the codelist added by an extension? (Not only modified by it)additional check objectProperty (key) nameTypeValuejson_locationstringA JSON Pointer to the problematic data, e.g.releases/0/buyerconformance_errorsProperty (key) nameTypeValueocds_prefixes_bad_formatarray[array[string]]An array of pairs of a badocidvalue and the JSON Pointer to it, e.g.["MY-ID","releases/0/ocid"]ocid_descriptionstringThe description of theocidfield from the OCDS schemaocid_info_urlstringThe URL to the identifiers content in the OCDS documentationadditional_fieldsProperty (key) nameTypeValuepathstringThe JSON Pointer to the parent object, with array indices removed, e.g./releases/tenderfieldstringThe name of the additional field, e.g.myFieldusage_countintegerThe number of times the additional field is setall_additional_fieldsProperty (key) nameTypeValuecountintegerThe number of times the additional field is setexamplesarray*A sample of up to 3 values of the fieldroot_additional_fieldbooleanIs the parent object described by the schema?additional_field_descendanceobjectThe additional fields that are descendants of this field. Is only set ifroot_additional_fieldis true. A mapping from an additional field’s JSON Pointer (with array indices removed) to anall_additional_fieldsobject in whichroot_additional_fieldis falsepathstringThe JSON Pointer to the parent object, with array indices removed, e.g./releases/tenderfield_namestringThe name of the additional field, e.g.myFieldarray*An array marked with an asterisk is populated from fields in the data, so could be any type (if the data doesn’t conform to the schema).Contributinglib-cove-ocds was extracted from [cove](https://github.com/OpenDataServices/cove/tree/fa4441b9413324a740b8dc063ffbf0256a353c55).