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
Add versionadded
  • Loading branch information
scaramallion committed Nov 17, 2023
commit 793bd7217e7e724f974ce2d0567f8e940c836276
6 changes: 5 additions & 1 deletion pynetdicom/dsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ def encode(


def encode_file_meta(file_meta: FileMetaDataset) -> bytes:
"""Return the encoded File Meta Information elements in `file_meta`."""
"""Return the encoded File Meta Information elements in `file_meta`.

.. versionadded:: 2.1

"""

buffer = DicomBytesIO()
buffer.is_little_endian = True
Expand Down
6 changes: 4 additions & 2 deletions pynetdicom/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ def encoded_dataset(self, include_meta: bool = True) -> bytes:
"""Return the encoded C-STORE dataset sent by the peer without first
decoding it.

.. versionadded:: 2.1

Examples
--------
Retrieve the encoded dataset as sent by the peer::
Expand Down Expand Up @@ -677,12 +679,12 @@ def handle_store(event: pynetdicom.events.Event, dst: pathlib.Path) -> int:
if not include_meta:
return stream

return b"".join([
return b"".join((
b"\x00" * 128,
b"DICM",
encode_file_meta(self.file_meta),
stream,
])
))

@property
def event(self) -> EventType:
Expand Down
Loading