
    YbcJ                     P    d dl mZ ddlmZ ddlmZmZ eZd Zd Zd Zdd	Z	d
 Z
y)    )absolute_import   match)TYPESTypec                      | rt        |       S dS )a\  
    Infers the type of the given input.

    Function is overloaded to accept multiple types in input
    and peform the needed type inference based on it.

    Args:
        obj: path to file, bytes or bytearray.

    Returns:
        The matched type instance. Otherwise None.

    Raises:
        TypeError: if obj is not a supported type.
    Nr   )objs    3/usr/lib/python3/dist-packages/filetype/filetype.pyguessr      s      5:&$&    c                 8    t        |       }|r|j                  S |S )a  
    Infers the file type of the given input
    and returns its MIME type.

    Args:
        obj: path to file, bytes or bytearray.

    Returns:
        The matched MIME type as string. Otherwise None.

    Raises:
        TypeError: if obj is not a supported type.
    )r   mimer
   kinds     r   
guess_mimer      s     :D499&$&r   c                 8    t        |       }|r|j                  S |S )a  
    Infers the file type of the given input
    and returns its RFC file extension.

    Args:
        obj: path to file, bytes or bytearray.

    Returns:
        The matched file extension as string. Otherwise None.

    Raises:
        TypeError: if obj is not a supported type.
    )r   	extensionr   s     r   guess_extensionr   1   s     :D!4>>+t+r   Nc                 ^    t         D ]$  }|j                  |k(  s|j                  | k(  s"|c S  y)a  
    Returns the file type instance searching by
    MIME type or file extension.

    Args:
        ext: file extension string. E.g: jpg, png, mp4, mp3
        mime: MIME string. E.g: image/jpeg, video/mpeg

    Returns:
        The matched file type instance. Otherwise None.
    N)typesr   r   )r   extr   s      r   get_typer   C   s4      >>S DII$5K r   c                 f    t        | t              st        d      t        j	                  d|        y)z
    Adds a new type matcher instance to the supported types.

    Args:
        instance: Type inherited instance.

    Returns:
        None
    z.instance must inherit from filetype.types.Typer   N)
isinstancer   	TypeErrorr   insert)instances    r   add_typer   U   s(     h%HII	LLHr   )NN)
__future__r   r   r   r   r   r   r   r   r   r    r   r   <module>r"      s0    '   	'&'$,$$r   