From f17f4afb07b269199c6bc10d28ae0a4da7c37aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Wed, 9 Oct 2024 16:03:38 +0200 Subject: [PATCH] Finish writer documentation, final cleanup. --- docs/index.md | 13 +++++++++++++ oarepo_c4gh/__init__.py | 1 + oarepo_c4gh/crypt4gh/__init__.py | 3 ++- tests/test_writer.py | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 048bf64..8736041 100644 --- a/docs/index.md +++ b/docs/index.md @@ -95,3 +95,16 @@ my_keys = KeyCollection(my_secret_key, my_other_secret_key) with open("hello.txt.c4gh") as f: crypt4gh = Crypt4GH(my_keys, f) ``` + +### Container Serialization + +An initialized container can be also serialized. Currently the result +of such serialization should be exactly the same binary data as the +original input. + +```python +from oarepo_cg4h import Crypt4GHWriter + +writer = Crypt4GHWriter(crypt4gh, open("output.c4gh", "w")) +writer.write() +``` diff --git a/oarepo_c4gh/__init__.py b/oarepo_c4gh/__init__.py index 9fdb3aa..41082ef 100644 --- a/oarepo_c4gh/__init__.py +++ b/oarepo_c4gh/__init__.py @@ -12,6 +12,7 @@ "SoftwareKey", "C4GHKey", "Crypt4GH", + "Crypt4GHWriter", "Crypt4GHException", "Crypt4GHKeyException", "Crypt4GHHeaderException", diff --git a/oarepo_c4gh/crypt4gh/__init__.py b/oarepo_c4gh/crypt4gh/__init__.py index 0a76897..1805fae 100644 --- a/oarepo_c4gh/crypt4gh/__init__.py +++ b/oarepo_c4gh/crypt4gh/__init__.py @@ -1,3 +1,4 @@ from .crypt4gh import Crypt4GH +from .writer import Crypt4GHWriter -__all__ = ["Crypt4GH"] +__all__ = ["Crypt4GH", "Crypt4GHWriter"] diff --git a/tests/test_writer.py b/tests/test_writer.py index d97f7b5..32ec115 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -28,6 +28,7 @@ def test_abstract_container(self): assert c4gh.header is None, "Implementation in abstract class" assert c4gh.data_blocks is None, "Implementation in abstract class" + class TestCrypt4GHWriter(unittest.TestCase): def test_writing_header(self):