o
    i                  	   @   s   d Z ddlZddlmZ ddlmZ ddlZedZdddd	d
ddZ	de
eB eB dB ddeB e
B fddZdeeB defddZ	ddedee dB de
ddfddZdS )zMiscellaneous helper functions    N)groupby)Pathpydicomi  i@B i ʚ;i   i   i   @)kbmbgbkibmibgibexprreturnc                 C   s   | du s
| t dkrdS t| tt B r| S zt| W S  ty#   Y nw dd t| tjD \}}| tv rAt |t|   S td| d)zeReturn the number of bytes for `defer_size` argument in
    :func:`~pydicom.filereader.dcmread`.
    Ninfc                 s   s    | ]
\}}d  |V  qdS ) N)join).0kg r   B/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/pydicom/misc.py	<genexpr>&   s    z size_in_bytes.<locals>.<genexpr>z"Unable to parse length with unit '')	float
isinstanceint
ValueErrorr   strisalphalower_size_factors)r   valueunitr   r   r   size_in_bytes   s   
r!   	file_pathc                 C   sF   t | d}|d |ddkW  d   S 1 sw   Y  dS )a  Return ``True`` if the file at `file_path` is a DICOM file.

    This function is a pared down version of
    :func:`~pydicom.filereader.read_preamble` meant for a fast return. The
    file is read for a conformant preamble ('DICM'), returning
    ``True`` if so, and ``False`` otherwise. This is a conservative approach.

    Parameters
    ----------
    file_path : str
        The path to the file.

    See Also
    --------
    filereader.read_preamble
    filereader.read_partial
    rb      s   DICMN)openread)r"   fpr   r   r   is_dicom-   s   
$r)      msgcategory
stacklevelc                 C   s"   t |  tj| ||d d dS )aU  Send warning message `msg` to the logger.

    Parameters
    ----------
    msg : str
        The warning message.
    category : type[Warning] | None, optional
        The warning category class, defaults to ``UserWarning``.
    stacklevel : int, optional
        The stack level to refer to, relative to where `warn_and_log` is used.
    r*   )r-   N)LOGGERwarningwarningswarn)r+   r,   r-   r   r   r   warn_and_logD   s   
r2   )Nr*   )__doc__logging	itertoolsr   pathlibr   r0   	getLoggerr.   r   r   r   r   r!   boolr)   typeWarningr2   r   r   r   r   <module>   s2   
&

