a
    d<                     @   s   d Z ddlmZ ddlZzddlmZ W n ey>   eZY n0 ddl	m
Z ddlmZ ze dd ZW n" ey   eefZd	d ZY n0 d
dgZdZdZdZdZdddZdZddd
ZdS )a  The ``namedutils`` module defines two lightweight container types:
:class:`namedtuple` and :class:`namedlist`. Both are subtypes of built-in
sequence types, which are very fast and efficient. They simply add
named attribute accessors for specific indexes within themselves.

The :class:`namedtuple` is identical to the built-in
:class:`collections.namedtuple`, with a couple of enhancements,
including a ``__repr__`` more suitable to inheritance.

The :class:`namedlist` is the mutable counterpart to the
:class:`namedtuple`, and is much faster and lighter-weight than
full-blown :class:`object`. Consider this if you're implementing nodes
in a tree, graph, or other mutable data structure. If you want an even
skinnier approach, you'll probably have to look to C.
    )print_functionN)OrderedDict)	iskeyword)
itemgetterc                 C   s   t d d S )Nzexec code in global_envexeccodeZ
global_env r
   [/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/boltons/namedutils.pyexec_?   s    r   c                 C   s   t | | d S Nr   r   r
   r
   r   r   C   s    	namedlist
namedtuplez	{name}=%rzP    {name} = _property(_itemgetter({index:d}), doc='Alias for field {index:d}')
zh    {name} = _property(_itemgetter({index:d}), _itemsetter({index:d}), doc='Alias for field {index:d}')
a  class {typename}(tuple):
    '{typename}({arg_list})'

    __slots__ = ()

    _fields = {field_names!r}

    def __new__(_cls, {arg_list}):  # TODO: tweak sig to make more extensible
        'Create new instance of {typename}({arg_list})'
        return _tuple.__new__(_cls, ({arg_list}))

    @classmethod
    def _make(cls, iterable, new=_tuple.__new__, len=len):
        'Make a new {typename} object from a sequence or iterable'
        result = new(cls, iterable)
        if len(result) != {num_fields:d}:
            raise TypeError('Expected {num_fields:d}'
                            ' arguments, got %d' % len(result))
        return result

    def __repr__(self):
        'Return a nicely formatted representation string'
        tmpl = self.__class__.__name__ + '({repr_fmt})'
        return tmpl % self

    def _asdict(self):
        'Return a new OrderedDict which maps field names to their values'
        return OrderedDict(zip(self._fields, self))

    def _replace(_self, **kwds):
        'Return a new {typename} object replacing field(s) with new values'
        result = _self._make(map(kwds.pop, {field_names!r}, _self))
        if kwds:
            raise ValueError('Got unexpected field names: %r' % kwds.keys())
        return result

    def __getnewargs__(self):
        'Return self as a plain tuple.  Used by copy and pickle.'
        return tuple(self)

    __dict__ = _property(_asdict)

    def __getstate__(self):
        'Exclude the OrderedDict from pickling'  # wat
        pass

{field_defs}
Fc              
   C   sr  t |tr|dd }dd |D }|rt }t|D ]Z\}}tdd |D r~t|s~|r~|d  s~|	ds~||v rd	| ||< |
| q:| g| D ]N}td
d |D std| t|rtd| |d  rtd| qt }|D ]B}|	dr|std| ||v r2td| |
| qd| i}t||d< t||d< tt|dddd |d< ddd |D |d< ddd t|D |d< tjf i |}|rt| ttd|  tttd}	zt||	 W n8 ty, }
 zt|
jd  | W Y d!}
~
n
d!}
~
0 0 |	|  }ztd}|jd"d#|_W n ttfyl   Y n0 |S )$a;  Returns a new subclass of tuple with named fields.

    >>> Point = namedtuple('Point', ['x', 'y'])
    >>> Point.__doc__                   # docstring for the new class
    'Point(x, y)'
    >>> p = Point(11, y=22)             # instantiate with pos args or keywords
    >>> p[0] + p[1]                     # indexable like a plain tuple
    33
    >>> x, y = p                        # unpack like a regular tuple
    >>> x, y
    (11, 22)
    >>> p.x + p.y                       # fields also accessible by name
    33
    >>> d = p._asdict()                 # convert to a dictionary
    >>> d['x']
    11
    >>> Point(**d)                      # convert from a dictionary
    Point(x=11, y=22)
    >>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
    Point(x=100, y=22)
    , c                 S   s   g | ]}t |qS r
   str.0xr
   r
   r   
<listcomp>       znamedtuple.<locals>.<listcomp>c                 s   s   | ]}|  p|d kV  qdS _Nisalnumr   cr
   r
   r   	<genexpr>   r   znamedtuple.<locals>.<genexpr>r   r   _%dc                 s   s   | ]}|  p|d kV  qdS r   r   r   r
   r
   r   r      r   WType names and field names can only contain alphanumeric characters and underscores: %r2Type names and field names cannot be a keyword: %r9Type names and field names cannot start with a number: %r/Field names cannot start with an underscore: %r$Encountered duplicate field name: %rtypenamefield_names
num_fields'    arg_list, c                 s   s   | ]}t j|d V  qdS )nameN
_repr_tmplformatr   r0   r
   r
   r   r      s   repr_fmt
c                 s   s    | ]\}}t j||d V  qdS )indexr0   N)_imm_field_tmplr3   r   r8   r0   r
   r
   r   r      s   
field_defsznamedtuple_%s)_itemgetter__name__r   	_property_tuple:
Nr=   __main__) 
isinstance
basestringreplacesplitset	enumerateall
_iskeywordisdigit
startswithadd
ValueErrortuplelenreprjoin_namedtuple_tmplr3   printdictr<   r   propertyr   SyntaxErrormessage_sys	_getframe	f_globalsget
__module__AttributeError)r&   r'   verboserenameseenr8   r0   fmt_kwclass_definition	namespaceeresultframer
   r
   r   r      s    


 

(
a  class {typename}(list):
    '{typename}({arg_list})'

    __slots__ = ()

    _fields = {field_names!r}

    def __new__(_cls, {arg_list}):  # TODO: tweak sig to make more extensible
        'Create new instance of {typename}({arg_list})'
        return _list.__new__(_cls, ({arg_list}))

    def __init__(self, {arg_list}):  # tuple didn't need this but list does
        return _list.__init__(self, ({arg_list}))

    @classmethod
    def _make(cls, iterable, new=_list, len=len):
        'Make a new {typename} object from a sequence or iterable'
        # why did this function exist? why not just star the
        # iterable like below?
        result = cls(*iterable)
        if len(result) != {num_fields:d}:
            raise TypeError('Expected {num_fields:d} arguments,'
                            ' got %d' % len(result))
        return result

    def __repr__(self):
        'Return a nicely formatted representation string'
        tmpl = self.__class__.__name__ + '({repr_fmt})'
        return tmpl % tuple(self)

    def _asdict(self):
        'Return a new OrderedDict which maps field names to their values'
        return OrderedDict(zip(self._fields, self))

    def _replace(_self, **kwds):
        'Return a new {typename} object replacing field(s) with new values'
        result = _self._make(map(kwds.pop, {field_names!r}, _self))
        if kwds:
            raise ValueError('Got unexpected field names: %r' % kwds.keys())
        return result

    def __getnewargs__(self):
        'Return self as a plain list.  Used by copy and pickle.'
        return tuple(self)

    __dict__ = _property(_asdict)

    def __getstate__(self):
        'Exclude the OrderedDict from pickling'  # wat
        pass

{field_defs}
c              
   C   s|  t |tr|dd }dd |D }|rt }t|D ]Z\}}tdd |D r~t|s~|r~|d  s~|	ds~||v rd	| ||< |
| q:| g| D ]N}td
d |D std| t|rtd| |d  rtd| qt }|D ]B}|	dr|std| ||v r2td| |
| qd| i}t||d< t||d< tt|dddd |d< ddd |D |d< ddd t|D |d< tjf i |}|rt| dd }	tt|	d |  tttd!}
zt||
 W n8 ty6 } zt|jd" | W Y d#}~n
d#}~0 0 |
|  }ztd}|jd$d%|_W n t tfyv   Y n0 |S )&a7  Returns a new subclass of list with named fields.

    >>> Point = namedlist('Point', ['x', 'y'])
    >>> Point.__doc__                   # docstring for the new class
    'Point(x, y)'
    >>> p = Point(11, y=22)             # instantiate with pos args or keywords
    >>> p[0] + p[1]                     # indexable like a plain list
    33
    >>> x, y = p                        # unpack like a regular list
    >>> x, y
    (11, 22)
    >>> p.x + p.y                       # fields also accessible by name
    33
    >>> d = p._asdict()                 # convert to a dictionary
    >>> d['x']
    11
    >>> Point(**d)                      # convert from a dictionary
    Point(x=11, y=22)
    >>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
    Point(x=100, y=22)
    r   r   c                 S   s   g | ]}t |qS r
   r   r   r
   r
   r   r   D  r   znamedlist.<locals>.<listcomp>c                 s   s   | ]}|  p|d kV  qdS r   r   r   r
   r
   r   r   H  r   znamedlist.<locals>.<genexpr>r   r   r    c                 s   s   | ]}|  p|d kV  qdS r   r   r   r
   r
   r   r   Q  r   r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   c                 s   s   | ]}t j|d V  qdS r/   r1   r4   r
   r
   r   r   i  s   r5   r6   c                 s   s    | ]\}}t j||d V  qdS r7   )_m_field_tmplr3   r:   r
   r
   r   r   k  s   r;   c                    s    fdd}|S )Nc                    s   ||  < d S r   r
   )objvaluekeyr
   r   _itemsetters  s    z3namedlist.<locals>._itemsetter.<locals>._itemsetterr
   )rk   rl   r
   rj   r   rl   r  s    znamedlist.<locals>._itemsetterznamedlist_%s)r<   rl   r=   r   r>   Z_listr@   Nr=   rA   )!rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   _namedlist_tmplr3   rS   rT   r<   r   rU   listr   rV   rW   rX   rY   rZ   r[   r\   r]   )r&   r'   r^   r_   r`   r8   r0   ra   rb   rl   rc   rd   re   rf   r
   r
   r   r   )  s    


 

(
)FF)FF)__doc__
__future__r   sysrX   collectionsr   ImportErrorrT   keywordr   rI   operatorr   r<   rC   r   	NameErrorr   bytes__all__r2   r9   rg   rR   r   rm   r   r
   r
   r
   r   <module>!   s,   
2
g8