Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__/collections.cpython-311.pyc

�

�܋f����.�dZddlZddlZddlmZddlmZddlmZddlm	Z	dd	l
mZgd
�Ze	j
���ZGd�de��ZGd
�de��ZGd�de��Zd�ZGd�de��Zd�Zd�ZGd�de��Zejd��Z	Gd�de��Zd<d�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d<d$�Z%d<d%�Z&d<d&�Z'd'�Z(d(�Z)e*e+fZ,d)�Z-d*�Z.d+�Z/Gd,�d-e0��Z1Gd.�d/e*��Z2Gd0�d1e3��Z4e0e1e*e2e3e4iZ5e0d2d3d4d5�e(��fe*d6d3d4d5�e/��fe3e	j6rd7d8ie)��fn
d7d9ie)��fiZ7Gd:�d;e3��Z8ee8��ee1��ee2��dS)=aNSupport for collections of mapped entities.

The collections package supplies the machinery used to inform the ORM of
collection membership changes.  An instrumentation via decoration approach is
used, allowing arbitrary types (including built-ins) to be used as entity
collections without requiring inheritance from a base class.

Instrumentation decoration relays membership change events to the
:class:`.CollectionAttributeImpl` that is currently managing the collection.
The decorators observe function call arguments and return values, tracking
entities entering or leaving the collection.  Two decorator approaches are
provided.  One is a bundle of generic decorators that map function arguments
and return values to events::

  from sqlalchemy.orm.collections import collection
  class MyClass(object):
      # ...

      @collection.adds(1)
      def store(self, item):
          self.data.append(item)

      @collection.removes_return()
      def pop(self):
          return self.data.pop()


The second approach is a bundle of targeted decorators that wrap appropriate
append and remove notifiers around the mutation methods present in the
standard Python ``list``, ``set`` and ``dict`` interfaces.  These could be
specified in terms of generic decorator recipes, but are instead hand-tooled
for increased efficiency.  The targeted decorators occasionally implement
adapter-like behavior, such as mapping bulk-set methods (``extend``,
``update``, ``__setslice__``, etc.) into the series of atomic mutation events
that the ORM requires.

The targeted decorators are used internally for automatic instrumentation of
entity collection classes.  Every collection class goes through a
transformation process roughly like so:

1. If the class is a built-in, substitute a trivial sub-class
2. Is this class already instrumented?
3. Add in generic decorators
4. Sniff out the collection interface through duck-typing
5. Add targeted decoration to any undecorated interface method

This process modifies the class at runtime, decorating methods and adding some
bookkeeping properties.  This isn't possible (or desirable) for built-in
classes like ``list``, so trivial sub-classes are substituted to hold
decoration::

  class InstrumentedList(list):
      pass

Collection classes can be specified in ``relationship(collection_class=)`` as
types or a function that returns an instance.  Collection classes are
inspected and instrumented during the mapper compilation phase.  The
collection_class callable will be executed once to produce a specimen
instance, and the type of that specimen will be instrumented.  Functions that
return built-in types like ``lists`` will be adapted to produce instrumented
instances.

When extending a known type like ``list``, additional decorations are not
generally not needed.  Odds are, the extension method will delegate to a
method that's already instrumented.  For example::

  class QueueIsh(list):
     def push(self, item):
         self.append(item)
     def shift(self):
         return self.pop(0)

There's no need to decorate these methods.  ``append`` and ``pop`` are already
instrumented as part of the ``list`` interface.  Decorating them would fire
duplicate events, which should be avoided.

The targeted decoration tries not to rely on other methods in the underlying
collection class, but some are unavoidable.  Many depend on 'read' methods
being present to properly instrument a 'write', for example, ``__setitem__``
needs ``__getitem__``.  "Bulk" methods like ``update`` and ``extend`` may also
reimplemented in terms of atomic appends and removes, so the ``extend``
decoration will actually perform many ``append`` operations and not call the
underlying method at all.

Tight control over bulk operation and the firing of events is also possible by
implementing the instrumentation internally in your methods.  The basic
instrumentation package works under the general assumption that collection
mutation will not raise unusual exceptions.  If you want to closely
orchestrate append and remove events with exception management, internal
instrumentation may be the answer.  Within your method,
``collection_adapter(self)`` will retrieve an object that you can use for
explicit control over triggering append and remove events.

The owning object and :class:`.CollectionAttributeImpl` are also reachable
through the adapter, allowing for some very sophisticated behavior.

�N)�inspect_getfullargspec�)�base�)�exc)�util)�
expression)�
collection�collection_adapter�mapped_collection�column_mapped_collection�attribute_mapped_collectionc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�_PlainColumnGetterz�Plain column getter, stores collection of Column objects
    directly.

    Serializes to a :class:`._SerializableColumnGetterV2`
    which has more expensive __call__() performance
    and some rare caveats.

    c�D�||_t|��dk|_dS�Nr)�cols�len�	composite)�selfrs  �Q/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/orm/collections.py�__init__z_PlainColumnGetter.__init__�s����	��T���Q������c�@�t�|j��S�N)�_SerializableColumnGetterV2�_reduce_from_colsr�rs r�
__reduce__z_PlainColumnGetter.__reduce__�s��*�<�<�T�Y�G�G�Grc��|jSr)r)r�mappers  r�_colsz_PlainColumnGetter._cols�s
���y�rc�����tj|���tj������fd�|����D��}|jrt|��S|dS)Nc�H��g|]}����j|����S�)�_get_state_attr_by_column�dict)�.0�col�m�states  ��r�
<listcomp>z/_PlainColumnGetter.__call__.<locals>.<listcomp>�s=���
�
�
��
�'�'��u�z�3�?�?�
�
�
rr)r�instance_state�
_state_mapperr"r�tuple�r�value�keyr*r+s   @@r�__call__z_PlainColumnGetter.__call__�s|�����#�E�*�*����u�%�%��
�
�
�
�
��z�z�!�}�}�
�
�
��
�>�	���:�:���q�6�MrN)�__name__�
__module__�__qualname__�__doc__rrr"r3r%rrrrs]��������'�'�'�H�H�H��������rrc�$�eZdZdZd�Zd�Zd�ZdS)�_SerializableColumnGetterzlColumn-based getter used in version 0.7.6 only.

    Remains here for pickle compatibility with 0.7.6.

    c�D�||_t|��dk|_dSr��colkeysrr�rr<s  rrz"_SerializableColumnGetter.__init__��������W����)����rc� �t|jffSr)r9r<rs rrz$_SerializableColumnGetter.__reduce__�s��(�4�<�/�9�9rc����tj|���tj������fd�|jD��}|jrt|��S|dS)Nc�h��g|].}����j�jj|����/Sr%)r&r'�mapped_table�columns)r(�kr*r+s  ��rr,z6_SerializableColumnGetter.__call__.<locals>.<listcomp>�sN���
�
�
��
�'�'��u�z�1�>�#9�!�#<�
�
�
�
�
rr)rr-r.r<rr/r0s   @@rr3z"_SerializableColumnGetter.__call__�sv�����#�E�*�*����u�%�%��
�
�
�
�
��\�	
�
�
���>�	���:�:���q�6�MrN)r4r5r6r7rrr3r%rrr9r9�sK��������*�*�*�:�:�:�����rr9c�:�eZdZdZd�Zd�Zed���Zd�ZdS)ra<Updated serializable getter which deals with
    multi-table mapped classes.

    Two extremely unusual cases are not supported.
    Mappings which have tables across multiple metadata
    objects, or which are mapped to non-Table selectables
    linked across inheriting mappers may fail to function
    here.

    c�D�||_t|��dk|_dSrr;r=s  rrz$_SerializableColumnGetterV2.__init__�r>rc� �|j|jffSr)�	__class__r<rs rrz&_SerializableColumnGetterV2.__reduce__�s���~����.�.rc�:��d���fd�|D��}t|ffS)Nc�\�t|jtj��sdS|jjSr)�
isinstance�tabler	�TableClauser2)�cs r�
_table_keyzA_SerializableColumnGetterV2._reduce_from_cols.<locals>._table_key�s(���a�g�z�'=�>�>�
#��t��w�{�"rc�4��g|]}|j�|��f��Sr%)r2)r(rNrOs  �rr,zA_SerializableColumnGetterV2._reduce_from_cols.<locals>.<listcomp>�s(���8�8�8�a�A�E�:�:�a�=�=�)�8�8�8r)r)�clsrr<rOs   @rrz-_SerializableColumnGetterV2._reduce_from_cols�s:���	#�	#�	#�9�8�8�8�4�8�8�8��*�W�J�6�6rc��g}t|jdd��}|jD]^\}}|�|�||vr&|�|jj|���3|�|j|j|���_|S)N�metadata)�getattr�local_tabler<�appendrN�tables)rr!rrS�ckey�tkeys      rr"z!_SerializableColumnGetterV2._cols�s������6�-�z�4�@�@�� �L�	;�	;�L�T�4��|�x�/�4�x�3G�3G����F�.�0��6�7�7�7�7����H�O�D�1�3�D�9�:�:�:�:��rN)	r4r5r6r7rr�classmethodrr"r%rrrr�sf������	�	�*�*�*�/�/�/��7�7��[�7�����rrc�h��d�tj|��D��}t|����fd�S)a�A dictionary-based collection type with column-based keying.

    Returns a :class:`.MappedCollection` factory with a keying function
    generated from mapping_spec, which may be a Column or a sequence
    of Columns.

    The key value must be immutable for the lifetime of the object.  You
    can not, for example, map on foreign key values if those key values will
    change during the session, i.e. from None to a database-assigned integer
    after a session flush.

    c�8�g|]}tj|d����S)�mapping_spec)r	�_only_column_elements)r(�qs  rr,z,column_mapped_collection.<locals>.<listcomp>�s5�����
�	�(��N�;�;���rc�"��t���Sr��MappedCollection��keyfuncs�r�<lambda>z*column_mapped_collection.<locals>.<lambda>�����#�G�,�,�r)r�to_listr)r]rrds  @rr
r
�sI�������l�+�+����D�!��&�&�G�,�,�,�,�,rc� �eZdZd�Zd�Zd�ZdS)�_SerializableAttrGetterc�F�||_tj|��|_dSr)�name�operator�
attrgetter�getter)rrks  rrz _SerializableAttrGetter.__init__�s����	��)�$�/�/����rc�,�|�|��Sr�rn)r�targets  rr3z _SerializableAttrGetter.__call__s���{�{�6�"�"�"rc� �t|jffSr)rirkrs rrz"_SerializableAttrGetter.__reduce__s��&����4�4rN)r4r5r6rr3rr%rrriri�sA������0�0�0�#�#�#�5�5�5�5�5rric�,��t|����fd�S)a�A dictionary-based collection type with attribute-based keying.

    Returns a :class:`.MappedCollection` factory with a keying based on the
    'attr_name' attribute of entities in the collection, where ``attr_name``
    is the string name of the attribute.

    .. warning:: the key value must be assigned to its final value
       **before** it is accessed by the attribute mapped collection.
       Additionally, changes to the key attribute are **not tracked**
       automatically, which means the key in the dictionary is not
       automatically synchronized with the key value on the target object
       itself.  See the section :ref:`key_collections_mutations`
       for an example.

    c�"��t���Srrarps�rrez-attribute_mapped_collection.<locals>.<lambda>s���#�F�+�+�r)ri)�	attr_namerns @rrr	s!��� %�Y�
/�
/�F�+�+�+�+�+rc����fd�S)a�A dictionary-based collection type with arbitrary keying.

    Returns a :class:`.MappedCollection` factory with a keying function
    generated from keyfunc, a callable that takes an entity and returns a
    key value.

    The key value must be immutable for the lifetime of the object.  You
    can not, for example, map on foreign key values if those key values will
    change during the session, i.e. from None to a database-assigned integer
    after a session flush.

    c�"��t���Srrarcs�rrez#mapped_collection.<locals>.<lambda>*rfrr%rcs`rrrs���-�,�,�,�,rc�P�eZdZdZed���Zed���Zed���Zed���Zee	j
dd��d�����ZeZ	ee	j
d	d
��d�����Z
ed���Zed
���Zed���Zed���ZdS)r
a}Decorators for entity collection classes.

    The decorators fall into two groups: annotations and interception recipes.

    The annotating decorators (appender, remover, iterator, linker, converter,
    internally_instrumented) indicate the method's purpose and take no
    arguments.  They are not written with parens::

        @collection.appender
        def append(self, append): ...

    The recipe decorators all require parens, even those that take no
    arguments::

        @collection.adds('entity')
        def insert(self, position, entity): ...

        @collection.removes_return()
        def popitem(self): ...

    c��d|_|S)aTag the method as the collection appender.

        The appender method is called with one positional argument: the value
        to append. The method will be automatically decorated with 'adds(1)'
        if not already decorated::

            @collection.appender
            def add(self, append): ...

            # or, equivalently
            @collection.appender
            @collection.adds(1)
            def add(self, append): ...

            # for mapping type, an 'append' may kick out a previous value
            # that occupies that slot.  consider d['a'] = 'foo'- any previous
            # value in d['a'] is discarded.
            @collection.appender
            @collection.replaces(1)
            def add(self, entity):
                key = some_key_func(entity)
                previous = None
                if key in self:
                    previous = self[key]
                self[key] = entity
                return previous

        If the value to append is not allowed in the collection, you may
        raise an exception.  Something to remember is that the appender
        will be called for each object mapped by a database query.  If the
        database contains rows that violate your collection semantics, you
        will need to get creative to fix the problem, as access via the
        collection will not work.

        If the appender method is internally instrumented, you must also
        receive the keyword argument '_sa_initiator' and ensure its
        promulgation to collection events.

        �appender��_sa_instrument_role��fns rrzzcollection.appenderGs��R",����	rc��d|_|S)aTag the method as the collection remover.

        The remover method is called with one positional argument: the value
        to remove. The method will be automatically decorated with
        :meth:`removes_return` if not already decorated::

            @collection.remover
            def zap(self, entity): ...

            # or, equivalently
            @collection.remover
            @collection.removes_return()
            def zap(self, ): ...

        If the value to remove is not present in the collection, you may
        raise an exception or return None to ignore the error.

        If the remove method is internally instrumented, you must also
        receive the keyword argument '_sa_initiator' and ensure its
        promulgation to collection events.

        �removerr{r}s rr�zcollection.removerss��0"+����	rc��d|_|S)z�Tag the method as the collection remover.

        The iterator method is called with no arguments.  It is expected to
        return an iterator over all collection members::

            @collection.iterator
            def __iter__(self): ...

        �iteratorr{r}s rr�zcollection.iterator�s��",����	rc��d|_|S)a�Tag the method as instrumented.

        This tag will prevent any decoration from being applied to the
        method. Use this if you are orchestrating your own calls to
        :func:`.collection_adapter` in one of the basic SQLAlchemy
        interface methods, or to prevent an automatic ABC method
        decoration from wrapping your implementation::

            # normally an 'extend' method on a list-like class would be
            # automatically intercepted and re-implemented in terms of
            # SQLAlchemy events and append().  your implementation will
            # never be called, unless:
            @collection.internally_instrumented
            def extend(self, items): ...

        T)�_sa_instrumentedr}s r�internally_instrumentedz"collection.internally_instrumented�s��$#����	rz1.0z�The :meth:`.collection.linker` handler is deprecated and will be removed in a future release.  Please refer to the :meth:`.AttributeEvents.init_collection` and :meth:`.AttributeEvents.dispose_collection` event handlers. c��d|_|S)a�Tag the method as a "linked to attribute" event handler.

        This optional event handler will be called when the collection class
        is linked to or unlinked from the InstrumentedAttribute.  It is
        invoked immediately after the '_sa_adapter' property is set on
        the instance.  A single argument is passed: the collection adapter
        that has been linked, or None if unlinking.


        �linkerr{r}s rr�zcollection.linker�s��&"*����	rz1.3z�The :meth:`.collection.converter` handler is deprecated and will be removed in a future release.  Please refer to the :class:`.AttributeEvents.bulk_replace` listener interface in conjunction with the :func:`.event.listen` function.c��d|_|S)a�Tag the method as the collection converter.

        This optional method will be called when a collection is being
        replaced entirely, as in::

            myobj.acollection = [newvalue1, newvalue2]

        The converter method will receive the object being assigned and should
        return an iterable of values suitable for use by the ``appender``
        method.  A converter must not assign values or mutate the collection,
        its sole job is to adapt the value the user provides into an iterable
        of values for the ORM's use.

        The default converter implementation will use duck-typing to do the
        conversion.  A dict-like collection will be convert into an iterable
        of dictionary values, and other types will simply be iterated::

            @collection.converter
            def convert(self, other): ...

        If the duck-typing of the object does not match the type of this
        collection, a TypeError is raised.

        Supply an implementation of this method if you want to expand the
        range of possible types that can be assigned in bulk or perform
        validation on the values about to be assigned.

        �	converterr{r}s rr�zcollection.converter�s��J"-����	rc����fd�}|S)a�Mark the method as adding an entity to the collection.

        Adds "add to collection" handling to the method.  The decorator
        argument indicates which method argument holds the SQLAlchemy-relevant
        value.  Arguments can be specified positionally (i.e. integer) or by
        name::

            @collection.adds(1)
            def push(self, item): ...

            @collection.adds('entity')
            def do_stuff(self, thing, entity=None): ...

        c���d�f|_|S)N�fire_append_event��_sa_instrument_before�r~�args �r�	decoratorz"collection.adds.<locals>.decorator����(;�S�'A�B�$��Irr%�r�r�s` r�addszcollection.adds��$���"	�	�	�	�	��rc����fd�}|S)aMark the method as replacing an entity in the collection.

        Adds "add to collection" and "remove from collection" handling to
        the method.  The decorator argument indicates which method argument
        holds the SQLAlchemy-relevant value to be added, and return value, if
        any will be considered the value to remove.

        Arguments can be specified positionally (i.e. integer) or by name::

            @collection.replaces(2)
            def __setitem__(self, index, item): ...

        c�(��d�f|_d|_|S)Nr��fire_remove_event)r��_sa_instrument_afterr�s �rr�z&collection.replaces.<locals>.decorators���(;�S�'A�B�$�&9�B�#��Irr%r�s` r�replaceszcollection.replacess$��� 	�	�	�	�	�
�rc����fd�}|S)aMark the method as removing an entity in the collection.

        Adds "remove from collection" handling to the method.  The decorator
        argument indicates which method argument holds the SQLAlchemy-relevant
        value to be removed. Arguments can be specified positionally (i.e.
        integer) or by name::

            @collection.removes(1)
            def zap(self, item): ...

        For methods where the value to remove is not known at call-time, use
        collection.removes_return.

        c���d�f|_|S�Nr�r�r�s �rr�z%collection.removes.<locals>.decorator6r�rr%r�s` r�removeszcollection.removes%r�rc��d�}|S)a�Mark the method as removing an entity in the collection.

        Adds "remove from collection" handling to the method.  The return
        value of the method, if any, is considered the value to remove.  The
        method arguments are not inspected::

            @collection.removes_return()
            def pop(self): ...

        For methods where the value to remove is known at call-time, use
        collection.remove.

        c��d|_|Sr�)r�r}s rr�z,collection.removes_return.<locals>.decoratorLs��&9�B�#��Irr%)r�s r�removes_returnzcollection.removes_return<s�� 	�	�	��rN)r4r5r6r7�staticmethodrzr�r�r�r�
deprecatedr��linkr�r�r�r�r�r%rrr
r
-s���������2�)�)��\�)�V����\��4����\������\��(��T�_�
�	K��������\���D����T�_�
�	?��������\��@����\��,����\��,����\��,����\���rr
�_sa_adapterc���eZdZdZdZd�Zd�Zed���Zed���Z	d�Z
dd	�Zd
�Zd�Z
d�Zdd
�Zd�Zdd�Zd�Zd�Zd�Zd�ZeZdd�Zdd�Zdd�Zd�Zd�ZdS)�CollectionAdapteraiBridges between the ORM and arbitrary Python collections.

    Proxies base-level collection operations (append, remove, iterate)
    to the underlying Python collection, and emits add/remove events for
    entities entering or leaving the collection.

    The ORM uses :class:`.CollectionAdapter` exclusively for interaction with
    entity collections.


    )�attr�_key�_data�owner_state�
_converter�invalidatedc��||_|j|_tj|��|_||_||_|j|_	d|_
dS)NF)r�r2r��weakref�refr�r�r��
_sa_converterr�r�)rr�r��datas    rrzCollectionAdapter.__init__msK����	��H��	��[��&�&��
�&�������,��� ����rc�.�tjd��dS)Nz%This collection has been invalidated.)r�warnrs r�_warn_invalidatedz#CollectionAdapter._warn_invalidatedvs���	�9�:�:�:�:�:rc�*�|���S)z$The entity collection being adapted.)r�rs rr�zCollectionAdapter.datays���z�z�|�|�rc�X�|jj|j|���uS)z�return True if the owner state still refers to this collection.

        This will return False within a bulk replace operation,
        where this collection is the one being replaced.

        )r�r'r�r�rs r�_referenced_by_ownerz&CollectionAdapter._referenced_by_owner~s$����$�T�Y�/�4�:�:�<�<�?�?rc�4�|���jSr�r��_sa_appenderrs r�
bulk_appenderzCollectionAdapter.bulk_appender�s���z�z�|�|�(�(rNc�X�|����||���dS)z8Add an entity to the collection, firing mutation events.��
_sa_initiatorNr��r�item�	initiators   r�append_with_eventz#CollectionAdapter.append_with_event�s+��	
�
�
���!�!�$�i�!�@�@�@�@�@rc�X�|����|d���dS�z=Add or restore an entity to the collection, firing no events.Fr�Nr��rr�s  r�append_without_eventz&CollectionAdapter.append_without_event�s)���
�
���!�!�$�e�!�<�<�<�<�<rc�\�|���j}|D]}||d����dSr�r�)r�itemsrzr�s    r�append_multiple_without_eventz/CollectionAdapter.append_multiple_without_event�sC���:�:�<�<�,���	0�	0�D��H�T��/�/�/�/�/�	0�	0rc�4�|���jSr�r��_sa_removerrs r�bulk_removerzCollectionAdapter.bulk_remover�s���z�z�|�|�'�'rc�X�|����||���dS)z=Remove an entity from the collection, firing mutation events.r�Nr�r�s   r�remove_with_eventz#CollectionAdapter.remove_with_event�s)���
�
��� � ��Y� �?�?�?�?�?rc�X�|����|d���dS)z7Remove an entity from the collection, firing no events.Fr�Nr�r�s  r�remove_without_eventz&CollectionAdapter.remove_without_event�s)���
�
��� � ��U� �;�;�;�;�;rc�v�|���j}t|��D]}|||����dS)z>Empty the collection, firing a mutation event for each entity.r�N�r�r��list)rr�r�r�s    r�clear_with_eventz"CollectionAdapter.clear_with_event�sK���*�*�,�,�*����J�J�	3�	3�D��G�D�	�2�2�2�2�2�	3�	3rc�v�|���j}t|��D]}||d����dS)z'Empty the collection, firing no events.Fr�Nr�)rr�r�s   r�clear_without_eventz%CollectionAdapter.clear_without_event�sK���*�*�,�,�*����J�J�	/�	/�D��G�D��.�.�.�.�.�	/�	/rc�h�t|��������S)z(Iterate over entities in the collection.)�iterr��_sa_iteratorrs r�__iter__zCollectionAdapter.__iter__�s&���D�J�J�L�L�-�-�/�/�0�0�0rc��tt|����������S)z!Count entities in the collection.)rr�r�r�rs r�__len__zCollectionAdapter.__len__�s,���4��
�
���1�1�3�3�4�4�5�5�5rc��dS�NTr%rs r�__bool__zCollectionAdapter.__bool__�s���trc��|durG|jr|���|j�|j|jj||��S|S)a Notify that a entity has entered the collection.

        Initiator is a token owned by the InstrumentedAttribute that
        initiated the membership mutation, and should be left as None
        unless you are passing along an initiator value from a chained
        operation.

        F)r�r�r�r�r�r'r�s   rr�z#CollectionAdapter.fire_append_event�s_���E�!�!���
)��&�&�(�(�(��9�.�.�� �$�"2�"7��y���
��Krc��|durI|jr|���|j�|j|jj||��dSdS)aNotify that a entity has been removed from the collection.

        Initiator is the InstrumentedAttribute that initiated the membership
        mutation, and should be left as None unless you are passing along
        an initiator value from a chained operation.

        FN)r�r�r�r�r�r'r�s   rr�z#CollectionAdapter.fire_remove_event�sj���E�!�!���
)��&�&�(�(�(��I�'�'�� �$�"2�"7��y�
�
�
�
�
�"�!rc��|jr|���|j�|j|jj|���dS)z�Notify that an entity is about to be removed from the collection.

        Only called if the entity cannot be removed after calling
        fire_remove_event().

        �r�N)r�r�r��fire_pre_remove_eventr�r')rr�s  rr�z'CollectionAdapter.fire_pre_remove_event�sZ����	%��"�"�$�$�$��	�'�'���d�.�3�y�	(�	
�	
�	
�	
�	
rc�N�|j|j|jj|j|jd�S)N)r2r��	owner_clsr�r�)r�r��class_r�r�rs r�__getstate__zCollectionAdapter.__getstate__�s0���9��+��)�0��I��+�
�
�	
rc��|d|_|d|_tj|d��|_|dj|_||d_|d|_t|d|j��j
|_dS)Nr2r�r�r�r�)r�r�r�r�r�r�r�r�r�rT�implr�)r�ds  r�__setstate__zCollectionAdapter.__setstate__�st���e�H��	��]�+����[��6��+�+��
��F�)�1��� $��&�	���]�+����A�k�N�D�I�6�6�;��	�	�	rr)r4r5r6r7�	__slots__rr��propertyr�r�r�r�r�r�r�r�r�r�r�r�r�r��__nonzero__r�r�r�r�r�r%rrr�r�Ws�������
�
��I�!�!�!�;�;�;�����X���@�@��X�@�)�)�)�A�A�A�A�
=�=�=�0�0�0�(�(�(�@�@�@�@�<�<�<�3�3�3�3�/�/�/�1�1�1�
6�6�6�����K�����$
�
�
�
�
�
�
�
�
�
�
�<�<�<�<�<rr�c��t|t��sJ�tj}||pd��}|�|pd��}||pd���|��}|�|��}|���}	|pdD]%}
|
|vr|	|
|����|
|vr
|	|
d����&|r|D]}
|�|
|����dSdS)aFLoad a new collection, firing events based on prior like membership.

    Appends instances in ``values`` onto the ``new_adapter``. Events will be
    fired for any instance not present in the ``existing_adapter``.  Any
    instances in ``existing_adapter`` not present in ``values`` will have
    remove events fired upon them.

    :param values: An iterable of collection member instances

    :param existing_adapter: A :class:`.CollectionAdapter` of
     instances to be replaced

    :param new_adapter: An empty :class:`.CollectionAdapter`
     to load with ``values``


    r%r�Fr�N)rKr�r�IdentitySet�intersection�
differencer�r�)�values�existing_adapter�new_adapterr��idset�existing_idset�	constants�	additions�removalsrz�members           r�bulk_replacer�s8��&�f�d�#�#�#�#�#���E��U�+�1�r�2�2�N��+�+�F�L�b�9�9�I���f�l��#�#�.�.�y�9�9�I��(�(��3�3�H��(�(�*�*�H��,�B�2�2���Y����H�V�9�5�5�5�5�5�
�y�
 �
 ��H�V�5�1�1�1�1���L��	L�	L�F��.�.�v��.�K�K�K�K�L�L�	L�	Lrc��|tvr
t|}t|����}|tvrt||��}|��}t���rj	t|dd��t
|��krt|��t���n#t���wxYw|S)aoPrepare a callable for future use as a collection class factory.

    Given a collection class factory (either a type or no-arg callable),
    return another factory that will produce compatible instances when
    called.

    This function is responsible for converting collection_class=list
    into the run-time behavior of collection_class=InstrumentedList.

    r�N)	�__canned_instrumentation�type�__converting_factory�__instrumentation_mutex�acquirerT�id�_instrument_class�release)�factoryrQs  r�prepare_instrumentationr
*s����*�*�*�*�7�3���w�w�y�y�/�/�C��&�&�&�&�s�G�4�4���g�i�i���&�&�(�(�.�	.��s�.��5�5��C���@�@�!�#�&�&�&�#�+�+�-�-�-�-��#�+�+�-�-�-�-�����Ns�+1B6�6Cc�f���t|���fd�}d�jz|_�j|_|S)zsReturn a wrapper that converts a "canned" collection like
    set, dict, list into the Instrumented* version.

    c�.�����}�|��Srr%)r
�instrumented_cls�original_factorys ��r�wrapperz%__converting_factory.<locals>.wrapperUs"���%�%�'�'�
���
�+�+�+rz	%sWrapper)rr4r7)�specimen_clsrrr
s ` @rrrMsQ����0��=��,�,�,�,�,�,�
#�%5�%>�>�G��&�.�G�O��Nrc���|jdkrtjd���t|��\}}t	|||��t|||��t
|||��dS)z6Modify methods in a class and install instrumentation.�__builtin__zGCan not instrument a built-in type. Use a subclass, even a trivial one.N)r5�sa_exc�
ArgumentError�_locate_roles_and_methods�_setup_canned_roles�_assert_required_roles�_set_collection_attributes�rQ�roles�methodss   rrr`sz���~��&�&��"�
,�
�
�	
�
/�s�3�3�N�E�7���U�G�,�,�,��3��w�/�/�/��s�E�7�3�3�3�3�3rc��i}i}|jD]�}t|�����D]�\}}tj|��s�t|d��r#|j}|dvsJ�|�||��d\}}t|d��r|j\}	}
|	dvsJ�|	|
f}t|d��r|j	}	|	dvsJ�|	}|r
||fz||<��|rdd|f||<����||fS)zgsearch for _sa_instrument_role-decorated methods in
    method resolution order, assign to roles.

    r|)rzr�r�r�r�)NNr�)r�r�r�N)
�__mro__�varsr�r�callable�hasattrr|�
setdefaultr�r�)rQrr�superclsrk�method�role�before�after�op�arguments           rrruse��
�E��G��K�2�2�� ��N�N�0�0�2�2�	2�	2�L�D�&��=��(�(�
���v�4�5�5�	
-��1��� ������ � ��t�,�,�,�'�M�F�E��v�6�7�7�
&�%�;���H��G�G�G�G�G��X����v�5�6�6�
��0���G�G�G�G�G����
2� &�%�� 1���
�
��
2� $�d�E� 1���
��=	2�>�'�>�rc�z�tj|��}|tvr�t|\}}|���D]\}}|�||���|���D]H\}}	t||d��}
|
r.||vr*t
|
d��st|||	|
�����GdSdS)z�see if this class has "canned" roles based on a known
    collection type (dict, set, list).  Apply those roles
    as needed to the "roles" dictionary, and also
    prepare "decorator" methods

    Nr�)r�duck_type_collection�__interfacesr�r!rTr �setattr)rQrr�collection_type�canned_roles�
decoratorsr$rkr#r�r~s           rrr�s����/��4�4�O��,�&�&�#/��#@� ��j�&�,�,�.�.�	)�	)�J�D�$����T�4�(�(�(�(�",�!1�!1�!3�!3�	4�	4��F�I���f�d�+�+�B��
4��'�)�)���$6�7�7�*���V�Y�Y�r�]�]�3�3�3��'�&�	4�	4rc�.�d|vst||d��stjd|jz���|d|vr/tt	||d��d��sd||d<d|vst||d��stjd|jz���|d|vr/tt	||d��d��sd||d<d|vst||d��stjd	|jz���d
S)zTensure all roles are present, and apply implicit instrumentation if
    needed

    rzz>Type %s must elect an appender method to be a collection classr�)r�rNr�z<Type %s must elect a remover method to be a collection class)r�rNr�z>Type %s must elect an iterator method to be a collection classN)r rrr4rTrs   rrr�se��
����g�c�5��3D�&E�&E���"�
!�#&�<�
0�
�
�	
�
�z�	�'�	)�	)�'���U�:�&�'�'�);�3�3�	)�&D���j�!�"�����W�S�%�	�2B�%C�%C���"�
!�#&�<�
0�
�
�	
�
�y�	��	(�	(����U�9�%�&�&�(:�2�2�	(�%C���i� �!�����g�c�5��3D�&E�&E���"�
!�#&�<�
0�
�
�	
��rc�|�|���D]8\}\}}}t||tt||��|||�����9|���D]'\}}t|d|zt||�����(d|_t|d��sd|_t|��|_dS)zkapply ad-hoc instrumentation from decorators, class-level defaults
    and implicit role declarations

    z_sa_%sNr�)	r�r,�_instrument_membership_mutatorrTr�r r�rr�)rQrr�method_namer%r(r&r$s        rrr�s���
3:�-�-�/�/�
�
�.��.�f�h�����*���[�)�)�6�8�U�
�
�	
�	
�	
�	
�#�[�[�]�]�A�A���k���X��_�g�c�;�&?�&?�@�@�@�@��C�O��3��(�(�!� ����c�7�7�C���rc���������r�ttjt���d����}t	�t
��r ��t
|���kr|�pd�n�|vr|�����nd���~������fd�}d|_t�d��r�j
|_
�j|_�j|_|S)zIRoute method args and/or return value through the collection
    adapter.rNc�����rf��$�
|vrtjd�z���|�
}n@t|���kr	|�}n$�
|vr	|�
}ntjd�z���|�dd��}|durd}n
|dj}�r|rt|���||���r|s�	|i|��S�	|i|��}|�t|���||��|S)NzMissing argument %sr�Fr)rrr�popr�rT)�args�kwr1r��executor�resr&r(r%r#�	named_arg�pos_args      ������rrz/_instrument_membership_mutator.<locals>.wrappersN����	����B�&�&� �.�-��8�����9�
����t�9�9�w�&�&� ��M�E�E��"�_�_��y�M�E�E� �.�-��8�����F�F�?�D�1�1�	������H�H��A�w�*�H��	8�h�	8�%�G�H�f�%�%�e�Y�7�7�7��	�H�	��6�4�&�2�&�&�&��&�$�%�"�%�%�C���(���%�(�(��i�8�8�8��JrTr|)
r�r�flatten_iteratorrrK�intr�indexr�r r|r4r7)r#r%r(r&�fn_argsrr;r<s````  @@rr2r2�s���������
���!�"8��"@�"@��"C�D�D�
�
���h��$�$�	!��G��G���x�/�E�G�H�4E�M��I�I��7�"�"�!�-�-��1�1����� �I��!�!�!�!�!�!�!�!�!�!�F $�G���v�,�-�-�A�&,�&@��#���G���n�G�O��Nrc�L�|dur|j}|r|�||��}|S)z^Run set events.

    This event always occurs before the collection is actually mutated.

    F)r�r��r
r�r�r9s    r�__setrC/s:���E�!�!��)���	C��-�-�d�M�B�B�D��Krc�T�|dur!|j}|r|�||��dSdSdS)aRun del events.

    This event occurs before the collection is actually mutated, *except*
    in the case of a pop operation, in which case it occurs afterwards.
    For pop operations, the __before_pop hook is called before the
    operation occurs.

    FN)r�r�rBs    r�__delrE=sM���E�!�!��)���	<��&�&�t�]�;�;�;�;�;�"�!�	<�	<rc�F�|j}|r|�|��dSdS)z;An event which occurs on a before a pop() operation occurs.N)r�r�)r
r�r9s   r�__before_poprGLs6���%�H��6��&�&�}�5�5�5�5�5�6�6rc���d���fd�}�fd�}�fd�}�fd�}�fd�}tjr
�fd�}�fd�}�fd	�}�fd
�}�fd�}	tjs�fd�}
t�����}|�d
��|S)z:Tailored instrumentation wrappers for any list-like class.c�\�d|_tt|j��j|_dSr�)r�rTr�r4r7r}s r�_tidyz_list_decorators.<locals>._tidyV�$��"����T�2�;�/�/�7��
�
�
rc�,���d�fd�	}�|��|S)Nc�B��t|||��}�||��dSr�rC)rr�r�r~s   �rrVz0_list_decorators.<locals>.append.<locals>.append[s'�����t�]�3�3�D��B�t�T�N�N�N�N�Nrrr%)r~rVrJs` �rrVz _list_decorators.<locals>.appendZs6����	�	�	�	�	�	�	��f�
�
�
��
rc�,���d�fd�	}�|��|S)Nc�B��t|||���||��dSr�rE�rr1r�r~s   �r�removez0_list_decorators.<locals>.remove.<locals>.removecs(����$��}�-�-�-��B�t�U�O�O�O�O�Orrr%�r~rSrJs` �rrSz _list_decorators.<locals>.removebs6����	�	�	�	�	�	�
	��f�
�
�
��
rc�*����fd�}�|��|S)Nc�B��t||��}�|||��dSrrN)rr?r1r~s   �r�insertz0_list_decorators.<locals>.insert.<locals>.insertls,����$��&�&�E��B�t�U�E�"�"�"�"�"rr%)r~rWrJs` �rrWz _list_decorators.<locals>.insertks1����	#�	#�	#�	#�	#�	��f�
�
�
��
rc�*����fd�}�|��|S)Nc�b��t|t��s9||}|�t||��t||��}�
|||��dS|jpd}|jpd}|dkr|t
|��z
}|j�|j}nt
|��}|dkr|t
|��z
}|dkr`||urdSt|||��D]}t
|��|kr||=�t|��D]\}}|�
||z|���dStt|||����}	t
|��t
|	��kr/tdt
|���dt
|	�������t|	|��D]\}}|�||���dS)Nrrz#attempt to assign sequence of size z to extended slice of size )rK�slicerErC�step�startr�stop�range�	enumeraterWr��
ValueError�zip�__setitem__)rr?r1�existingr[r\r]�ir��rngr~s          �rrbz:_list_decorators.<locals>.__setitem__.<locals>.__setitem__ts�����e�U�+�+�%
2���;���'��$��)�)�)��d�E�*�*����4���&�&�&�&�&��z��Q����(�q���1�9�9��S��Y�Y�&�E��:�)� �:�D�D��t�9�9�D��!�8�8��C��I�I�%�D��1�9�9���}�}���"�5�$��5�5�,�,���t�9�9�u�,�,� $�U���#,�U�#3�#3�5�5���4����A��I�t�4�4�4�4�5�5��u�U�D�$�7�7�8�8�C��5�z�z�S��X�X�-�-�(�j� #�5�z�z�z�z�3�s�8�8�8�5����
$'�s�E�?�?�2�2���4��(�(��D�1�1�1�1�2�2rr%�r~rbrJs` �rrbz%_list_decorators.<locals>.__setitem__ss6����&	2�&	2�&	2�&	2�&	2�P	��k�����rc�*����fd�}�|��|S)Nc����t|t��s&||}t||���||��dS||D]}t||����||��dSr)rKrZrE�rr?r�r~s   �r�__delitem__z:_list_decorators.<locals>.__delitem__.<locals>.__delitem__�s|����e�U�+�+�

 ��E�{���d�D�!�!�!���4�������
!��K�&�&�D��$��%�%�%�%���4������rr%�r~rjrJs` �rrjz%_list_decorators.<locals>.__delitem__�s5����	 �	 �	 �	 �	 �	��k�����rc�*����fd�}�|��|S)Nc�|����||�D]}t�|����fd�|D��}��|||��dS)Nc�0��g|]}t�|����Sr%rN)r(r1rs  �rr,zP_list_decorators.<locals>.__setslice__.<locals>.__setslice__.<locals>.<listcomp>�s#���A�A�A��%��e�,�,�A�A�ArrQ)rr\�endr�r1r~s`    �r�__setslice__z<_list_decorators.<locals>.__setslice__.<locals>.__setslice__�sc����!�%��)�_�'�'�E��$��&�&�&�&�A�A�A�A�&�A�A�A����4���V�,�,�,�,�,rr%)r~rprJs` �rrpz&_list_decorators.<locals>.__setslice__�s5����
-�
-�
-�
-�
-�
�E�,�����rc�*����fd�}�|��|S)Nc�\��|||�D]}t||����|||��dSrrQ)rr\ror1r~s    �r�__delslice__z<_list_decorators.<locals>.__delslice__.<locals>.__delslice__�sG���!�%��)�_�'�'�E��$��&�&�&�&���4���$�$�$�$�$rr%)r~rsrJs` �rrsz&_list_decorators.<locals>.__delslice__�s5����
%�
%�
%�
%�
%�

�E�,�����rc�$��d�}�|��|S)Nc�:�|D]}|�|���dSr�rV�r�iterabler1s   r�extendz0_list_decorators.<locals>.extend.<locals>.extend�s0��!�
#�
#�����E�"�"�"�"�
#�
#rr%)r~ryrJs  �rryz _list_decorators.<locals>.extend�s&���	#�	#�	#�	��f�
�
�
��
rc�$��d�}�|��|S)Nc�:�|D]}|�|���|Srrvrws   r�__iadd__z4_list_decorators.<locals>.__iadd__.<locals>.__iadd__�s-��"�
#�
#�����E�"�"�"�"��Krr%)r~r|rJs  �rr|z"_list_decorators.<locals>.__iadd__��&���	�	�	�	��h�����rc�,���d�fd�	}�|��|S)N���c�^��t|���||��}t||��|Sr�rGrEris   �rr6z*_list_decorators.<locals>.pop.<locals>.pop�s5���������2�d�E�?�?�D��$������Kr�rr%�r~r6rJs` �rr6z_list_decorators.<locals>.pop�s6����	�	�	�	�	�	�	��c�
�
�
��
rc�,���d�fd�	}�|��|S)Nrc�H��|D]}t||����|��dSrrQris   �r�clearz._list_decorators.<locals>.clear.<locals>.clear�s6��� �&�&�D��$��%�%�%�%���4�����rr�r%�r~r�rJs` �rr�z_list_decorators.<locals>.clear�s6����
�
�
�
�
�
�

�E�%�L�L�L��LrrJ)r�py2k�locals�copyr6)
rVrSrWrbrjrprsryr|r6r��lrJs
            @r�_list_decoratorsr�Sse���8�8�8����������������*�*�*�*�*�X�����"�y� �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ������	�	�	�	�	�������9�	�	�	�	�	�	�	���
�
���A��E�E�'�N�N�N��Hrc���	�d��	tjd����	fd�}�	fd�}�	fd�}��	fd�}�	fd�}�	fd�}��	fd	�}t�����}|�d
��|�d��|S)zBTailored instrumentation wrappers for any dict-like mapping class.c�\�d|_tt|j��j|_dSr�)r�rTr'r4r7r}s rrJz_dict_decorators.<locals>._tidy�rKr�Unspecifiedc�,���d�fd�	}�|��|S)Nc�z��||vrt||||��t|||��}�|||��dSr)rErC)rr2r1r�r~s    �rrbz:_dict_decorators.<locals>.__setitem__.<locals>.__setitem__sM����d�{�{��d�D��I�}�5�5�5��$��}�5�5�E��B�t�S�%� � � � � rrr%rfs` �rrbz%_dict_decorators.<locals>.__setitem__s:����	!�	!�	!�	!�	!�	!�	��k�����rc�,���d�fd�	}�|��|S)Nc�V��||vrt||||���||��dSrrQ)rr2r�r~s   �rrjz:_dict_decorators.<locals>.__delitem__.<locals>.__delitem__s5����d�{�{��d�D��I�}�5�5�5��B�t�S�M�M�M�M�Mrrr%rks` �rrjz%_dict_decorators.<locals>.__delitem__
s:����	�	�	�	�	�	�
	��k�����rc�*����fd�}�|��|S)Nc�T��|D]}t|||����|��dSrrQ)rr2r~s  �rr�z._dict_decorators.<locals>.clear.<locals>.clears:����
'�
'���d�D��I�&�&�&�&��B�t�H�H�H�H�Hrr%r�s` �rr�z_dict_decorators.<locals>.clears1����	�	�	�	�	�
	��e�����rc�0����f��fd�	}�|��|S)Nc���t|��||v}|�ur
�||��}n
�|||��}|rt||��|Srr�)rr2�default�_to_delr�r�r~s     ��rr6z*_dict_decorators.<locals>.pop.<locals>.popsf���������T�k�G��+�%�%��r�$��}�}����r�$��W�-�-���
"��d�D�!�!�!��Krr%)r~r6r�rJs` ��rr6z_dict_decorators.<locals>.pops>����#.�		�		�		�		�		�		�		�	��c�
�
�
��
rc�*����fd�}�|��|S)Nc�h��t|���|��}t||d��|Srr��rr�r~s  �r�popitemz2_dict_decorators.<locals>.popitem.<locals>.popitem,s7���������2�d�8�8�D��$��Q�� � � ��Krr%)r~r�rJs` �rr�z!_dict_decorators.<locals>.popitem+s1����	�	�	�	�	�	��g�����rc�&��dd�}�|��|S)Nc�d�||vr|�||��|S|�|��Sr)rb�__getitem__)rr2r�s   rr!z8_dict_decorators.<locals>.setdefault.<locals>.setdefault6s:���$���� � ��g�.�.�.����'�'��,�,�,rrr%)r~r!rJs  �rr!z$_dict_decorators.<locals>.setdefault5s/���	-�	-�	-�	-�	��j�����rc�,���f�fd�	}�|��|S)Nc���|�ur]t|d��r2t|��D]!}||vs||||ur||||<�"n|D]\}}||vs
|||ur|||<�|D]!}||vs||||ur||||<�"dS)N�keys)r r�)r�__otherr8r2r1r�s     �r�updatez0_dict_decorators.<locals>.update.<locals>.updateAs�����k�)�)��7�F�+�+�.�#�G�}�}�5�5���d�?�?�d�3�i�w�s�|�.K�.K�(/���D��I��5�'.�.�.�
��U��d�?�?�d�3�i�u�.D�.D�(-�D��I���
(�
(���d�?�?�d�3�i�r�#�w�&>�&>� "�3��D��I��
(�
(rr%)r~r�r�rJs  ��rr�z _dict_decorators.<locals>.update@s8���!,�	(�	(�	(�	(�	(�	(�	��f�
�
�
��
rrJ�r�symbolr�r�r6)
rbrjr�r6r�r!r�r�r�rJs
        @@r�_dict_decoratorsr��s����8�8�8��+�m�,�,�K����������������
�
�
�
�
�
������	�	�	�	�	�������$	���
�
���A��E�E�'�N�N�N��E�E�-�����Hrc�>�t|t|jfz��S)zKAllow only set, frozenset and self.__class__-derived
    objects in binops.)rK�_set_binop_basesrH�r�objs  r�_set_binops_check_strictr�[s���c�+�t�~�.?�?�@�@�@rc�x�t|t|jfz��ptj|��t
kS)z5Allow anything set-like to participate in set binops.)rKr�rHrr*�setr�s  r�_set_binops_check_looser�as9��	�3�(�D�N�+<�<�=�=�	1��$�S�)�)�S�0�rc�L��d��tjd��}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd	�}�fd
�}�fd�}	�fd�}
�fd
�}�fd�}�fd�}
t�����}|�d��|�d��|S)z9Tailored instrumentation wrappers for any set-like class.c�\�d|_tt|j��j|_dSr�)r�rTr�r4r7r}s rrJz_set_decorators.<locals>._tidyls$��"����S�"�+�.�.�6��
�
�
rr�c�,���d�fd�	}�|��|S)Nc�J��||vrt|||��}�||��dSrrNrRs   �r�addz)_set_decorators.<locals>.add.<locals>.addss2����D� � ��d�E�=�9�9���B�t�U�O�O�O�O�Orrr%)r~r�rJs` �rr�z_set_decorators.<locals>.addrs6����	�	�	�	�	�	�	��c�
�
�
��
rc�,���d�fd�	}�|��|S)Nc�J��||vrt|||���||��dSrrQrRs   �r�discardz1_set_decorators.<locals>.discard.<locals>.discard}�1�����}�}��d�E�=�1�1�1��B�t�U�O�O�O�O�Orrr%)r~r�rJs` �rr�z _set_decorators.<locals>.discard|s6����	�	�	�	�	�	�	��g�����rc�,���d�fd�	}�|��|S)Nc�J��||vrt|||���||��dSrrQrRs   �rrSz/_set_decorators.<locals>.remove.<locals>.remove�r�rrr%rTs` �rrSz_set_decorators.<locals>.remove�s6����	�	�	�	�	�	�	��f�
�
�
��
rc�*����fd�}�|��|S)Nc�\��t|���|��}t||��|Srr�r�s  �rr6z)_set_decorators.<locals>.pop.<locals>.pop�s5���������2�d�8�8�D�
�$������Krr%r�s` �rr6z_set_decorators.<locals>.pop�s1����	�	�	�	�	�	��c�
�
�
��
rc�$��d�}�|��|S)Nc�T�t|��D]}|�|���dSr)r�rSr�s  rr�z-_set_decorators.<locals>.clear.<locals>.clear�s6���T�
�
�
"�
"�����D�!�!�!�!�
"�
"rr%r�s  �rr�z_set_decorators.<locals>.clear�s&���	"�	"�	"�	��e�����rc�$��d�}�|��|S)Nc�:�|D]}|�|���dSr)r��rr1r�s   rr�z/_set_decorators.<locals>.update.<locals>.update�s,���
�
����������
�
rr%)r~r�rJs  �rr�z_set_decorators.<locals>.update�s&���	�	�	�	��f�
�
�
��
rc�$��d�}�|��|S)Nc�h�t||��stS|D]}|�|���|Sr)r��NotImplementedr�r�s   r�__ior__z1_set_decorators.<locals>.__ior__.<locals>.__ior__�s?��+�D�%�8�8�
&�%�%��
�
�����������Krr%)r~r�rJs  �rr�z _set_decorators.<locals>.__ior__�s&���	�	�	�	��g�����rc�$��d�}�|��|S)Nc�:�|D]}|�|���dSr)r�r�s   r�difference_updatezE_set_decorators.<locals>.difference_update.<locals>.difference_update�s0���
#�
#�����T�"�"�"�"�
#�
#rr%)r~r�rJs  �rr�z*_set_decorators.<locals>.difference_update�s+���	#�	#�	#�	��� � � � � rc�$��d�}�|��|S)Nc�h�t||��stS|D]}|�|���|Sr)r�r�r�r�s   r�__isub__z3_set_decorators.<locals>.__isub__.<locals>.__isub__�sC��+�D�%�8�8�
&�%�%��
#�
#�����T�"�"�"�"��Krr%)r~r�rJs  �rr�z!_set_decorators.<locals>.__isub__�r}rc�$��d�}�|��|S)Nc���|�|��t|��}}||z
||z
}}|D]}|�|���|D]}|�|���dSr)r�r�rSr��r�other�want�haverSr�r�s       r�intersection_updatezI_set_decorators.<locals>.intersection_update.<locals>.intersection_update�s~���*�*�5�1�1�3�t�9�9�$�D���+�t�d�{�C�F��
"�
"�����D�!�!�!�!��
�
����������
�
rr%)r~r�rJs  �rr�z,_set_decorators.<locals>.intersection_update�s+���	�	�	�	��!�"�"�"�"�"rc�$��d�}�|��|S)Nc��t||��stS|�|��t|��}}||z
||z
}}|D]}|�|���|D]}|�|���|Sr)r�r�r�r�rSr�r�s       r�__iand__z3_set_decorators.<locals>.__iand__.<locals>.__iand__�s���+�D�%�8�8�
&�%�%��*�*�5�1�1�3�t�9�9�$�D���+�t�d�{�C�F��
"�
"�����D�!�!�!�!��
�
�����������Krr%)r~r�rJs  �rr�z!_set_decorators.<locals>.__iand__��&���
	�
	�
	�	��h�����rc�$��d�}�|��|S)Nc���|�|��t|��}}||z
||z
}}|D]}|�|���|D]}|�|���dSr)�symmetric_differencer�rSr�r�s       r�symmetric_difference_updatezY_set_decorators.<locals>.symmetric_difference_update.<locals>.symmetric_difference_update�s~���2�2�5�9�9�3�t�9�9�$�D���+�t�d�{�C�F��
"�
"�����D�!�!�!�!��
�
����������
�
rr%)r~r�rJs  �rr�z4_set_decorators.<locals>.symmetric_difference_update�s+���	�	�	�	��)�*�*�*�*�*rc�$��d�}�|��|S)Nc��t||��stS|�|��t|��}}||z
||z
}}|D]}|�|���|D]}|�|���|Sr)r�r�r�r�rSr�r�s       r�__ixor__z3_set_decorators.<locals>.__ixor__.<locals>.__ixor__�s���+�D�%�8�8�
&�%�%��2�2�5�9�9�3�t�9�9�$�D���+�t�d�{�C�F��
"�
"�����D�!�!�!�!��
�
�����������Krr%)r~r�rJs  �rr�z!_set_decorators.<locals>.__ixor__�r�rrJr�)r�r�r�rSr6r�r�r�r�r�r�r�r�r�r�rJs               @r�_set_decoratorsr�is����7�7�7��+�m�,�,�K������	�	�	�	�	�	�	�	�	�	�
�
�
�
�
�����������	�	�	�	�	�!�!�!�!�!�	�	�	�	�	�#�#�#�#�#������ +�+�+�+�+������ 	���
�
���A��E�E�'�N�N�N��E�E�-�����Hrc��eZdZdZdS)�InstrumentedListz-An instrumented version of the built-in list.N�r4r5r6r7r%rrr�r��������7�7�7�7rr�c��eZdZdZdS)�InstrumentedSetz,An instrumented version of the built-in set.Nr�r%rrr�r�s������6�6�6�6rr�c��eZdZdZdS)�InstrumentedDictz-An instrumented version of the built-in dict.Nr�r%rrr�r�r�rr�rVrSr�)rzr�r�r�r�r��
itervaluesc��eZdZdZd�Zejejdd�����Zej	ejdd�����Z
dS)rba)A basic dictionary-based collection class.

    Extends dict with the minimal bag semantics that collection
    classes require. ``set`` and ``remove`` are implemented in terms
    of a keying function: any callable that takes an object and
    returns an object for use as a dictionary key.

    c��||_dS)ahCreate a new collection with keying provided by keyfunc.

        keyfunc may be any callable that takes an object and returns an object
        for use as a dictionary key.

        The keyfunc will be called every time the ORM needs to add a member by
        value-only (such as when loading instances from the database) or
        remove a member.  The usual cautions about dictionary keying apply-
        ``keyfunc(object)`` should return the same output for the life of the
        collection.  Keying based on mutable properties can result in
        unreachable instances "lost" in the collection.

        Nrc)rrds  rrzMappedCollection.__init__8s������rNc�^�|�|��}|�|||��dS)z9Add an item by value, consulting the keyfunc for the key.N)rdrb�rr1r�r2s    rr�zMappedCollection.setHs3��
�l�l�5�!�!������e�]�3�3�3�3�3rc	��|�|��}|||kr$tjd|�d||�d|�d����|�||��dS)z<Remove an item by value, consulting the keyfunc for the key.zCan not remove 'z': collection holds 'z' for key 'z�'. Possible cause: is the MappedCollection key function based on mutable properties or properties that only obtain values after flush?N)rdr�InvalidRequestErrorrjr�s    rrSzMappedCollection.removePs{��
�l�l�5�!�!����9�����,�,�*/����S�	�	�	�3�3�3�@���
�	
����m�,�,�,�,�,rr)r4r5r6r7rr
rzr�r�r�rSr%rrrbrb.s������������ ���'�4�4�4�(�'���4����'�
-�
-�
-�(�'���
-�
-�
-rrbr)9r7rlr��sqlalchemy.util.compatr�rrrr�sqlr	�__all__�	threading�Lockr�objectrr9rr
rirrr
rmrr�r�r
rrrrrrr2rCrErGr�r�r��	frozensetr�r�r�r�r�r�r�r'r�r�py3kr+rbr%rr�<module>r�s���`�`�D��������9�9�9�9�9�9������������������������������.�-�-�/�/�� � � � � �� � � �F���������:&�&�&�&�&�"4�&�&�&�R-�-�-�*	5�	5�	5�	5�	5�f�	5�	5�	5�,�,�,�(
-�
-�
-� c�c�c�c�c��c�c�c�L	)�X�(��7�7��=�h<�h<�h<�h<�h<��h<�h<�h<�V%L�%L�%L�%L�P � � �F���&4�4�4�*)�)�)�X4�4�4�0
�
�
�@#�#�#�0;�;�;�|����<�<�<�<�6�6�6�6�a
�a
�a
�H^
�^
�^
�B��#��A�A�A����`
�`
�`
�F8�8�8�8�8�t�8�8�8�7�7�7�7�7�c�7�7�7�8�8�8�8�8�t�8�8�8�
	�
����
���	��(�
�K�K��������x�Z�H�H�����
�
	��y�:�J��!�#3�#3�#5�#5�
6�
6��|�
$�&6�&6�&8�&8�	9�
�� 1-�1-�1-�1-�1-�t�1-�1-�1-�r��"�#�#�#���"�#�#�#���/�"�"�"�"�"r

Hacked By AnonymousFox1.0, Coded By AnonymousFox