pynetdicom.utils.validate_ae_title

pynetdicom.utils.validate_ae_title(ae_title, use_short=False)[source]

Return a valid AE title from ae_title, if possible.

An AE title:

  • Must be no more than 16 characters

  • Leading and trailing spaces are not significant

  • The characters should belong to the Default Character Repertoire excluding 0x5C (backslash) and all control characters

If the supplied ae_title is greater than 16 characters once non-significant spaces have been removed then the returned AE title will be truncated to remove the excess characters.

If the supplied ae_title is less than 16 characters once non-significant spaces have been removed, the spare trailing characters will be set to space (0x20) provided use_short is False.

Changed in version 1.1: Changed to only return bytes for Python 3.

Changed in version 1.5: Added use_short keyword parameter.

Parameters
  • ae_title (bytes) – The AE title to check.

  • use_short (bool, optional) – If False (default) then pad AE titles with trailing spaces up to the maximum allowable length (16 bytes), otherwise no padding will be added.

Returns

A valid AE title truncated to 16 characters if necessary. If Python 3 then only returns bytes, if Python 2 then returns str.

Return type

str or bytes

Raises

ValueError – If ae_title is an empty string, contains only spaces or contains control characters or backslash.