Skip to content

Commit

Permalink
Merge pull request #2 from kiesraad/update-docs
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
chrismostert authored Jan 9, 2024
2 parents f74ed59 + ea6ead9 commit 3e15fa3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ cython_debug/
#.idea/

# Testdata
test/data
data
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Python bindings for the EML_NL Standard
Data bindings for the EML_NL Standard to load EML_NL files into Python [dataclasses](https://docs.python.org/3/library/dataclasses.html) with correct structure, datatypes and typehints following the [EML_NL Xml Schema Definitions](https://www.kiesraad.nl/adviezen-en-publicaties/formulieren/2016/osv/eml-bestanden/eml_nl_1_2_1-xsd). Type hints can be staticically checked using [mypy](https://mypy-lang.org/) or [pyright](https://github.com/microsoft/pyright).
Data bindings for the EML_NL Standard to load EML_NL files into Python [dataclasses](https://docs.python.org/3/library/dataclasses.html) with correct structure, datatypes and typehints following the [EML_NL Xml Schema Definitions](https://www.kiesraad.nl/adviezen-en-publicaties/formulieren/2016/osv/eml-bestanden/eml_nl_1_2_1-xsd). Type hints can be statically checked using [mypy](https://mypy-lang.org/) or [pyright](https://github.com/microsoft/pyright).

## Requirements
- At least Python version 3.10 for the [KW_ONLY](https://docs.python.org/3/library/dataclasses.html#dataclasses.KW_ONLY) type annotations for dataclasses. This is so that non-nullable fields can be marked as mandatory (see [here](https://xsdata.readthedocs.io/en/latest/faq/why-non-nullable-fields-are-marked-as-optional.html)).
- [xsData](https://github.com/tefra/xsdata) for parsing using these databindings.
- At least Python version 3.10 for the [KW_ONLY](https://docs.python.org/3/library/dataclasses.html#dataclasses.KW_ONLY) type annotations for dataclasses. This is so that non-nullable fields can be marked as mandatory (refer to [xsdata documentation](https://xsdata.readthedocs.io/en/latest/faq/why-non-nullable-fields-are-marked-as-optional.html)).
- [xsData](https://github.com/tefra/xsdata) for parsing using these data bindings.

For running tests, additionally:
- [pytest](https://docs.pytest.org/) for the test framework.
- [formencode](http://www.formencode.org/) for XML comparison.

## Testing
The bindings are tested on over 2500 different EML files from different type of Dutch elections, all downloaded from [data.overheid.nl](https://data.overheid.nl/community/organization/kiesraad) using a roundtrip serialization test.
The bindings are tested on over 2500 different EML files from different type of Dutch elections, all downloaded from [data.overheid.nl](https://data.overheid.nl/community/organization/kiesraad) using a roundtrip serialization test. To run the tests, install the test dependencies (see above), put EML files into a `data` folder and run `pytest` in the root folder.

See the [test report](pyeml_bindings_testreport.html)

Expand Down Expand Up @@ -43,7 +47,6 @@ with open(Path("output.xml"), "w") as out_file:
# to use the same namespace prefixes.
# If we don't, we still get back valid EML but with ns0, ns1 etc.
serializer.write(out=out_file, obj=eml, ns_map=NAMESPACE)

```

## Building
Expand Down
2 changes: 1 addition & 1 deletion tests/test_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def parsing_roundtrip_same(parser, serializer, reporter, path_to_eml, type) -> b

parser = XmlParser(ParserConfig(fail_on_unknown_properties=False))
serializer = XmlSerializer()
reporter = lambda x: stdout.write(x + "\n")
reporter = print
files = glob.glob(f"data/**/*.eml.xml", recursive=True)

test_cases = zip(
Expand Down

0 comments on commit 3e15fa3

Please sign in to comment.