models
pacsanini.models
#
The models module provide data structures for the net module so that
DICOM network nodes can easily be represented.
DicomNode
pydantic-model
#
DicomNode represents a networking node in a DICOM system.
Attributes:
| Name | Type | Description |
|---|---|---|
aetitle |
bytes |
The DICOM node's AE Title. When initialized, this can be a string. |
ip |
Optional[str] |
The DICOM node's IP address or hostname. Defaults to None. |
port |
Optional[int] |
The DICOM node's listening port. When initialized, the port value can be a string value. |
has_net_info |
Optional[bool] |
If the ip and port attributes are not None, has_net_info is set to True -otherwise this is False. |
__json_encoder__(obj)
special
staticmethod
#
partial(func, args, *keywords) - new function with partial application
of the given arguments and keywords.
has_port(self)
#
Returns True if the port for the application is set, False otherwise.
Source code in pacsanini/models.py
def has_port(self) -> bool:
"""Returns True if the port for the application is set, False otherwise."""
return self.port is not None
validate_aetitle(v)
classmethod
#
Coerce the aetitle to bytes.
Source code in pacsanini/models.py
@validator("aetitle", pre=True)
def validate_aetitle(cls, v): # pylint: disable=no-self-argument,no-self-use
"""Coerce the aetitle to bytes."""
if isinstance(v, bytes):
return v
if isinstance(v, str):
return v.encode()
raise ValueError(f"aetitle must be a str or bytes -obtained ({type(v)}): {v}")
validate_ip(v)
classmethod
#
Validate the IP address.
Source code in pacsanini/models.py
@validator("ip", pre=True)
def validate_ip(cls, v): # pylint: disable=no-self-argument,no-self-use
"""Validate the IP address."""
return v if v else None
validate_net_info(v, values, **kwargs)
classmethod
#
Check if the IP and port parameters are given.
Source code in pacsanini/models.py
@validator("has_net_info", pre=True, always=True)
def validate_net_info(
cls, v, values, **kwargs
): # pylint: disable=no-self-argument,no-self-use,unused-argument
"""Check if the IP and port parameters are given."""
return (
values.get("ip", None) is not None and values.get("port", None) is not None
)
validate_port(v)
classmethod
#
Coerce str to int if need be.
Source code in pacsanini/models.py
@validator("port", pre=True)
def validate_port(cls, v): # pylint: disable=no-self-argument,no-self-use
"""Coerce str to int if need be."""
if not v:
return None
if isinstance(v, str):
return int(v)
return v
QueryLevel
#
QueryLevel provides abstraction over the specific
query level that users want.
StorageSortKey
#
StorageSortKey indicates how to organize DICOM files
when persisting them in the context of a storescp server.