-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move current filter implementation into separate subdirectory.
- split filter header and filter4gh - adjust tests for filter4gh in filter subdirectory (for now)
- Loading branch information
Showing
4 changed files
with
56 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .crypt4gh import Crypt4GH | ||
from .writer import Crypt4GHWriter | ||
from .filter import Crypt4GHFilter | ||
from .filter.filter4gh import Crypt4GHFilter | ||
|
||
__all__ = ["Crypt4GH", "Crypt4GHWriter", "Crypt4GHFilter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""This module implements a filtered Crypt4GH container backed by | ||
other Crypt4GH container but presenting filtered (added, changed | ||
and/or removed) header packets. | ||
""" | ||
|
||
from ..common.proto4gh import Proto4GH | ||
from ..common.header import Header | ||
from typing import Generator | ||
from ..common.data_block import DataBlock | ||
from .header import FilterHeader | ||
|
||
|
||
class Crypt4GHFilter(Proto4GH): | ||
"""The whole container filter which actually filters only header | ||
packets but for the writer the whole interface is needed. | ||
""" | ||
|
||
def __init__(self, original: Proto4GH) -> None: | ||
"""Only prepares the filtered header and original container | ||
with original blocks. | ||
Parameters: | ||
original: the original container to be filtered. | ||
""" | ||
self._original = original | ||
self._header = FilterHeader(original.header) | ||
|
||
def add_recipient(self, public_key: bytes) -> None: | ||
"""Passes the public key to the header filter instance. | ||
Parameters: | ||
public_key: the reader key to add. | ||
""" | ||
self._header.add_recipient(public_key) | ||
|
||
@property | ||
def header(self) -> Header: | ||
"""Returns the filtered header instance.""" | ||
return self._header | ||
|
||
@property | ||
def data_blocks(self) -> Generator[DataBlock, None, None]: | ||
"""Returns the iterator for the original data blocks.""" | ||
return self._original.data_blocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters