From 75707e68e01120b2fc7b004068c84da43ced7f3b Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:54:48 -0500 Subject: [PATCH] feat: ProfileBuilder accepts standard_base_url as the bytes of a ZIP file --- docs/changelog.rst | 7 ++++++- docs/conf.py | 2 +- ocdsextensionregistry/profile_builder.py | 6 ++++-- ocdsextensionregistry/util.py | 3 +++ pyproject.toml | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6b480b1..bbeedef 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,11 @@ Changelog ========= +0.6.9 (2025-01-07) +------------------ + +- :class:`~ocdsextensionregistry.profile_builder.ProfileBuilder` also accepts ``standard_base_url`` as the bytes of a ZIP file. + 0.6.8 (2024-12-17) ------------------ @@ -142,7 +147,7 @@ Changelog 0.3.4 (2023-07-08) ------------------ -- feat: :class:`~ocdsextensionregistry.profile_builder.ProfileBuilder` accepts ``standard_base_url`` as a ZIP file, in addition to a directory. +- feat: :class:`~ocdsextensionregistry.profile_builder.ProfileBuilder` also accepts ``standard_base_url`` as a ``file://`` URL to a ZIP file. 0.3.3 (2023-07-07) ------------------ diff --git a/docs/conf.py b/docs/conf.py index 9b7519f..0740f08 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,7 +23,7 @@ author = "Open Contracting Partnership" # The short X.Y version -version = "0.6.8" +version = "0.6.9" # The full version, including alpha/beta/rc tags release = version diff --git a/ocdsextensionregistry/profile_builder.py b/ocdsextensionregistry/profile_builder.py index 562e642..f14e5a4 100644 --- a/ocdsextensionregistry/profile_builder.py +++ b/ocdsextensionregistry/profile_builder.py @@ -69,10 +69,12 @@ def __init__(self, standard_tag, extension_versions, registry_base_url=None, sta :param extension_versions: the extension versions :param str registry_base_url: the registry's base URL, defaults to ``'https://raw.githubusercontent.com/open-contracting/extension_registry/main/'`` - :param str standard_base_url: the standard's base URL, defaults to - ``'https://codeload.github.com/open-contracting/standard/zip/' + standard_tag`` + :param standard_base_url: the standard's base URL, defaults to + ``f'https://codeload.github.com/open-contracting/standard/zip/{standard_tag}'`` + (can be a ``file://`` URL to a directory or a ZIP file, or the bytes of a ZIP file) :param str schema_base_url: the schema's base URL, e.g. ``'https://standard.open-contracting.org/profiles/ppp/schema/1__0__0__beta/'`` + :type standard_base_url: str or bytes :type extension_versions: dict or list """ # Allows setting the registry URL to e.g. a pull request, when working on a profile. diff --git a/ocdsextensionregistry/util.py b/ocdsextensionregistry/util.py index 2fd71bb..40dc525 100644 --- a/ocdsextensionregistry/util.py +++ b/ocdsextensionregistry/util.py @@ -115,6 +115,9 @@ def _resolve(data_or_url): def _resolve_zip(url, base=''): + if isinstance(url, bytes): + return ZipFile(BytesIO(url)) + parsed = urlsplit(url) if parsed.scheme == 'file': diff --git a/pyproject.toml b/pyproject.toml index 783537a..85e5a01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ocdsextensionregistry" -version = "0.6.8" +version = "0.6.9" authors = [{name = "Open Contracting Partnership", email = "data@open-contracting.org"}] description = "Eases access to information from the extension registry of the Open Contracting Data Standard" readme = "README.rst"