Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Add convenience function Event.encoded_dataset() #888

Merged
merged 10 commits into from
Nov 17, 2023
Prev Previous commit
Next Next commit
Fix type hints
  • Loading branch information
scaramallion committed Nov 17, 2023
commit 2deb22d8b91ec6762a9293382c82d52d00c9b877
4 changes: 3 additions & 1 deletion pynetdicom/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pynetdicom.dsutils import decode, encode, create_file_meta, encode_file_meta

if TYPE_CHECKING: # pragma: no cover
from io import BytesIO
from pynetdicom.association import Association
from pynetdicom.dimse_messages import DIMSEMessage
from pynetdicom.dimse_primitives import (
Expand Down Expand Up @@ -665,7 +666,8 @@ def handle_store(event: pynetdicom.events.Event, dst: pathlib.Path) -> int:
If the corresponding event is not a C-STORE request.
"""
try:
stream = self.request.DataSet.getvalue()
request = cast(C_STORE, self.request)
stream = cast(BytesIO, request.DataSet).getvalue()
except AttributeError:
raise AttributeError(
"The corresponding event is not a C-STORE request and has no "
Expand Down