Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-xmlschema for openSUSE:Factory checked in at 2021-04-26 16:38:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-xmlschema (Old) and /work/SRC/openSUSE:Factory/.python-xmlschema.new.12324 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xmlschema" Mon Apr 26 16:38:45 2021 rev:12 rq:887874 version:1.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-xmlschema/python-xmlschema.changes 2021-03-05 13:45:07.311613770 +0100 +++ /work/SRC/openSUSE:Factory/.python-xmlschema.new.12324/python-xmlschema.changes 2021-04-26 16:38:57.506012038 +0200 @@ -1,0 +2,8 @@ +Thu Apr 22 19:36:20 UTC 2021 - Dirk M??ller <dmuel...@suse.com> + +- update to 1.5.2: + * Improve empty content checking + * Fix simple content restriction of xs:complexType + * Fix facets retrieving for xs:complexType with simple content + +------------------------------------------------------------------- Old: ---- xmlschema-1.5.1.tar.gz New: ---- xmlschema-1.5.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-xmlschema.spec ++++++ --- /var/tmp/diff_new_pack.JkP0cM/_old 2021-04-26 16:38:57.954012751 +0200 +++ /var/tmp/diff_new_pack.JkP0cM/_new 2021-04-26 16:38:57.958012757 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-xmlschema -Version: 1.5.1 +Version: 1.5.2 Release: 0 Summary: An XML Schema validator and decoder License: MIT @@ -38,7 +38,7 @@ Requires: python-elementpath >= 2.1.2 Requires: python-lxml Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives BuildArch: noarch %python_subpackages ++++++ xmlschema-1.5.1.tar.gz -> xmlschema-1.5.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/CHANGELOG.rst new/xmlschema-1.5.2/CHANGELOG.rst --- old/xmlschema-1.5.1/CHANGELOG.rst 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/CHANGELOG.rst 2021-03-04 21:38:45.000000000 +0100 @@ -2,6 +2,12 @@ CHANGELOG ********* +`v1.5.2`_ (2021-03-04) +====================== +* Improve empty content checking +* Fix simple content restriction of xs:complexType +* Fix facets retrieving for xs:complexType with simple content + `v1.5.1`_ (2021-02-11) ====================== * Optimize NamespaceView read-only mapping @@ -408,4 +414,5 @@ .. _v1.4.1: https://github.com/brunato/xmlschema/compare/v1.4.0...v1.4.1 .. _v1.4.2: https://github.com/brunato/xmlschema/compare/v1.4.1...v1.4.2 .. _v1.5.0: https://github.com/brunato/xmlschema/compare/v1.4.2...v1.5.0 -.. _v1.6.0: https://github.com/brunato/xmlschema/compare/v1.5.0...v1.5.1 +.. _v1.5.1: https://github.com/brunato/xmlschema/compare/v1.5.0...v1.5.1 +.. _v1.5.2: https://github.com/brunato/xmlschema/compare/v1.5.1...v1.5.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/PKG-INFO new/xmlschema-1.5.2/PKG-INFO --- old/xmlschema-1.5.1/PKG-INFO 2021-02-11 17:08:15.698073000 +0100 +++ new/xmlschema-1.5.2/PKG-INFO 2021-03-04 21:59:04.384701500 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: xmlschema -Version: 1.5.1 +Version: 1.5.2 Summary: An XML Schema validator and decoder Home-page: https://github.com/sissaschool/xmlschema Author: Davide Brunato @@ -188,3 +188,4 @@ Requires-Python: >=3.6 Provides-Extra: codegen Provides-Extra: dev +Provides-Extra: docs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/doc/api.rst new/xmlschema-1.5.2/doc/api.rst --- old/xmlschema-1.5.1/doc/api.rst 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/doc/api.rst 2021-03-04 21:38:45.000000000 +0100 @@ -396,9 +396,6 @@ .. autoclass:: xmlschema.extras.codegen.AbstractGenerator - .. autoattribute:: xsd_file - .. automethod:: register_filter - .. automethod:: register_test .. automethod:: map_type .. automethod:: list_templates .. automethod:: matching_templates diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/doc/conf.py new/xmlschema-1.5.2/doc/conf.py --- old/xmlschema-1.5.1/doc/conf.py 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/doc/conf.py 2021-03-04 21:38:45.000000000 +0100 @@ -65,7 +65,7 @@ # The short X.Y version. version = '1.5' # The full version, including alpha/beta/rc tags. -release = '1.5.1' +release = '1.5.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/setup.py new/xmlschema-1.5.2/setup.py --- old/xmlschema-1.5.1/setup.py 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/setup.py 2021-03-04 21:38:45.000000000 +0100 @@ -16,7 +16,7 @@ setup( name='xmlschema', - version='1.5.1', + version='1.5.2', packages=find_packages(include=['xmlschema', 'xmlschema.*']), include_package_data=True, entry_points={ @@ -27,12 +27,12 @@ ] }, python_requires='>=3.6', - setup_requires=['elementpath>=2.1.2, <3.0.0'], install_requires=['elementpath>=2.1.2, <3.0.0'], extras_require={ 'codegen': ['elementpath>=2.1.2, <3.0.0', 'jinja2'], 'dev': ['tox', 'coverage', 'lxml', 'elementpath>=2.1.2, <3.0.0', - 'memory_profiler', 'Sphinx', 'sphinx_rtd_theme', 'jinja2'] + 'memory_profiler', 'Sphinx', 'sphinx_rtd_theme', 'jinja2'], + 'docs': ['elementpath>=2.1.2, <3.0.0', 'Sphinx', 'sphinx_rtd_theme', 'jinja2'] }, author='Davide Brunato', author_email='brun...@sissa.it', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/test_cli.py new/xmlschema-1.5.2/tests/test_cli.py --- old/xmlschema-1.5.1/tests/test_cli.py 2020-11-10 11:12:34.000000000 +0100 +++ new/xmlschema-1.5.2/tests/test_cli.py 2021-03-04 21:38:45.000000000 +0100 @@ -13,13 +13,14 @@ from unittest.mock import patch import glob import io +import logging import pathlib import os import platform import sys -from xmlschema.cli import validate, xml2json, json2xml -from xmlschema import to_json +import xmlschema +from xmlschema.cli import get_loglevel, get_converter, validate, xml2json, json2xml WORK_DIRECTORY = os.getcwd() @@ -142,6 +143,15 @@ @patch('sys.stderr', new_callable=io.StringIO) @patch('sys.stdout', new_callable=io.StringIO) def test_xml2json_command_03(self, mock_out, mock_err): + self.run_xml2json('vehicles.xml', '--schema=vehicles.xsd') + os.unlink('vehicles.json') + self.assertEqual(mock_err.getvalue(), '') + self.assertEqual("vehicles.xml converted to vehicles.json\n", mock_out.getvalue()) + self.assertEqual('0', str(self.ctx.exception)) + + @patch('sys.stderr', new_callable=io.StringIO) + @patch('sys.stdout', new_callable=io.StringIO) + def test_xml2json_command_04(self, mock_out, mock_err): self.run_xml2json('vehicles-2_errors.xml') os.unlink('vehicles-2_errors.json') self.assertEqual(mock_err.getvalue(), '') @@ -151,6 +161,25 @@ @patch('sys.stderr', new_callable=io.StringIO) @patch('sys.stdout', new_callable=io.StringIO) + def test_xml2json_command_05(self, mock_out, mock_err): + if os.path.isfile('vehicles.json'): + os.unlink('vehicles.json') + + self.run_xml2json('vehicles.xml') + self.assertEqual('0', str(self.ctx.exception)) + self.run_xml2json('vehicles.xml') + + with self.assertRaises(ValueError) as ctx: + self.run_xml2json('--output=vehicles.json', 'vehicles.xml') + self.assertEqual(str(ctx.exception), "'vehicles.json' is not a directory") + + os.unlink('vehicles.json') + self.assertEqual(mock_err.getvalue(), '') + self.assertIn("vehicles.xml converted to vehicles.json\n", mock_out.getvalue()) + self.assertIn("skip vehicles.json: the destination file exists!", mock_out.getvalue()) + + @patch('sys.stderr', new_callable=io.StringIO) + @patch('sys.stdout', new_callable=io.StringIO) def test_json2xml_command_01(self, mock_out, mock_err): self.run_json2xml() self.assertEqual(mock_out.getvalue(), '') @@ -169,7 +198,7 @@ @patch('sys.stdout', new_callable=io.StringIO) def test_json2xml_command_03(self, mock_out, mock_err): with open('vehicles-test.json', 'w') as fp: - to_json('vehicles.xml', fp) + xmlschema.to_json('vehicles.xml', fp) self.run_json2xml('vehicles-test.json', '--schema=vehicles.xsd') os.unlink('vehicles-test.json') os.unlink('vehicles-test.xml') @@ -178,6 +207,60 @@ mock_out.getvalue()) self.assertEqual('0', str(self.ctx.exception)) + @patch('sys.stderr', new_callable=io.StringIO) + @patch('sys.stdout', new_callable=io.StringIO) + def test_json2xml_command_04(self, mock_out, mock_err): + with open('vehicles-test.json', 'w') as fp: + xmlschema.to_json('vehicles.xml', fp) + + self.run_json2xml('vehicles-test.json', '--schema=vehicles.xsd') + self.assertEqual('0', str(self.ctx.exception)) + self.run_json2xml('vehicles-test.json', '--schema=vehicles.xsd') + + with self.assertRaises(ValueError) as ctx: + self.run_json2xml('vehicles-test.json', '--schema=vehicles.xsd', + '--output=vehicles-test.xml') + self.assertEqual(str(ctx.exception), "'vehicles-test.xml' is not a directory") + + os.unlink('vehicles-test.json') + os.unlink('vehicles-test.xml') + + self.assertEqual(mock_err.getvalue(), '') + self.assertIn("vehicles-test.json converted to vehicles-test.xml\n", + mock_out.getvalue()) + self.assertIn("skip vehicles-test.xml: the destination file exists!", + mock_out.getvalue()) + + @patch('sys.stderr', new_callable=io.StringIO) + @patch('sys.stdout', new_callable=io.StringIO) + def test_wrong_xsd_version(self, mock_out, mock_err): + self.run_validate('--version=1.9', 'vehicles.xml') + self.assertEqual(mock_out.getvalue(), '') + self.assertIn("'1.9' is not a valid XSD version", mock_err.getvalue()) + self.assertEqual('2', str(self.ctx.exception)) + + @patch('sys.stderr', new_callable=io.StringIO) + @patch('sys.stdout', new_callable=io.StringIO) + def test_wrong_defuse(self, mock_out, mock_err): + self.run_validate('--defuse=sometimes', 'vehicles.xml') + self.assertEqual(mock_out.getvalue(), '') + self.assertIn("'sometimes' is not a valid value", mock_err.getvalue()) + self.assertEqual('2', str(self.ctx.exception)) + + def test_get_loglevel(self): + self.assertEqual(get_loglevel(0), logging.ERROR) + self.assertEqual(get_loglevel(1), logging.WARNING) + self.assertEqual(get_loglevel(2), logging.INFO) + self.assertEqual(get_loglevel(3), logging.DEBUG) + + def test_get_converter(self): + self.assertIsNone(get_converter(None)) + self.assertIs(get_converter('Unordered'), xmlschema.UnorderedConverter) + self.assertIs(get_converter('Parker'), xmlschema.ParkerConverter) + + with self.assertRaises(ValueError): + get_converter('Unknown') + if __name__ == '__main__': header_template = "Test xmlschema CLI with Python {} on {}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_attributes.py new/xmlschema-1.5.2/tests/validators/test_attributes.py --- old/xmlschema-1.5.1/tests/validators/test_attributes.py 2021-02-05 09:47:55.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_attributes.py 2021-03-04 21:38:45.000000000 +0100 @@ -64,6 +64,23 @@ self.assertEqual(ctx.exception.message, "attribute use='': value doesn't match any pattern of ['\\\\c+']") + def test_is_empty_attribute(self): + schema = self.check_schema(""" + <xs:attribute name="a1" type="xs:string"/> + <xs:attribute name="a2" type="xs:string" fixed=""/> + <xs:attribute name="a3" type="emptyString"/> + + <xs:simpleType name="emptyString"> + <xs:restriction base="xs:string"> + <xs:maxLength value="0"/> + </xs:restriction> + </xs:simpleType> + """) + + self.assertFalse(schema.attributes['a1'].is_empty()) + self.assertTrue(schema.attributes['a2'].is_empty()) + self.assertTrue(schema.attributes['a3'].is_empty()) + def test_wrong_attribute_type(self): self.check_schema(""" <xs:attributeGroup name="alpha"> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_complex_types.py new/xmlschema-1.5.2/tests/validators/test_complex_types.py --- old/xmlschema-1.5.1/tests/validators/test_complex_types.py 2021-02-05 09:47:55.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_complex_types.py 2021-03-04 21:38:45.000000000 +0100 @@ -420,6 +420,39 @@ xsd_type = schema.types['type1'] self.assertIs(xsd_type.content_type, xsd_type.content) + def test_is_empty(self): + schema = self.check_schema(""" + <xs:complexType name="emptyType1"/> + + <xs:complexType name="emptyType2"> + <xs:sequence/> + </xs:complexType> + + <xs:complexType name="emptyType3"> + <xs:complexContent> + <xs:restriction base="xs:anyType"/> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="notEmptyType1"> + <xs:sequence> + <xs:element name="elem1"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="notEmptyType2"> + <xs:complexContent> + <xs:extension base="xs:anyType"/> + </xs:complexContent> + </xs:complexType> + """) + + self.assertTrue(schema.types['emptyType1'].is_empty()) + self.assertTrue(schema.types['emptyType2'].is_empty()) + self.assertTrue(schema.types['emptyType3'].is_empty()) + self.assertFalse(schema.types['notEmptyType1'].is_empty()) + self.assertFalse(schema.types['notEmptyType2'].is_empty()) + class TestXsd11ComplexType(TestXsdComplexType): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_elements.py new/xmlschema-1.5.2/tests/validators/test_elements.py --- old/xmlschema-1.5.1/tests/validators/test_elements.py 2021-02-05 09:47:55.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_elements.py 2021-03-04 21:38:45.000000000 +0100 @@ -106,6 +106,23 @@ self.assertEqual(model_group[1].value_constraint, 'alpha') self.assertEqual(model_group[2].value_constraint, 'beta') + def test_is_empty_attribute(self): + schema = self.check_schema(""" + <xs:element name="e1" type="xs:string"/> + <xs:element name="e2" type="xs:string" fixed=""/> + <xs:element name="e3" type="emptyString"/> + + <xs:simpleType name="emptyString"> + <xs:restriction base="xs:string"> + <xs:maxLength value="0"/> + </xs:restriction> + </xs:simpleType> + """) + + self.assertFalse(schema.elements['e1'].is_empty()) + self.assertTrue(schema.elements['e2'].is_empty()) + self.assertTrue(schema.elements['e3'].is_empty()) + class TestXsd11Elements(TestXsdElements): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_particles.py new/xmlschema-1.5.2/tests/validators/test_particles.py --- old/xmlschema-1.5.1/tests/validators/test_particles.py 2021-01-24 22:47:47.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_particles.py 2021-03-04 21:38:45.000000000 +0100 @@ -44,6 +44,8 @@ def test_is_empty(self): self.assertFalse(self.schema.elements['cars'].is_empty()) + self.assertFalse(ParticleMixin().is_empty()) + self.assertTrue(ParticleMixin(min_occurs=0, max_occurs=0).is_empty()) def test_is_single(self): self.assertTrue(self.schema.elements['cars'].is_single()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_schema_class.py new/xmlschema-1.5.2/tests/validators/test_schema_class.py --- old/xmlschema-1.5.1/tests/validators/test_schema_class.py 2021-02-05 09:47:55.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_schema_class.py 2021-03-04 21:38:45.000000000 +0100 @@ -217,6 +217,14 @@ self.assertEqual(set(schema.root_elements), {schema.elements['root1'], schema.elements['root2']}) + def test_simple_types(self): + self.assertListEqual(self.vh_schema.simple_types, []) + self.assertGreater(len(self.st_schema.simple_types), 20) + + def test_complex_types(self): + self.assertListEqual(self.vh_schema.complex_types, + [self.vh_schema.types['vehicleType']]) + def test_is_restriction_method(self): # Test issue #111 fix schema = self.schema_class(source=self.casepath('issues/issue_111/issue_111.xsd')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_simple_types.py new/xmlschema-1.5.2/tests/validators/test_simple_types.py --- old/xmlschema-1.5.1/tests/validators/test_simple_types.py 2021-02-05 09:47:55.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_simple_types.py 2021-03-04 21:38:45.000000000 +0100 @@ -143,6 +143,37 @@ </xs:restriction> </xs:simpleType>""") + def test_is_empty(self): + schema = self.check_schema(""" + <xs:simpleType name="emptyType1"> + <xs:restriction base="xs:string"> + <xs:maxLength value="0"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="emptyType2"> + <xs:restriction base="xs:string"> + <xs:length value="0"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="emptyType3"> + <xs:restriction base="xs:string"> + <xs:enumeration value=""/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="notEmptyType1"> + <xs:restriction base="xs:string"> + <xs:enumeration value=" "/> + </xs:restriction> + </xs:simpleType>""") + + self.assertTrue(schema.types['emptyType1'].is_empty()) + self.assertTrue(schema.types['emptyType2'].is_empty()) + self.assertTrue(schema.types['emptyType3'].is_empty()) + self.assertFalse(schema.types['notEmptyType1'].is_empty()) + class TestXsd11SimpleTypes(TestXsdSimpleTypes): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tests/validators/test_xsdbase.py new/xmlschema-1.5.2/tests/validators/test_xsdbase.py --- old/xmlschema-1.5.1/tests/validators/test_xsdbase.py 2021-02-05 10:05:33.000000000 +0100 +++ new/xmlschema-1.5.2/tests/validators/test_xsdbase.py 2021-03-04 21:38:45.000000000 +0100 @@ -19,6 +19,7 @@ XMLSchema11, XMLSchemaParseError, XMLSchemaValidationError, XsdGroup, XsdSimpleType from xmlschema.names import XSD_NAMESPACE, XSD_ELEMENT, XSD_ANNOTATION, XSD_ANY_TYPE from xmlschema.etree import ElementTree +from xmlschema.dataobjects import DataElement CASES_DIR = os.path.join(os.path.dirname(__file__), '../test_cases') @@ -649,6 +650,22 @@ self.assertIn(self.schema.elements['bikes'].name, obj) self.assertEqual(len(errors), 2) + def test_decode_to_objects(self): + xml_file = os.path.join(CASES_DIR, 'examples/vehicles/vehicles.xml') + root = ElementTree.parse(xml_file).getroot() + + obj = self.schema.elements['vehicles'].to_objects(root) + self.assertIsInstance(obj, DataElement) + self.assertEqual(self.schema.elements['vehicles'].name, obj.tag) + self.assertIs(obj.__class__, DataElement) + + obj = self.schema.elements['vehicles'].to_objects(root, with_bindings=True) + self.assertIsInstance(obj, DataElement) + self.assertEqual(self.schema.elements['vehicles'].name, obj.tag) + self.assertIsNot(obj.__class__, DataElement) + self.assertTrue(issubclass(obj.__class__, DataElement)) + self.assertEqual(obj.__class__.__name__, 'VehiclesBinding') + def test_encode(self): xml_file = os.path.join(CASES_DIR, 'examples/vehicles/vehicles.xml') obj = self.schema.decode(xml_file) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/tox.ini new/xmlschema-1.5.2/tox.ini --- old/xmlschema-1.5.1/tox.ini 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/tox.ini 2021-03-04 21:38:45.000000000 +0100 @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py{36,37,38,39}, pypy3, ep21{2,3,4}, docs, flake8, coverage +envlist = py{36,37,38,39}, pypy3, ep21{2,3,4}, ep220, docs, flake8, coverage skip_missing_interpreters = true toxworkdir = {homedir}/.tox/xmlschema @@ -51,6 +51,11 @@ elementpath==2.1.4 lxml +[testenv:ep220] +deps = + elementpath==2.2.0 + lxml + [testenv:docs] commands = make -C doc html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema/__init__.py new/xmlschema-1.5.2/xmlschema/__init__.py --- old/xmlschema-1.5.1/xmlschema/__init__.py 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema/__init__.py 2021-03-04 21:38:45.000000000 +0100 @@ -30,7 +30,7 @@ XsdComponent, XsdType, XsdElement, XsdAttribute ) -__version__ = '1.5.1' +__version__ = '1.5.2' __author__ = "Davide Brunato" __contact__ = "brun...@sissa.it" __copyright__ = "Copyright 2016-2021, SISSA" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema/cli.py new/xmlschema-1.5.2/xmlschema/cli.py --- old/xmlschema-1.5.1/xmlschema/cli.py 2020-11-10 11:13:55.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema/cli.py 2021-03-04 21:38:45.000000000 +0100 @@ -34,15 +34,13 @@ def xsd_version_number(value): if value not in ('1.0', '1.1'): - msg = "%r is not an XSD version." % value - raise argparse.ArgumentTypeError(msg) + raise argparse.ArgumentTypeError("%r is not a valid XSD version" % value) return value def defuse_data(value): if value not in ('always', 'remote', 'never'): - msg = "%r is not a valid value." % value - raise argparse.ArgumentTypeError(msg) + raise argparse.ArgumentTypeError("%r is not a valid value" % value) return value @@ -87,6 +85,9 @@ "{!r}.".format(tuple(CONVERTERS_MAP))) parser.add_argument('--lazy', action='store_true', default=False, help="use lazy decoding mode (slower but use less memory).") + parser.add_argument('--defuse', metavar='(always, remote, never)', + type=defuse_data, default='remote', + help="when to defuse XML data, on remote resources for default.") parser.add_argument('-o', '--output', type=str, default='.', help="where to write the encoded XML files, current dir by default.") parser.add_argument('-f', '--force', action="store_true", default=False, @@ -126,6 +127,7 @@ cls=schema_class, converter=converter, lazy=args.lazy, + defuse=args.defuse, validation='lax', ) except (xmlschema.XMLSchemaException, URLError) as err: @@ -231,6 +233,9 @@ metavar="URI/URL", help="schema location hint overrides.") parser.add_argument('--lazy', action='store_true', default=False, help="use lazy validation mode (slower but use less memory).") + parser.add_argument('--defuse', metavar='(always, remote, never)', + type=defuse_data, default='remote', + help="when to defuse XML data, on remote resources for default.") parser.add_argument('files', metavar='[XML_FILE ...]', nargs='+', help="XML files to be validated.") @@ -239,7 +244,8 @@ tot_errors = 0 for filepath in args.files: try: - errors = list(iter_errors(filepath, schema=args.schema, lazy=args.lazy)) + errors = list(iter_errors(filepath, schema=args.schema, + lazy=args.lazy, defuse=args.defuse)) except (xmlschema.XMLSchemaException, URLError) as err: tot_errors += 1 print(str(err)) @@ -252,11 +258,3 @@ print("{} is not valid".format(filepath)) sys.exit(tot_errors) - - -if __name__ == '__main__': - if sys.version_info < (3, 5, 0): - sys.stderr.write("You need python 3.5 or later to run this program\n") - sys.exit(1) - - validate() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema/validators/attributes.py new/xmlschema-1.5.2/xmlschema/validators/attributes.py --- old/xmlschema-1.5.1/xmlschema/validators/attributes.py 2021-01-24 22:47:47.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema/validators/attributes.py 2021-03-04 21:38:45.000000000 +0100 @@ -195,6 +195,9 @@ def is_prohibited(self): return self.use == 'prohibited' + def is_empty(self): + return self.fixed == '' or self.type.is_empty() + def iter_components(self, xsd_classes=None): if xsd_classes is None or isinstance(self, xsd_classes): yield self diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema/validators/complex_types.py new/xmlschema-1.5.2/xmlschema/validators/complex_types.py --- old/xmlschema-1.5.1/xmlschema/validators/complex_types.py 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema/validators/complex_types.py 2021-03-04 21:38:45.000000000 +0100 @@ -294,16 +294,23 @@ self.content = self.schema.create_any_content_group(self) self._parse_content_tail(elem) else: - if base_type.has_simple_content(): + if base_type.is_empty(): + self.content = self.schema.BUILDERS.restriction_class(elem, self.schema, self) + if not self.is_empty(): + self.parse_error("a not empty simpleContent cannot restrict " + "an empty content type", elem) + self.content = self.schema.create_any_content_group(self) + + elif base_type.has_simple_content(): self.content = self.schema.BUILDERS.restriction_class(elem, self.schema, self) if not self.content.is_derived(base_type.content, 'restriction'): - self.parse_error("Content type is not a restriction of base content", elem) + self.parse_error("content type is not a restriction of base content", elem) elif base_type.mixed and base_type.is_emptiable(): self.content = self.schema.BUILDERS.restriction_class(elem, self.schema, self) else: - self.parse_error("with simpleContent cannot restrict an empty or " - "an element-only content type", base_type.elem) + self.parse_error("with simpleContent cannot restrict an " + "element-only content type", elem) self.content = self.schema.create_any_content_group(self) self._parse_content_tail(elem, derivation='restriction', @@ -613,9 +620,9 @@ if xsd_classes is None or isinstance(obj, xsd_classes): yield obj - @staticmethod - def get_facet(*_args, **_kwargs): - return None + def get_facet(self, tag): + if isinstance(self.content, XsdSimpleType): + return self.content.get_facet(tag) def admit_simple_restriction(self): if 'restriction' in self.final: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema/validators/elements.py new/xmlschema-1.5.2/xmlschema/validators/elements.py --- old/xmlschema-1.5.1/xmlschema/validators/elements.py 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema/validators/elements.py 2021-03-04 21:38:45.000000000 +0100 @@ -629,7 +629,7 @@ else: nilled = True - if xsd_type.is_empty() and elem.text: + if xsd_type.is_empty() and elem.text and xsd_type.normalize(elem.text): reason = "character data is not allowed because content is empty" yield self.validation_error(validation, reason, elem, **kwargs) @@ -1047,6 +1047,9 @@ except AttributeError: return True + def is_empty(self): + return self.fixed == '' or self.type.is_empty() + class Xsd11Element(XsdElement): """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema/validators/simple_types.py new/xmlschema-1.5.2/xmlschema/validators/simple_types.py --- old/xmlschema-1.5.1/xmlschema/validators/simple_types.py 2021-02-11 15:32:40.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema/validators/simple_types.py 2021-03-04 21:38:45.000000000 +0100 @@ -349,7 +349,8 @@ return '{}+'.format(sequence_type) def is_empty(self): - return self.max_length == 0 + return self.max_length == 0 or \ + self.enumeration is not None and all(v == '' for v in self.enumeration) def is_emptiable(self): return self.allow_empty diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema.egg-info/PKG-INFO new/xmlschema-1.5.2/xmlschema.egg-info/PKG-INFO --- old/xmlschema-1.5.1/xmlschema.egg-info/PKG-INFO 2021-02-11 17:08:15.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema.egg-info/PKG-INFO 2021-03-04 21:59:04.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: xmlschema -Version: 1.5.1 +Version: 1.5.2 Summary: An XML Schema validator and decoder Home-page: https://github.com/sissaschool/xmlschema Author: Davide Brunato @@ -188,3 +188,4 @@ Requires-Python: >=3.6 Provides-Extra: codegen Provides-Extra: dev +Provides-Extra: docs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmlschema-1.5.1/xmlschema.egg-info/requires.txt new/xmlschema-1.5.2/xmlschema.egg-info/requires.txt --- old/xmlschema-1.5.1/xmlschema.egg-info/requires.txt 2021-02-11 17:08:15.000000000 +0100 +++ new/xmlschema-1.5.2/xmlschema.egg-info/requires.txt 2021-03-04 21:59:04.000000000 +0100 @@ -13,3 +13,9 @@ Sphinx sphinx_rtd_theme jinja2 + +[docs] +elementpath<3.0.0,>=2.1.2 +Sphinx +sphinx_rtd_theme +jinja2