
    .Phm:                     b    d Z ddlZddlmZ ddlmZ ddlm	Z
 ddgZdZd	Zd
ZdZddZdZ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.
    N)OrderedDict)	iskeyword)
itemgetter	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                    t          |t                    r(|                    dd                                          }d |D             }|rt	                      }t          |          D ]\  }}t          d |D                       rDt          |          s5|r3|d                                         s|	                    d          s||v rd|z  ||<   |
                    |           | g|z   D ]z}t          d |D                       st          d	|z            t          |          rt          d
|z            |d                                         rt          d|z            {t	                      }|D ]V}|	                    d          r|st          d|z            ||v rt          d|z            |
                    |           Wd| i}t          |          |d<   t          |          |d<   t          t          |                                        dd          dd         |d<   d                    d |D                       |d<   d                    d t          |          D                       |d<   t!          j        d"i |}|rt%          |           t'          t(          d| z  t*          t,          t                    }		 t/          ||	           n,# t0          $ r}
t1          |
j        dz   |z             d}
~
ww xY w|	|          }	 t5          j        d          }|j                            d d!          |_        n# t>          t          f$ r Y nw xY w|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                 ,    g | ]}t          |          S  str.0xs     R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/boltons/namedutils.py
<listcomp>znamedtuple.<locals>.<listcomp>       ///a3q66///    c              3   J   K   | ]}|                                 p|d k    V  dS _Nisalnumr   cs     r   	<genexpr>znamedtuple.<locals>.<genexpr>   3      >>A		/qCx>>>>>>r   r   r   _%dc              3   J   K   | ]}|                                 p|d k    V  dS r   r   r   s     r   r   znamedtuple.<locals>.<genexpr>   3      99q199;;*!s(999999r   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              3   L   K   | ]}t                               |           V   dS )nameN
_repr_tmplformatr   r2   s     r   r   znamedtuple.<locals>.<genexpr>   G       #< #<'+ $.#4#4$#4#?#? #< #< #< #< #< #<r   repr_fmt
c              3   T   K   | ]#\  }}t                               ||           V  $dS )indexr2   N)_imm_field_tmplr5   r   r<   r2   s      r   r   znamedtuple.<locals>.<genexpr>   sU       %P %P)4 &5%;%;%d%;%S%S %P %P %P %P %P %Pr   
field_defsznamedtuple_%s)_itemgetter__name__r   	_property_tuple:
NrA   __main__r   ) 
isinstancer   replacesplitset	enumerateall
_iskeywordisdigit
startswithadd
ValueErrortuplelenreprjoin_namedtuple_tmplr5   printdictr@   r   propertyexecSyntaxErrormsg_sys	_getframe	f_globalsget
__module__AttributeError)r'   r(   verboserenameseenr<   r2   fmt_kwclass_definition	namespaceeresultframes                r   r   r   {   s1   2 +s## <!))#s3399;;//;///K 
uu$[11 	 	KE4>>>>>>> 3d##33 7??$$3 ??3''	3
 4<<%*U]E"HHTNNNN
[( 
4 
499D99999 	% K#$ % % % d 	3 +-12 3 3 37?? 	4 ,.23 4 4 4	4 55D  ??3 	* 	* "$() * * *4<<CdJKKK (#F!+..F={++F<eK001199#rBB1R4HF: #< #</:#< #< #< < <F:99 %P %P8A+8N8N%P %P %P P PF<'.8888   -8!,'!	# # #I
<y)))) < < <!%%-*::;;;<x Fq!!!O//
JGGJ'    Ms*   K$ $
L.LL4M M"!M"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                    t          |t                    r(|                    dd                                          }d |D             }|rt	                      }t          |          D ]\  }}t          d |D                       rDt          |          s5|r3|d                                         s|	                    d          s||v rd|z  ||<   |
                    |           | g|z   D ]z}t          d |D                       st          d	|z            t          |          rt          d
|z            |d                                         rt          d|z            {t	                      }|D ]V}|	                    d          r|st          d|z            ||v rt          d|z            |
                    |           Wd| i}t          |          |d<   t          |          |d<   t          t          |                                        dd          dd         |d<   d                    d |D                       |d<   d                    d t          |          D                       |d<   t!          j        d#i |}|rt%          |           d }	t'          t(          |	d| z  t*          t,          t.                    }
	 t1          ||
           n,# t2          $ r}t3          |j        dz   |z             d }~ww xY w|
|          }	 t7          j        d          }|j                            d!d"          |_        n# t@          t          f$ r Y nw xY w|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                 ,    g | ]}t          |          S r   r   r   s     r   r   znamedlist.<locals>.<listcomp>5  r   r   c              3   J   K   | ]}|                                 p|d k    V  dS r   r   r   s     r   r   znamedlist.<locals>.<genexpr>9  r   r   r   r   r   c              3   J   K   | ]}|                                 p|d k    V  dS r   r   r   s     r   r   znamedlist.<locals>.<genexpr>B  r!   r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   c              3   L   K   | ]}t                               |           V   dS r1   r3   r6   s     r   r   znamedlist.<locals>.<genexpr>Z  r7   r   r8   r9   c              3   T   K   | ]#\  }}t                               ||           V  $dS r;   )_m_field_tmplr5   r>   s      r   r   znamedlist.<locals>.<genexpr>\  sU       %P %P)4 &3%9%9D%9%Q%Q %P %P %P %P %P %Pr   r?   c                       fd}|S )Nc                     || <   d S )Nr   )objvaluekeys     r   _itemsetterz3namedlist.<locals>._itemsetter.<locals>._itemsetterd  s    CHHHr   r   )rv   rw   s   ` r   rw   znamedlist.<locals>._itemsetterc  s"    	 	 	 	 	r   znamedlist_%s)r@   rw   rA   r   rB   _listrD   NrA   rE   r   )!rF   r   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   _namedlist_tmplr5   rV   rW   r@   r   rX   listrY   rZ   r[   r\   r]   r^   r_   r`   ra   )r'   r(   rb   rc   rd   r<   r2   re   rf   rw   rg   rh   ri   rj   s                 r   r   r     sC   2 +s## <!))#s3399;;//;///K 
uu$[11 	 	KE4>>>>>>> 3d##33 7??$$3 ??3''	3
 4<<%*U]E"HHTNNNN
[( 
4 
499D99999 	% K#$ % % % d 	3 +-12 3 3 37?? 	4 ,.23 4 4 4	4 55D  ??3 	* 	* "$() * * *4<<CdJKKK (#F!+..F={++F<eK001199#rBB1R4HF: #< #</:#< #< #< < <F:99 %P %P8A+8N8N%P %P %P P PF<&-7777     !,,x7!,'! ! !I<y)))) < < <!%%-*::;;;<x Fq!!!O//
JGGJ'    Ms*   K( (
L2LL4M M&%M&)FF)__doc__sysr\   collectionsr   keywordr   rL   operatorr   r@   __all__r4   r=   rq   rU   r   ry   r   r   r   r   <module>r      s   > $     # # # # # # + + + + + + . . . . . . 
% 
0 d` ` ` `N5pg g g g g gr   