
    Ybc)                     :    	 d dl Z dZd Zd Zd Zy# e$ r Y w xY w)    Ni    c                     t        | d      5 }t        |j                  t                    cddd       S # 1 sw Y   yxY w)z
    Reads file from disk and returns the first 8192 bytes
    of data representing the magic number header signature.

    Args:
        path: path string to file.

    Returns:
        First 8192 bytes of the file content as bytearray type.
    rbN)open	bytearrayread_NUM_SIGNATURE_BYTES)pathfps     0/usr/lib/python3/dist-packages/filetype/utils.pyget_signature_bytesr      s7     
dD	 8R!5678 8 8s   5>c                 D    t        |       }|t        kD  rt        n|}| d| S )z
    Returns the first 8192 bytes of the given bytearray
    as part of the file header signature.

    Args:
        array: bytearray to extract the header signature.

    Returns:
        First 8192 bytes of the file content as bytearray type.
    N)lenr   )arraylengthindexs      r   	signaturer      s)     ZF$*-A$A vE%=    c                    t        | t              rt        |       S t        | t              rt	        |       S t        | t
              rt        |       S t        | t              r"t        t        |       j                               S t        | t        j                        rt	        |       S t        | d      rt        | d      r^t        | d      rR| j                         }| j                  d       | j                  t              }| j                  |       t        |      S t        | j                  t                    S t!        dt#        |       z        )af  
    Infers the input type and reads the first 8192 bytes,
    returning a sliced bytearray.

    Args:
        obj: path to readable, file-like object(with read() method), bytes,
        bytearray or memoryview

    Returns:
        First 8192 bytes of the file content as bytearray type.

    Raises:
        TypeError: if obj is not a supported type.
    r   tellseekr   z"Unsupported type as file input: %s)
isinstancer   r   strr   bytes
memoryviewtolistpathlibPurePathhasattrr   r   r   r   	get_bytes	TypeErrortype)obj	start_posmagic_bytess      r   r   r   -   s    #y!~#s"3''#u~#z"3..011#w''("3''sF3GC$8
IHHQK((#78KHHY[))"6788
849D
EEr   )r   ImportErrorr   r   r   r    r   r   <module>r'      s:   	
  8"'FO  		s    