Skip to content

Commit

Permalink
Finish refactoring, update generated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzoep committed Oct 29, 2024
1 parent 9880bd5 commit 0f4b26f
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 12 deletions.
19 changes: 13 additions & 6 deletions docs/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ implementation.
Abstract Classes
----------------

::: oarepo_c4gh.crypt4gh.aheader
::: oarepo_c4gh.crypt4gh.common.header_packet

::: oarepo_c4gh.crypt4gh.acrypt4gh
::: oarepo_c4gh.crypt4gh.common.header

::: oarepo_c4gh.crypt4gh.common.proto4gh

::: oarepo_c4gh.crypt4gh.common.data_block

Container Components
--------------------

::: oarepo_c4gh.crypt4gh.crypt4gh

::: oarepo_c4gh.crypt4gh.header
::: oarepo_c4gh.crypt4gh.stream.stream4gh

::: oarepo_c4gh.crypt4gh.header_packet
::: oarepo_c4gh.crypt4gh.stream.header

::: oarepo_c4gh.crypt4gh.data_block
::: oarepo_c4gh.crypt4gh.stream.header_packet

Data Keys
---------
Expand All @@ -43,4 +47,7 @@ Stream Writer

::: oarepo_c4gh.crypt4gh.writer

::: oarepo_c4gh.crypt4gh.filter
::: oarepo_c4gh.crypt4gh.filter.filter4gh

::: oarepo_c4gh.crypt4gh.filter.header

1 change: 1 addition & 0 deletions oarepo_c4gh/crypt4gh/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Empty"""
2 changes: 1 addition & 1 deletion oarepo_c4gh/crypt4gh/common/header_packet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Interface for packet headers.
"""

from ...exceptions import Crypt4GHHeaderPacketException


Expand Down Expand Up @@ -29,7 +30,6 @@ def __init__(
self._data_encryption_method = data_encryption_method
self._data_encryption_key = data_encryption_key


@property
def is_data_encryption_parameters(self) -> bool:
"""A predicate for checking whether this packet contains DEK.
Expand Down
1 change: 1 addition & 0 deletions oarepo_c4gh/crypt4gh/filter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Empty"""
3 changes: 1 addition & 2 deletions oarepo_c4gh/crypt4gh/filter/header.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module implements filtered header on top of other Header
implementation.
"""

from ..common.header import Header
from ...key.software import SoftwareKey
import io
Expand Down Expand Up @@ -86,5 +87,3 @@ def magic_bytes(self) -> bytes:
def version(self) -> int:
"""Returns the original version."""
return self._original.version


1 change: 1 addition & 0 deletions oarepo_c4gh/crypt4gh/stream/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Empty"""
9 changes: 6 additions & 3 deletions oarepo_c4gh/crypt4gh/stream/header_packet.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
"""Implementation of single Crypt4GH header packet parser.
"""

from ..common.header_packet import HeaderPacket
from ...key import KeyCollection
import io
from ..util import read_crypt4gh_stream_le_uint32, read_crypt4gh_bytes_le_uint32
from ..util import (
read_crypt4gh_stream_le_uint32,
read_crypt4gh_bytes_le_uint32,
)
from nacl.bindings import crypto_aead_chacha20poly1305_ietf_decrypt
from nacl.exceptions import CryptoError
from ...exceptions import Crypt4GHHeaderPacketException


class StreamHeaderPacket(HeaderPacket):
"""Loads the header packet from stream.
"""Loads the header packet from stream."""

"""
def __init__(
self, reader_keys: KeyCollection, istream: io.RawIOBase
) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_abstract_interface(self):

def test_abstract_implementation(self):
from oarepo_c4gh import Key

class MyKey(Key):
pass

Expand Down
2 changes: 2 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TestACrypt4GHHeader(unittest.TestCase):
def test_abstract_packets(self):
class MyHeader4GH(Header):
pass

MyHeader4GH.__abstractmethods__ = set()
hdr = MyHeader4GH()
assert hdr.packets is None, "Implementation in abstract class"
Expand All @@ -30,6 +31,7 @@ class MyHeader4GH(Header):
def test_abstract_container(self):
class MyCrypt4GH(Proto4GH):
pass

MyCrypt4GH.__abstractmethods__ = set()
c4gh = MyCrypt4GH()
assert c4gh.header is None, "Implementation in abstract class"
Expand Down

0 comments on commit 0f4b26f

Please sign in to comment.