o
    e                     @   sJ   d dl Zd dlZdd Zejdd ZejdejjfddZ	d	d
 Z
dS )    Nc                    s   t   fdd}|S )z
    Wrap func so it's not called if its first param is None

    >>> print_text = pass_none(print)
    >>> print_text('text')
    text
    >>> print_text(None)
    c                    s"   | d ur | g|R i |S d S )N )paramargskwargsfuncr   S/var/www/html/venv/lib/python3.10/site-packages/setuptools/_distutils/_functools.pywrapper   s   zpass_none.<locals>.wrapper)	functoolswraps)r   r	   r   r   r   	pass_none   s   
r   c                 C   s   ||  S )zSplat args to func.r   r   r   r   r   r   _splat_inner   s   r   r   c                 C   s   |di | S )zSplat kargs to func as kwargs.Nr   r   r   r   r   r   _   s   r   c                 C   s   t | t jt| dS )a  
    Wrap func to expect its parameters to be passed positionally in a tuple.

    Has a similar effect to that of ``itertools.starmap`` over
    simple ``map``.

    >>> import itertools, operator
    >>> pairs = [(-1, 1), (0, 2)]
    >>> _ = tuple(itertools.starmap(print, pairs))
    -1 1
    0 2
    >>> _ = tuple(map(splat(print), pairs))
    -1 1
    0 2

    The approach generalizes to other iterators that don't have a "star"
    equivalent, such as a "starfilter".

    >>> list(filter(splat(operator.add), pairs))
    [(0, 2)]

    Splat also accepts a mapping argument.

    >>> def is_nice(msg, code):
    ...     return "smile" in msg or code == 0
    >>> msgs = [
    ...     dict(msg='smile!', code=20),
    ...     dict(msg='error :(', code=1),
    ...     dict(msg='unknown', code=0),
    ... ]
    >>> for msg in filter(splat(is_nice), msgs):
    ...     print(msg)
    {'msg': 'smile!', 'code': 20}
    {'msg': 'unknown', 'code': 0}
    r   )r
   r   partialr   r   r   r   r   splat%   s   $r   )collections.abccollectionsr
   r   singledispatchr   registerabcMappingr   r   r   r   r   r   <module>   s    
