o
    i	                     @   sL   d Z ddlmZmZ ddlmZ deeB defddZdedefd	d
Z	dS )z?Miscellaneous utility routines relating to hex and byte strings    )a2b_hexb2a_hex)default_encoding	hexstringreturnc                 C   sB   t | trt| ddS t | trtt| ddtS td)az  Return bytestring for a string of hex bytes separated by whitespace

    This is useful for creating specific byte sequences for testing, using
    python's implied concatenation for strings with comments allowed.

    Examples
    --------

    ::
        hex_string = (
            "08 00 32 10 "  # (0008,1032) SQ "Procedure Code Sequence"
            "08 00 00 00 "  # length 8
            "fe ff 00 e0 "  # (FFFE,E000) Item Tag
        )
        byte_string = hex2bytes(hex_string)

    Note in the example that all lines except the first must
    start with a space, alternatively the space could
    end the previous line.
              z&argument shall be bytes or string type)
isinstancebytesr   replacestrr   	TypeError)r    r   J/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/pydicom/util/hexutil.py	hex2bytes	   s
   

r   byte_stringc                    s0   t |   d fddtdt dD S )z4Return a hex string representation of encoded bytes.r	   c                 3   s     | ]} ||d   V  qdS )   Nr   ).0isr   r   	<genexpr>-   s    zbytes2hex.<locals>.<genexpr>r   r   )r   decodejoinrangelen)r   r   r   r   	bytes2hex*   s   $r   N)
__doc__binasciir   r   pydicom.charsetr   r   r   r   r   r   r   r   r   <module>   s
   !