Skip to content

Commit

Permalink
Merge pull request #109 from OpenDataServices/codelists
Browse files Browse the repository at this point in the history
Codelist changes for 360Giving
  • Loading branch information
Bjwebb authored Dec 14, 2022
2 parents d6f108e + 44f1d42 commit 76e5df1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.6
python-version: 3.7
- name: InstallCommon
run: |
sudo apt-get install gettext translate-toolkit
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ jobs:
# libcove doesn't support Windows.
# https://github.com/OpenDataServices/lib-cove/issues/53
# We also only use Linux servers, so don't test on Mac
os: [ubuntu-latest]
# Need to use an older Ubuntu so Python 3.6 is available
os: [ubuntu-20.04]
python-version: [ 3.6, 3.7, 3.8, 3.9, "3.10", "3.11" ]
jsonref-version: ["==0.3", ">1"]
steps:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## Added

## [0.29.0] - 2022-12-14

- Add `SchemaJsonMixin.process_codelists` (previously only existed in lib-cove-ocds, will be used by 360 CoVE) https://github.com/OpenDataServices/lib-cove/pull/109

## [0.28.0] - 2022-11-18

### Fixed
Expand Down
27 changes: 26 additions & 1 deletion libcove/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,39 @@ def get_schema_obj(self, deref=False):
return self.deref_schema(self.schema_str)
return self._schema_obj

def get_pkg_schema_obj(self, deref=False):
def get_pkg_schema_obj(self, deref=False, use_extensions=False):
if deref:
return self.deref_schema(self.pkg_schema_str)
return self._pkg_schema_obj

def get_pkg_schema_fields(self):
return set(schema_dict_fields_generator(self.get_pkg_schema_obj(deref=True)))

def process_codelists(self):
# From https://github.com/open-contracting/lib-cove-ocds/blob/051c25717f22f20c968b13071805a4b79c82b91c/libcoveocds/schema.py#L99-L160
# but with support for extended codelists removed.

self.core_codelist_schema_paths = get_schema_codelist_paths(
self, use_extensions=False
)
self.extended_codelist_schema_paths = self.core_codelist_schema_paths

core_unique_files = frozenset(
value[0] for value in self.core_codelist_schema_paths.values()
)
self.core_codelists = load_core_codelists(
self.codelists,
core_unique_files,
config=self.config if hasattr(self, "config") else None,
)

self.extended_codelists = self.core_codelists
self.extended_codelist_urls = {}
# we do not want to cache if the requests failed.
if not self.core_codelists:
load_core_codelists.cache_clear()
return


def schema_dict_fields_generator(schema_dict):
if "properties" in schema_dict and isinstance(schema_dict["properties"], dict):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="libcove",
version="0.28.0",
version="0.29.0",
author="Open Data Services",
author_email="[email protected]",
url="https://github.com/OpenDataServices/lib-cove",
Expand Down

0 comments on commit 76e5df1

Please sign in to comment.