diff --git a/Dockerfile b/Dockerfile index 2dd0553..674345d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,12 @@ COPY requirements.txt requirements-dev.txt /tmp/ # (generated by 'task wheel') from that repo and uncomment # the following lines. Also comment out the datatrails-archivist line in # requirements.txt. +# cp ~/git/datatrails-python/dist/*.whl . # That way one can test an unreleased version of github datatrails-samples. # NB dont forget to recomment before merging !! -#COPY datatrails*.whl /tmp/ -#RUN python3 -m pip -qq install /tmp/datatrails*.whl \ -# && rm -f /tmp/datatrails*.whl +# COPY datatrails*.whl /tmp/ +# RUN python3 -m pip -qq install /tmp/datatrails*.whl \ +# && rm -f /tmp/datatrails*.whl RUN python3 -m pip -qq install --upgrade pip \ && python3 -m pip -qq install -r /tmp/requirements-dev.txt \ diff --git a/archivist_samples/archivist.py b/archivist_samples/archivist.py new file mode 100644 index 0000000..ad0892c --- /dev/null +++ b/archivist_samples/archivist.py @@ -0,0 +1,16 @@ +"""Local Archivist class +""" + +# pylint: disable=missing-docstring +# pylint: disable=too-few-public-methods + +from archivist.archivist import Archivist as _Archivist + +from .about import __version__ as VERSION +from .constants import USER_AGENT_PREFIX + + +class Archivist(_Archivist): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.user_agent = f"{USER_AGENT_PREFIX}{VERSION}" diff --git a/archivist_samples/c2pa/c2pa.py b/archivist_samples/c2pa/c2pa.py index 24ae229..b37b254 100644 --- a/archivist_samples/c2pa/c2pa.py +++ b/archivist_samples/c2pa/c2pa.py @@ -21,7 +21,7 @@ from ..testing.assets import make_assets_create, AttachmentDescription if TYPE_CHECKING: - from archivist.archivist import Archivist + from ..archivist import Archivist LOGGER = logging.getLogger(__name__) diff --git a/archivist_samples/testing/constants.py b/archivist_samples/constants.py similarity index 100% rename from archivist_samples/testing/constants.py rename to archivist_samples/constants.py diff --git a/archivist_samples/document/document.py b/archivist_samples/document/document.py index f713616..d876336 100644 --- a/archivist_samples/document/document.py +++ b/archivist_samples/document/document.py @@ -21,7 +21,7 @@ from ..testing.assets import make_assets_create, AttachmentDescription if TYPE_CHECKING: - from archivist.archivist import Archivist + from ..archivist import Archivist LOGGER = logging.getLogger(__name__) diff --git a/archivist_samples/sbom_document/software_package.py b/archivist_samples/sbom_document/software_package.py index b13c561..ecba84d 100644 --- a/archivist_samples/sbom_document/software_package.py +++ b/archivist_samples/sbom_document/software_package.py @@ -14,7 +14,7 @@ from sys import exit as sys_exit from typing import List, Optional -from archivist import archivist as type_helper +from .. import archivist as type_helper from ..testing.assets import make_assets_create, AttachmentDescription diff --git a/archivist_samples/testing/archivist_parser.py b/archivist_samples/testing/archivist_parser.py index f038b4d..4c1a936 100644 --- a/archivist_samples/testing/archivist_parser.py +++ b/archivist_samples/testing/archivist_parser.py @@ -13,11 +13,9 @@ import logging from sys import exit as sys_exit -from archivist.archivist import Archivist from archivist.logger import set_logger -from ..about import __version__ as VERSION -from .constants import USER_AGENT_PREFIX +from ..archivist import Archivist LOGGER = logging.getLogger(__name__) @@ -114,11 +112,11 @@ def endpoint(args): args.url, authtoken, partner_id=args.partner_id, - user_agent=f"{USER_AGENT_PREFIX}{VERSION}", ) if arch is None: LOGGER.error("Critical error. Aborting.") sys_exit(1) + LOGGER.info("User agent is %s", arch.user_agent) return arch diff --git a/requirements.txt b/requirements.txt index 636e0db..ab838b6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ pyyaml~=6.0.1 # the following lines. Also do similar in the Dockerfile. # That way one can test an unreleased version of github datatrails-samples. # NB dont forget to uncomment before merging !! -datatrails-archivist==0.31.2 +datatrails-archivist==0.31.3