diff --git a/a3m/cli/client/__main__.py b/a3m/cli/client/__main__.py index ca6e42563..5ceb12365 100644 --- a/a3m/cli/client/__main__.py +++ b/a3m/cli/client/__main__.py @@ -13,6 +13,7 @@ from a3m.api.transferservice import v1beta1 as transfer_service_api from a3m.cli.client.wrapper import ClientWrapper +from a3m.cli.common import configure_xml_catalog_files from a3m.cli.common import init_django from a3m.cli.common import suppress_warnings from a3m.server.rpc.client import Client @@ -53,6 +54,7 @@ def main(ctx, uri, name, address, processing_config, wait_for_ready, no_input): """ init_django() suppress_warnings() + configure_xml_catalog_files() # Disable logging. if not settings.DEBUG: diff --git a/a3m/cli/common.py b/a3m/cli/common.py index 0796bcfd7..033819364 100644 --- a/a3m/cli/common.py +++ b/a3m/cli/common.py @@ -1,4 +1,5 @@ import os +import pathlib import sys import warnings @@ -25,3 +26,10 @@ def init_django(): """ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "a3m.settings.common") django.setup() + + +def configure_xml_catalog_files(): + """Use local XML schemas for validation.""" + os.environ["XML_CATALOG_FILES"] = str( + pathlib.Path(__file__).parent.parent / "client/assets/catalog/catalog.xml" + ) diff --git a/a3m/cli/server/__main__.py b/a3m/cli/server/__main__.py index 358fcc23b..3232be865 100644 --- a/a3m/cli/server/__main__.py +++ b/a3m/cli/server/__main__.py @@ -7,6 +7,7 @@ from django.conf import settings from a3m import __version__ +from a3m.cli.common import configure_xml_catalog_files from a3m.cli.common import init_django from a3m.cli.common import suppress_warnings @@ -17,6 +18,7 @@ def main(): init_django() suppress_warnings() + configure_xml_catalog_files() from a3m.server.runner import create_server diff --git a/a3m/client/__init__.py b/a3m/client/__init__.py index a60a0d6a8..982d945de 100644 --- a/a3m/client/__init__.py +++ b/a3m/client/__init__.py @@ -1,6 +1,12 @@ import os +import pathlib THIS_DIR = os.path.dirname(__file__) ASSETS_DIR = os.path.join(THIS_DIR, "assets", "") + +# Use local XML schemas for validation. +os.environ["XML_CATALOG_FILES"] = str( + pathlib.Path(__file__).parent / "assets/catalog/catalog.xml" +) diff --git a/a3m/client/assets/catalog/catalog.xml b/a3m/client/assets/catalog/catalog.xml new file mode 100644 index 000000000..51460c5de --- /dev/null +++ b/a3m/client/assets/catalog/catalog.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/a3m/client/assets/mets/xlink.xsd b/a3m/client/assets/mets/xlink.xsd new file mode 100644 index 000000000..f55eb6dae --- /dev/null +++ b/a3m/client/assets/mets/xlink.xsd @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/a3m/client/assets/mods/mods.xsd b/a3m/client/assets/mods/mods.xsd new file mode 100644 index 000000000..74d98bb90 --- /dev/null +++ b/a3m/client/assets/mods/mods.xsd @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/a3m/client/assets/mods/xml.xsd b/a3m/client/assets/mods/xml.xsd new file mode 100644 index 000000000..bb367ccf5 --- /dev/null +++ b/a3m/client/assets/mods/xml.xsd @@ -0,0 +1,146 @@ + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + id (as an attribute name): denotes an attribute whose value + should be interpreted as if declared to be of type ID. + The xml:id specification is not yet a W3C Recommendation, + but this attribute is included here to facilitate experimentation + with the mechanisms it proposes. Note that it is _not_ included + in the specialAttrs attribute group. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang, xml:space or xml:id + attributes on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2005/08/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself, or with the XML namespace itself. In other words, if the XML + Schema or XML namespaces change, the version of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2005/08/xml.xsd will not change. + + + + + + Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. See + RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry + at http://www.iana.org/assignments/lang-tag-apps.htm for + further information. + + The union allows for the 'un-declaration' of xml:lang with + the empty string. + + + + + + + + + + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + See http://www.w3.org/TR/xml-id/ for + information about this attribute. + + + + + + + + + + \ No newline at end of file diff --git a/a3m/client/assets/premis/premis-v2-2.xsd b/a3m/client/assets/premis/premis-v2-2.xsd new file mode 100644 index 000000000..1d5392727 --- /dev/null +++ b/a3m/client/assets/premis/premis-v2-2.xsd @@ -0,0 +1,1387 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/requirements-dev.txt b/requirements-dev.txt index 17af9eebd..5509bd902 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -75,8 +75,6 @@ filelock==3.12.2 # virtualenv flake8==4.0.1 # via a3m (setup.py) -future==0.18.3 - # via metsrw gitdb==4.0.9 # via gitpython gitpython==3.1.32 @@ -132,7 +130,7 @@ mccabe==0.6.1 # via # flake8 # pylint -metsrw==0.3.21 +metsrw==0.4.0 # via a3m (setup.py) multidict==6.0.2 # via yarl @@ -235,7 +233,6 @@ semantic-version==2.6.0 # via releases six==1.16.0 # via - # metsrw # python-dateutil # vcrpy smmap==5.0.0 diff --git a/requirements.txt b/requirements.txt index 8e1f65b40..44fbed11e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,8 +34,6 @@ commonmark==0.9.1 # via rich django==3.2.20 # via a3m (setup.py) -future==0.18.3 - # via metsrw googleapis-common-protos==1.60.0 # via # a3m (setup.py) @@ -62,7 +60,7 @@ lxml==4.9.3 # a3m (setup.py) # ammcpc # metsrw -metsrw==0.3.21 +metsrw==0.4.0 # via a3m (setup.py) prometheus-client==0.14.1 # via a3m (setup.py) @@ -88,9 +86,7 @@ rich==10.16.2 s3transfer==0.5.2 # via boto3 six==1.16.0 - # via - # metsrw - # python-dateutil + # via python-dateutil sqlparse==0.4.4 # via django tenacity==8.0.1 diff --git a/setup.cfg b/setup.cfg index 185da65c2..d365ccc29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ python_requires = ~=3.9 install_requires = # Used by client modules ammcpc~=0.1 - metsrw~=0.3 + metsrw~=0.4 bagit~=1.7 clamd~=1.0 lxml~=4.7 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..dd1a22db7 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,15 @@ +import pathlib + +import pytest + + +@pytest.fixture(autouse=True) +def set_xml_catalog_files(monkeypatch): + """Use local XML schemas for validation.""" + monkeypatch.setenv( + "XML_CATALOG_FILES", + str( + pathlib.Path(__file__).parent.parent + / "a3m/client/assets/catalog/catalog.xml" + ), + )