o
    y¬´\%�  ã                   @   sì   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
l
mZ dd„ Ze d¡Z	 G dd„ de	jƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZe d¡ZG dd„ deƒZG dd„ deƒZdS )zõContain the ``AssociationProxy`` class.

The ``AssociationProxy`` is a Python property object which provides
transparent proxied access to the endpoint of an association object.

See the example ``examples/association/proxied_association.py``.

é    Né   )Úexc)Úinspect)Úorm)Úutil)Úcollections)Ú
interfaces)Úor_c                 K   s   t | |fi |¤ŽS )a¹  Return a Python property implementing a view of a target
    attribute which references an attribute on members of the
    target.

    The returned value is an instance of :class:`.AssociationProxy`.

    Implements a Python property representing a relationship as a collection
    of simpler values, or a scalar value.  The proxied property will mimic
    the collection type of the target (list, dict or set), or, in the case of
    a one to one relationship, a simple scalar value.

    :param target_collection: Name of the attribute we'll proxy to.
      This attribute is typically mapped by
      :func:`~sqlalchemy.orm.relationship` to link to a target collection, but
      can also be a many-to-one or non-scalar relationship.

    :param attr: Attribute on the associated instance or instances we'll
      proxy for.

      For example, given a target collection of [obj1, obj2], a list created
      by this proxy property would look like [getattr(obj1, *attr*),
      getattr(obj2, *attr*)]

      If the relationship is one-to-one or otherwise uselist=False, then
      simply: getattr(obj, *attr*)

    :param creator: optional.

      When new items are added to this proxied collection, new instances of
      the class collected by the target collection will be created.  For list
      and set collections, the target class constructor will be called with
      the 'value' for the new instance.  For dict types, two arguments are
      passed: key and value.

      If you want to construct instances differently, supply a *creator*
      function that takes arguments as above and returns instances.

      For scalar relationships, creator() will be called if the target is None.
      If the target is present, set operations are proxied to setattr() on the
      associated object.

      If you have an associated object with multiple attributes, you may set
      up multiple association proxies mapping to different attributes.  See
      the unit tests for examples, and for examples of how creator() functions
      can be used to construct the scalar relationship on-demand in this
      situation.

    :param \*\*kw: Passes along any other keyword arguments to
      :class:`.AssociationProxy`.

    )ÚAssociationProxy)Útarget_collectionÚattrÚkw© r   úQ/var/www/html/env/lib/python3.10/site-packages/sqlalchemy/ext/associationproxy.pyÚassociation_proxy   s   4r   ÚASSOCIATION_PROXYc                   @   s0  e Zd ZdZdZeZ					d:dd„Zedd„ ƒZ	edd	„ ƒZ
ed
d„ ƒZdd„ Zejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zed(d)„ ƒZejd*d+„ ƒZd;d,d-„Zd;d.d/„Zd;d0d1„Z d2d3„ Z!d4d5„ Z"d6d7„ Z#d8d9„ Z$dS )<r
   zDA descriptor that presents a read/write view of an object attribute.FNc                 C   s\   || _ || _|| _|| _|| _|| _d| _dt| ƒj|t	| ƒf | _
d| _|r,|| _dS dS )a	  Construct a new :class:`.AssociationProxy`.

        The :func:`.association_proxy` function is provided as the usual
        entrypoint here, though :class:`.AssociationProxy` can be instantiated
        and/or subclassed directly.

        :param target_collection: Name of the collection we'll proxy to,
          usually created with :func:`.relationship`.

        :param attr: Attribute on the collected instances we'll proxy
          for.  For example, given a target collection of [obj1, obj2], a
          list created by this proxy property would look like
          [getattr(obj1, attr), getattr(obj2, attr)]

        :param creator: Optional. When new items are added to this proxied
          collection, new instances of the class collected by the target
          collection will be created.  For list and set collections, the
          target class constructor will be called with the 'value' for the
          new instance.  For dict types, two arguments are passed:
          key and value.

          If you want to construct instances differently, supply a 'creator'
          function that takes arguments as above and returns instances.

        :param getset_factory: Optional.  Proxied attribute access is
          automatically handled by routines that get and set values based on
          the `attr` argument for this proxy.

          If you would like to customize this behavior, you may supply a
          `getset_factory` callable that produces a tuple of `getter` and
          `setter` functions.  The factory is called with two arguments, the
          abstract type of the underlying collection and this proxy instance.

        :param proxy_factory: Optional.  The type of collection to emulate is
          determined by sniffing the target collection.  If your collection
          type can't be determined by duck typing or you'd like to use a
          different collection implementation, you may supply a factory
          function to produce those collections.  Only applicable to
          non-scalar relationships.

        :param proxy_bulk_set: Optional, use with proxy_factory.  See
          the _set() method for details.

        :param info: optional, will be assigned to
         :attr:`.AssociationProxy.info` if present.

         .. versionadded:: 1.0.9

        Nz	_%s_%s_%s)r   Ú
value_attrÚcreatorÚgetset_factoryÚproxy_factoryÚproxy_bulk_setÚowning_classÚtypeÚ__name__ÚidÚkeyÚcollection_classÚinfo)Úselfr   r   r   r   r   r   r   r   r   r   Ú__init__c   s    ;ý
ÿzAssociationProxy.__init__c                 C   ó   t | j| jƒS )zðThe 'remote' :class:`.MapperProperty` referenced by this
        :class:`.AssociationProxy`.

        .. versionadded:: 0.7.3

        See also:

        :attr:`.AssociationProxy.attr`

        :attr:`.AssociationProxy.local_attr`

        )ÚgetattrÚtarget_classr   ©r   r   r   r   Úremote_attr¯   ó   zAssociationProxy.remote_attrc                 C   r    )zðThe 'local' :class:`.MapperProperty` referenced by this
        :class:`.AssociationProxy`.

        .. versionadded:: 0.7.3

        See also:

        :attr:`.AssociationProxy.attr`

        :attr:`.AssociationProxy.remote_attr`

        )r!   r   r   r#   r   r   r   Ú
local_attr¿   r%   zAssociationProxy.local_attrc                 C   s   | j | jfS )a€  Return a tuple of ``(local_attr, remote_attr)``.

        This attribute is convenient when specifying a join
        using :meth:`.Query.join` across two relationships::

            sess.query(Parent).join(*Parent.proxied.attr)

        .. versionadded:: 0.7.3

        See also:

        :attr:`.AssociationProxy.local_attr`

        :attr:`.AssociationProxy.remote_attr`

        )r&   r$   r#   r   r   r   r   Ï   s   zAssociationProxy.attrc                 C   s*   | j }|d u rt d¡‚t |¡ | j¡S )NzQThis association proxy has no mapped owning class; can't locate a mapped property)r   r   ÚInvalidRequestErrorr   Úclass_mapperÚget_propertyr   )r   r   r   r   r   Ú_get_propertyã   s   ÿ
ÿzAssociationProxy._get_propertyc                 C   s   |   ¡ jjS )zÄThe intermediary class handled by this :class:`.AssociationProxy`.

        Intercepted append/set/assignment events will result
        in the generation of new instances of this class.

        )r*   ÚmapperÚclass_r#   r   r   r   r"   î   s   zAssociationProxy.target_classc                 C   s   |   ¡ j }|r|  ¡  |S )zkReturn ``True`` if this :class:`.AssociationProxy` proxies a scalar
        relationship on the local side.)r*   ÚuselistÚ_initialize_scalar_accessors)r   Úscalarr   r   r   r/   ø   s   zAssociationProxy.scalarc                 C   s   |   ¡ j | j¡j S ©N)r*   r+   r)   r   r-   r#   r   r   r   Ú_value_is_scalar  s
   
þÿz!AssociationProxy._value_is_scalarc                 C   s   t | j| jƒjjS r0   )r!   r"   r   ÚimplÚuses_objectsr#   r   r   r   Ú_target_is_object
  s   z"AssociationProxy._target_is_objectc                 C   s|   |d ur|d u rt |ƒ}n	|d ur|}nd S zt|ƒ}W n tjy'   Y d S w |jj | ¡}|d ur9|j| _d S || _d S r0   )	r   r   r   ÚNoInspectionAvailabler+   Úclass_managerÚ_locate_owning_managerr,   r   )r   Úobjr,   Ú
target_clsÚinspÚownerr   r   r   Ú_calc_owner  s   
û
zAssociationProxy._calc_ownerc                 C   s¤   | j d u r|  ||¡ |d u r| S | jrt|| jƒ}|  |¡S zt|| jƒ\}}t|ƒ|kr1|W S W n	 ty;   Y nw |  	t
|| jƒ¡}t|| jt|ƒ|fƒ |S r0   )r   r<   r/   r!   r   Ú_scalar_getr   r   ÚAttributeErrorÚ_newÚ_lazy_collectionÚsetattr)r   r8   r,   ÚtargetÚ
creator_idÚproxyr   r   r   Ú__get__+  s$   

ÿÿzAssociationProxy.__get__c                 C   s˜   | j d u r|  |d ¡ | jr4| jr| jp| j}t|| jƒ}|d u r,t|| j||ƒƒ d S |  ||¡ d S |  	|d ¡}||urJ| 
¡  |  ||¡ d S d S r0   )r   r<   r/   r   r"   r!   r   rA   Ú_scalar_setrE   ÚclearÚ_set)r   r8   Úvaluesr   rB   rD   r   r   r   Ú__set__B  s   
þzAssociationProxy.__set__c                 C   s&   | j d u r|  |d ¡ t|| jƒ d S r0   )r   r<   Údelattrr   ©r   r8   r   r   r   Ú
__delete__S  s   
zAssociationProxy.__delete__c                 C   s8   | j r|   d | ¡\}}n|  d ¡\}}||| _| _d S r0   )r   Ú_default_getsetr=   rF   )r   ÚgetÚset_r   r   r   r.   Y  s   z-AssociationProxy._initialize_scalar_accessorsc                    sL   | j ‰t ˆ¡‰ ‡ fdd„}|tu r‡fdd„}||fS ‡fdd„}||fS )Nc                    s   | d urˆ | ƒS d S r0   r   )rB   )Ú_getterr   r   Úgetterd  ó   z0AssociationProxy._default_getset.<locals>.getterc                    s   t | ˆ |ƒ d S r0   ©rA   )ÚoÚkÚv©r   r   r   Úsetteri  ó   z0AssociationProxy._default_getset.<locals>.setterc                    s   t | ˆ |ƒ d S r0   rT   )rU   rW   rX   r   r   rY   n  rZ   )r   ÚoperatorÚ
attrgetterÚdict)r   r   rR   rY   r   )rQ   r   r   rN   `  s   
ýz AssociationProxy._default_getsetc                 C   sÈ   | j r| j p| j}t |ƒ ¡| _| jr|  ||| j| ¡S | jr)|  | j| ¡\}}n|  | j¡\}}| jt	u r>t
||||| ƒS | jtu rKt||||| ƒS | jtu rXt||||| ƒS t d| jj| jf ¡‚)Nz‚could not guess which interface to use for collection_class "%s" backing "%s"; specify a proxy_factory and proxy_bulk_set manually)r   r"   r   Úduck_type_collectionr   r   r   r   rN   ÚlistÚ_AssociationListr]   Ú_AssociationDictÚsetÚ_AssociationSetr   ÚArgumentErrorr   r   )r   Úlazy_collectionr   rR   rY   r   r   r   r?   s  s4   
ÿ

ÿ

ÿ

ÿýÿzAssociationProxy._newc                 C   sR   | j r| j p| j}| jr|  | j| ¡\}}n|  | j¡\}}||_ ||_||_d S r0   )r   r"   r   r   rN   rR   rY   )r   rD   r   rR   rY   r   r   r   Ú_inflate•  s   
zAssociationProxy._inflatec                 C   sh   | j r|   ||¡ d S | jtu r| |¡ d S | jtu r#| |¡ d S | jtu r/| |¡ d S t d¡‚)NzEno proxy_bulk_set supplied for custom collection_class implementation)	r   r   r_   Úextendr]   Úupdaterb   r   rd   )r   rD   rI   r   r   r   rH   ¡  s   


ÿzAssociationProxy._setc                 C   s
   |   ¡ jS r0   )r*   Ú
comparatorr#   r   r   r   Ú_comparator°  ó   
zAssociationProxy._comparatorc                 C   s    t | j| jƒ}t|tƒr|S d S r0   )r!   r"   r   Ú
isinstancer
   )r   r   r   r   r   Ú_unwrap_target_assoc_proxy´  s   
z+AssociationProxy._unwrap_target_assoc_proxyc                 K   s–   |  dd ¡}| j}|d ur|jdd|i|¤Ž}| j |¡S | jr1t| j| jƒ}|j|fi |¤Ž}n|r8t 	d¡‚|rC|d urCt 	d¡‚|}| j |¡S )NÚis_hasÚ	criterionzJCan't apply keyword arguments to column-targeted association proxy; use ==zINon-empty has() not allowed for column-targeted association proxy; use ==r   )
Úpoprm   Ú_criterion_existsrj   r4   r!   r"   r   r   rd   )r   ro   Úkwargsrn   Útarget_assocÚinnerÚpropÚ
value_exprr   r   r   rq   »  s,   ÿÿÿÿz"AssociationProxy._criterion_existsc                 K   s<   | j du r| jr| jr| jrt d¡‚| jd|ddœ|¤ŽS )a!  Produce a proxied 'any' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.RelationshipProperty.Comparator.any`
        and/or :meth:`.RelationshipProperty.Comparator.has`
        operators of the underlying proxied attributes.

        Nz9'any()' not implemented for scalar attributes. Use has().F©ro   rn   r   ©rm   r/   r4   r1   r   r'   rq   ©r   ro   rr   r   r   r   ÚanyØ  ó   
	ÿþþÿÿÿzAssociationProxy.anyc                 K   s<   | j du r| jr| jr| jst d¡‚| jd|ddœ|¤ŽS )a!  Produce a proxied 'has' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.RelationshipProperty.Comparator.any`
        and/or :meth:`.RelationshipProperty.Comparator.has`
        operators of the underlying proxied attributes.

        Nz4'has()' not implemented for collections.  Use any().Trw   r   rx   ry   r   r   r   Úhasì  r{   zAssociationProxy.hasc                 C   s’   | j }|dur| j |js| |¡¡S ||k¡S | jr/| jr/| js/| j t| j	| j
ƒ |¡¡S | jr=| jr=| jr=t d¡‚| jjdi | j
|i¤ŽS )ab  Produce a proxied 'contains' expression using EXISTS.

        This expression will be a composed product
        using the :meth:`.RelationshipProperty.Comparator.any`
        , :meth:`.RelationshipProperty.Comparator.has`,
        and/or :meth:`.RelationshipProperty.Comparator.contains`
        operators of the underlying proxied attributes.
        Nz5contains() doesn't apply to a scalar endpoint; use ==r   )rm   rj   rq   r/   Úcontainsr4   r1   r|   r!   r"   r   r   r'   )r   r8   rs   r   r   r   r}      s,   

ÿÿýÿþýÿÿzAssociationProxy.containsc                 C   sD   |d u rt | jjdi | j|i¤Ž| jd kƒS | jjdi | j|i¤ŽS )Nr   )r	   rj   r|   r   rL   r   r   r   Ú__eq__!  s   þzAssociationProxy.__eq__c                 C   s   | j  t| j| jƒ|k¡S r0   )rj   r|   r!   r"   r   rL   r   r   r   Ú__ne__,  s   ÿzAssociationProxy.__ne__c                 C   s   d| j | jf S )NzAssociationProxy(%r, %r))r   r   r#   r   r   r   Ú__repr__3  s   þzAssociationProxy.__repr__)NNNNNr0   )%r   Ú
__module__Ú__qualname__Ú__doc__Úis_attributer   Úextension_typer   Úpropertyr$   r&   r   r*   r   Úmemoized_propertyr"   r/   r1   r4   r<   rE   rJ   rM   r.   rN   r?   rf   rH   rj   rm   rq   rz   r|   r}   r~   r   r€   r   r   r   r   r
   ]   sZ    
øL



	
	

"




!r
   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
r@   c                 C   s   t  |¡| _|| _d S r0   ©ÚweakrefÚrefrB   )r   r8   rB   r   r   r   r   ;  s   
z_lazy_collection.__init__c                 C   s&   |   ¡ }|d u rt d¡‚t|| jƒS )Nz<stale association proxy, parent object has gone out of scope)rŠ   r   r'   r!   rB   rL   r   r   r   Ú__call__?  s   ÿz_lazy_collection.__call__c                 C   s   |   ¡ | jdœS )N)r8   rB   )rŠ   rB   r#   r   r   r   Ú__getstate__H  rZ   z_lazy_collection.__getstate__c                 C   s   t  |d ¡| _|d | _d S )Nr8   rB   rˆ   ©r   Ústater   r   r   Ú__setstate__K  s   z_lazy_collection.__setstate__N)r   r�   r‚   r   r‹   rŒ   r�   r   r   r   r   r@   :  s
    	r@   c                   @   sD   e Zd Zdd„ Zedd„ ƒZdd„ Zdd„ ZeZd	d
„ Z	dd„ Z
dS )Ú_AssociationCollectionc                 C   s"   || _ || _|| _|| _|| _dS )aú  Constructs an _AssociationCollection.

        This will always be a subclass of either _AssociationList,
        _AssociationSet, or _AssociationDict.

        lazy_collection
          A callable returning a list-based collection of entities (usually an
          object attribute managed by a SQLAlchemy relationship())

        creator
          A function that creates new target entities.  Given one parameter:
          value.  This assertion is assumed::

            obj = creator(somevalue)
            assert getter(obj) == somevalue

        getter
          A function.  Given an associated object, return the 'value'.

        setter
          A function.  Given an associated object and a value, store that
          value on the object.

        N)re   r   rR   rY   Úparent)r   re   r   rR   rY   r‘   r   r   r   r   Q  s
   
z_AssociationCollection.__init__c                 C   s   |   ¡ S r0   )re   r#   r   r   r   Ú<lambda>p  ó    z_AssociationCollection.<lambda>c                 C   ó
   t | jƒS r0   ©ÚlenÚcolr#   r   r   r   Ú__len__r  ó   
z_AssociationCollection.__len__c                 C   r”   r0   )Úboolr—   r#   r   r   r   Ú__bool__u  r™   z_AssociationCollection.__bool__c                 C   s   | j | jdœS )N©r‘   re   rœ   r#   r   r   r   rŒ   z  ó   z#_AssociationCollection.__getstate__c                 C   s$   |d | _ |d | _| j  | ¡ d S )Nr‘   re   )r‘   re   rf   r�   r   r   r   r�   }  s   

z#_AssociationCollection.__setstate__N)r   r�   r‚   r   r†   r—   r˜   r›   Ú__nonzero__rŒ   r�   r   r   r   r   r�   P  s    r�   c                   @   s„  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdLd!d"„Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!e!Z"d?d@„ Z#dAdB„ Z$dCdD„ Z%dEdF„ Z&dGdH„ Z'dIdJ„ Z(e)e*ƒ  +¡ ƒD ]\Z,Z-e. /e-¡r½e-j e,kr½e-js½e0e)e,ƒr½e1e)e,ƒje-_q [,[-dKS )Mr`   z(Generic, converting, list-to-list proxy.c                 C   ó
   |   |¡S r0   ©r   ©r   Úvaluer   r   r   Ú_create†  r™   z_AssociationList._createc                 C   rŸ   r0   ©rR   ©r   Úobject_r   r   r   Ú_get‰  r™   z_AssociationList._getc                 C   ó   |   ||¡S r0   ©rY   )r   r¦   r¢   r   r   r   rH   Œ  ó   z_AssociationList._setc                    s2   t |tƒsˆ  ˆ j| ¡S ‡ fdd„ˆ j| D ƒS )Nc                    ó   g | ]}ˆ   |¡‘qS r   ©r§   ©Ú.0Úmemberr#   r   r   Ú
<listcomp>“  ó    z0_AssociationList.__getitem__.<locals>.<listcomp>)rl   Úslicer§   r—   ©r   Úindexr   r#   r   Ú__getitem__�  s   
z_AssociationList.__getitem__c           	      C   s  t |tƒs|  | j| |¡ d S |jd u rt| ƒ}n|jdk r't| ƒ|j }n|j}|jp.d}|jp3d}tt	|jp:d||ƒƒ}|dkr^|D ]}| |= qE|}|D ]}|  
||¡ |d7 }qOd S t|ƒt|ƒkrrtdt|ƒt|ƒf ƒ‚t||ƒD ]\}}|  | j| |¡ qwd S )Nr   é   zBattempt to assign sequence of size %s to extended slice of size %s)rl   r²   rH   r—   Ústopr–   ÚstepÚstartr_   ÚrangeÚinsertÚ
ValueErrorÚzip)	r   r´   r¢   r·   r¸   r¹   ÚrngÚiÚitemr   r   r   Ú__setitem__•  s6   






þÿÿÿz_AssociationList.__setitem__c                 C   ó   | j |= d S r0   ©r—   r³   r   r   r   Ú__delitem__³  rª   z_AssociationList.__delitem__c                 C   ó$   | j D ]}|  |¡|kr dS qdS ©NTF©r—   r§   ©r   r¢   r¯   r   r   r   Ú__contains__¶  ó
   
ÿz_AssociationList.__contains__c                    s   ‡ fdd„ˆ j ||… D ƒS )Nc                    r«   r   r¬   r­   r#   r   r   r°   ¾  r±   z1_AssociationList.__getslice__.<locals>.<listcomp>rÃ   ©r   r¹   Úendr   r#   r   Ú__getslice__½  s   z_AssociationList.__getslice__c                    s$   ‡ fdd„|D ƒ}|ˆ j ||…< d S )Nc                    r«   r   )r£   )r®   rW   r#   r   r   r°   Á  r±   z1_AssociationList.__setslice__.<locals>.<listcomp>rÃ   )r   r¹   rÌ   rI   Úmembersr   r#   r   Ú__setslice__À  s   z_AssociationList.__setslice__c                 C   s   | j ||…= d S r0   rÃ   rË   r   r   r   Ú__delslice__Ä  rZ   z_AssociationList.__delslice__c                 c   ó   � | j D ]}|  |¡V  qdS )zÇIterate over proxied values.

        For the actual domain objects, iterate over .col instead or
        just use the underlying collection directly from its property
        on the parent.
        NrÇ   ©r   r¯   r   r   r   Ú__iter__Ç  s   €
z_AssociationList.__iter__c                 C   s   | j }|  |¡}| |¡ d S r0   )r—   r£   Úappend)r   r¢   r—   rÀ   r   r   r   rÔ   Ó  s   
z_AssociationList.appendc                    s&   t dd„ t ‡ fdd„t| ƒ¡D ƒƒS )Nc                 S   s   g | ]}d ‘qS )r¶   r   )r®   Ú_r   r   r   r°   Ú  s    ÿÿz*_AssociationList.count.<locals>.<listcomp>c                    s   | ˆ kS r0   r   )rW   ©r¢   r   r   r’   Ý  r“   z(_AssociationList.count.<locals>.<lambda>)Úsumr   Úitertools_filterÚiterr¡   r   rÖ   r   ÚcountØ  s   ÿþÿz_AssociationList.countc                 C   ó   |D ]}|   |¡ qd S r0   )rÔ   )r   rI   rW   r   r   r   rg   â  ó   ÿz_AssociationList.extendc                 C   s   |   |¡g| j||…< d S r0   )r£   r—   )r   r´   r¢   r   r   r   r»   æ  s   z_AssociationList.insertéÿÿÿÿc                 C   s   |   | j |¡¡S r0   )rR   r—   rp   r³   r   r   r   rp   é  ó   z_AssociationList.popc                 C   s0   t | ƒD ]\}}||kr| j|=  d S qtdƒ‚)Nzvalue not in list)Ú	enumerater—   r¼   )r   r¢   r¿   Úvalr   r   r   Úremoveì  s   þz_AssociationList.removec                 C   ó   t ‚)z#Not supported, use reversed(mylist)©ÚNotImplementedErrorr#   r   r   r   Úreverseó  ó   z_AssociationList.reversec                 C   râ   )z!Not supported, use sorted(mylist)rã   r#   r   r   r   Úsortø  ræ   z_AssociationList.sortc                 C   s   | j dt| j ƒ…= d S )Nr   )r—   r–   r#   r   r   r   rG   ý  ó   z_AssociationList.clearc                 C   ó   t | ƒ|kS r0   ©r_   ©r   Úotherr   r   r   r~      rª   z_AssociationList.__eq__c                 C   ó   t | ƒ|kS r0   rê   rë   r   r   r   r     rª   z_AssociationList.__ne__c                 C   ó   t | ƒ|k S r0   rê   rë   r   r   r   Ú__lt__  rª   z_AssociationList.__lt__c                 C   ó   t | ƒ|kS r0   rê   rë   r   r   r   Ú__le__	  rª   z_AssociationList.__le__c                 C   ó   t | ƒ|kS r0   rê   rë   r   r   r   Ú__gt__  rª   z_AssociationList.__gt__c                 C   ó   t | ƒ|kS r0   rê   rë   r   r   r   Ú__ge__  rª   z_AssociationList.__ge__c                 C   ó   t  t| ƒ|¡S r0   )r   Úcmpr_   rë   r   r   r   Ú__cmp__  rZ   z_AssociationList.__cmp__c                 C   s0   zt |ƒ}W n ty   t Y S w t | ƒ| S r0   ©r_   Ú	TypeErrorÚNotImplemented©r   Úiterablerì   r   r   r   Ú__add__  ó   ÿz_AssociationList.__add__c                 C   s0   zt |ƒ}W n ty   t Y S w |t | ƒ S r0   rù   rü   r   r   r   Ú__radd__  rÿ   z_AssociationList.__radd__c                 C   s   t |tƒstS t| ƒ| S r0   )rl   Úintrû   r_   ©r   Únr   r   r   Ú__mul__#  s   
z_AssociationList.__mul__c                 C   s   |   |¡ | S r0   )rg   )r   rý   r   r   r   Ú__iadd__*  s   
z_AssociationList.__iadd__c                 C   sD   t |tƒstS |dkr|  ¡  | S |dkr |  t| ƒ|d  ¡ | S ©Nr   r¶   )rl   r  rû   rG   rg   r_   r  r   r   r   Ú__imul__.  s   
þz_AssociationList.__imul__c                 G   s   t | ƒj|g|¢R Ž S r0   )r_   r´   )r   rÀ   Úargsr   r   r   r´   ;  rè   z_AssociationList.indexc                 C   ó   t | ƒS r0   rê   r#   r   r   r   Úcopy>  ó   z_AssociationList.copyc                 C   ó   t t| ƒƒS r0   )Úreprr_   r#   r   r   r   r€   A  rª   z_AssociationList.__repr__c                 C   ó   t dt| ƒj ƒ‚©Nz%s objects are unhashable©rú   r   r   r#   r   r   r   Ú__hash__D  rÞ   z_AssociationList.__hash__N)rÝ   )2r   r�   r‚   rƒ   r£   r§   rH   rµ   rÁ   rÄ   rÉ   rÍ   rÏ   rÐ   rÓ   rÔ   rÚ   rg   r»   rp   rá   rå   rç   rG   r~   r   rï   rñ   ró   rõ   rø   rþ   r   r  Ú__rmul__r  r  r´   r
  r€   r  r_   ÚlocalsÚitemsÚ	func_nameÚfuncr   ÚcallableÚhasattrr!   r   r   r   r   r`   ƒ  sd    

ÿ
ÿþ€r`   Ú_NotProvidedc                   @   sv  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ ZdCd'd(„ZdCd)d*„Zd+d,„ Zejrtd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Znd7d6„ Zd8d4„ Ze fd9d:„Z!d;d<„ Z"d=d>„ Z#d?d@„ Z$dAdB„ Z%e&e'ƒ  ¡ ƒD ]\Z(Z)e *e)¡r¶e)j e(kr¶e)js¶e+e,e(ƒr¶e-e,e(ƒje)_q™[([)d&S )Dra   z(Generic, converting, dict-to-dict proxy.c                 C   r¨   r0   r    ©r   r   r¢   r   r   r   r£   X  rª   z_AssociationDict._createc                 C   rŸ   r0   r¤   r¥   r   r   r   r§   [  r™   z_AssociationDict._getc                 C   s   |   |||¡S r0   r©   )r   r¦   r   r¢   r   r   r   rH   ^  r�   z_AssociationDict._setc                 C   s   |   | j| ¡S r0   ©r§   r—   ©r   r   r   r   r   rµ   a  rZ   z_AssociationDict.__getitem__c                 C   s8   || j v r|  | j | ||¡ d S |  ||¡| j |< d S r0   )r—   rH   r£   r  r   r   r   rÁ   d  s   
z_AssociationDict.__setitem__c                 C   rÂ   r0   rÃ   r  r   r   r   rÄ   j  rª   z_AssociationDict.__delitem__c                 C   ó
   || j v S r0   rÃ   r  r   r   r   rÉ   m  rk   z_AssociationDict.__contains__c                 C   r  r0   rÃ   r  r   r   r   Úhas_keyq  rk   z_AssociationDict.has_keyc                 C   s   t | j ¡ ƒS r0   )rÙ   r—   Úkeysr#   r   r   r   rÓ   u  r�   z_AssociationDict.__iter__c                 C   ó   | j  ¡  d S r0   ©r—   rG   r#   r   r   r   rG   x  r�   z_AssociationDict.clearc                 C   ré   r0   ©r]   rë   r   r   r   r~   {  rª   z_AssociationDict.__eq__c                 C   rí   r0   r"  rë   r   r   r   r   ~  rª   z_AssociationDict.__ne__c                 C   rî   r0   r"  rë   r   r   r   rï   �  rª   z_AssociationDict.__lt__c                 C   rð   r0   r"  rë   r   r   r   rñ   „  rª   z_AssociationDict.__le__c                 C   rò   r0   r"  rë   r   r   r   ró   ‡  rª   z_AssociationDict.__gt__c                 C   rô   r0   r"  rë   r   r   r   rõ   Š  rª   z_AssociationDict.__ge__c                 C   rö   r0   )r   r÷   r]   rë   r   r   r   rø   �  rZ   z_AssociationDict.__cmp__c                 C   s   t t|  ¡ ƒƒS r0   )r  r]   r  r#   r   r   r   r€   �  rZ   z_AssociationDict.__repr__Nc                 C   s"   z| | W S  t y   | Y S w r0   )ÚKeyError©r   r   Údefaultr   r   r   rO   “  s
   
ÿz_AssociationDict.getc                 C   s(   || j vr|  ||¡| j |< |S | | S r0   )r—   r£   r$  r   r   r   Ú
setdefault™  s   
z_AssociationDict.setdefaultc                 C   ó
   | j  ¡ S r0   )r—   r  r#   r   r   r   r     r™   z_AssociationDict.keysc                    ó   ‡ fdd„ˆ j D ƒS )Nc                 3   ó$   � | ]}|ˆ   ˆ j| ¡fV  qd S r0   r  ©r®   r   r#   r   r   Ú	<genexpr>¦  ó   €" z-_AssociationDict.iteritems.<locals>.<genexpr>rÃ   r#   r   r#   r   Ú	iteritems¥  rS   z_AssociationDict.iteritemsc                    r(  )Nc                 3   ó    � | ]}ˆ   ˆ j| ¡V  qd S r0   r  r*  r#   r   r   r+  ©  ó   € z._AssociationDict.itervalues.<locals>.<genexpr>rÃ   r#   r   r#   r   Ú
itervalues¨  rS   z_AssociationDict.itervaluesc                 C   r'  r0   )r—   Úiterkeysr#   r   r   r   r1  «  r™   z_AssociationDict.iterkeysc                    s   ‡ fdd„ˆ j  ¡ D ƒS )Nc                    r«   r   r¬   r­   r#   r   r   r°   ¯  r±   z+_AssociationDict.values.<locals>.<listcomp>)r—   rI   r#   r   r#   r   rI   ®  s   z_AssociationDict.valuesc                    s   ‡ fdd„ˆ D ƒS )Nc                    s    g | ]}|ˆ   ˆ j| ¡f‘qS r   r  )r®   rV   r#   r   r   r°   ²  s     z*_AssociationDict.items.<locals>.<listcomp>r   r#   r   r#   r   r  ±  rÞ   z_AssociationDict.itemsc                    r(  )Nc                 3   r)  r0   r  r*  r#   r   r   r+  ·  r,  z)_AssociationDict.items.<locals>.<genexpr>rÃ   r#   r   r#   r   r  ¶  rS   c                    r(  )Nc                 3   r.  r0   r  r*  r#   r   r   r+  º  r/  z*_AssociationDict.values.<locals>.<genexpr>rÃ   r#   r   r#   r   rI   ¹  rS   c                 C   s.   |t u r| j |¡}n| j ||¡}|  |¡S r0   )r  r—   rp   r§   )r   r   r%  r¯   r   r   r   rp   ¼  s   
z_AssociationDict.popc                 C   s    | j  ¡ }|d |  |d ¡fS r  )r—   Úpopitemr§   )r   rÀ   r   r   r   r2  Ã  s   
z_AssociationDict.popitemc           	      O   sž   t |ƒdkrtdt |ƒ ƒ‚t |ƒdkrB|d }t|dƒr)|D ]}|| | |< qnz|D ]\}}|| |< q,W n tyA   tdƒ‚w |D ]\}}|| |< qDd S )Nr¶   z+update expected at most 1 arguments, got %ir   r  z4dictionary update sequence requires 2-element tuples)r–   rú   r  r¼   )	r   Úar   Ú
seq_or_maprÀ   rV   rW   r   r¢   r   r   r   rh   Ç  s,   
ÿ
ÿ
ÿÿÿ
ÿz_AssociationDict.updatec                 C   s   t |  ¡ ƒS r0   )r]   r  r#   r   r   r   r
  á  rª   z_AssociationDict.copyc                 C   r  r  r  r#   r   r   r   r  ä  rÞ   z_AssociationDict.__hash__r0   ).r   r�   r‚   rƒ   r£   r§   rH   rµ   rÁ   rÄ   rÉ   r  rÓ   rG   r~   r   rï   rñ   ró   rõ   rø   r€   rO   r&  r  r   Úpy2kr-  r0  r1  rI   r  r  rp   r2  rh   r
  r  r_   r  r  r  r  r  r]   r!   r   r   r   r   ra   U  s^    


ÿ
ÿþ€ra   c                   @   sŠ  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ ZeZd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZeZdd„ ZeZd d!„ Zd"d#„ Zd$d%„ ZeZd&d'„ Zd(d)„ Zd*d+„ ZeZd,d-„ Zd.d/„ Zd0d1„ Z d2d3„ Z!d4d5„ Z"d6d7„ Z#d8d9„ Z$d:d;„ Z%d<d=„ Z&d>d?„ Z'd@dA„ Z(dBdC„ Z)dDdE„ Z*dFdG„ Z+e,e-ƒ  .¡ ƒD ]\Z/Z0e1 2e0¡rÀe0j e/krÀe0jsÀe3e4e/ƒrÀe5e4e/ƒje0_q£[/[0dHS )Irc   z&Generic, converting, set-to-set proxy.c                 C   rŸ   r0   r    r¡   r   r   r   r£   õ  r™   z_AssociationSet._createc                 C   rŸ   r0   r¤   r¥   r   r   r   r§   ø  r™   z_AssociationSet._getc                 C   r”   r0   r•   r#   r   r   r   r˜   û  r™   z_AssociationSet.__len__c                 C   s   | j rdS dS rÆ   rÃ   r#   r   r   r   r›   þ  s   z_AssociationSet.__bool__c                 C   rÅ   rÆ   rÇ   rÈ   r   r   r   rÉ     rÊ   z_AssociationSet.__contains__c                 c   rÑ   )zÀIterate over proxied values.

        For the actual domain objects, iterate over .col instead or just use
        the underlying collection directly from its property on the parent.

        NrÇ   rÒ   r   r   r   rÓ     s   €
z_AssociationSet.__iter__c                 C   s"   || vr| j  |  |¡¡ d S d S r0   )r—   Úaddr£   r¡   r   r   r   r6    s   ÿz_AssociationSet.addc                 C   s0   | j D ]}|  |¡|kr| j  |¡  d S qd S r0   )r—   r§   ÚdiscardrÈ   r   r   r   r7    s   
þÿz_AssociationSet.discardc                 C   s4   | j D ]}|  |¡|kr| j  |¡  d S qt|ƒ‚r0   )r—   r§   r7  r#  rÈ   r   r   r   rá   $  s   
þz_AssociationSet.removec                 C   s"   | j stdƒ‚| j  ¡ }|  |¡S )Nzpop from an empty set)r—   r#  rp   r§   rÒ   r   r   r   rp   +  s   

z_AssociationSet.popc                 C   rÛ   r0   )r6  ©r   rì   r¢   r   r   r   rh   1  rÜ   z_AssociationSet.updatec                 C   ó(   t  | |¡stS |D ]}|  |¡ q
| S r0   )r   Ú_set_binops_check_strictrû   r6  r8  r   r   r   Ú__ior__5  ó
   z_AssociationSet.__ior__c                 C   r  r0   )rb   rÙ   r#   r   r   r   rH   <  rª   z_AssociationSet._setc                 C   ó   t | ƒ |¡S r0   )rb   Úunionrë   r   r   r   r>  ?  r�   z_AssociationSet.unionc                 C   r=  r0   )rb   Ú
differencerë   r   r   r   r?  D  r�   z_AssociationSet.differencec                 C   rÛ   r0   )r7  r8  r   r   r   Údifference_updateI  rÜ   z!_AssociationSet.difference_updatec                 C   r9  r0   )r   r:  rû   r7  r8  r   r   r   Ú__isub__M  r<  z_AssociationSet.__isub__c                 C   r=  r0   )rb   Úintersectionrë   r   r   r   rB  T  r�   z_AssociationSet.intersectionc                 C   óR   |   |¡t| ƒ}}|| || }}|D ]}|  |¡ q|D ]}|  |¡ qd S r0   )rB  rb   rá   r6  ©r   rì   ÚwantÚhaverá   r6  r¢   r   r   r   Úintersection_updateY  ó   ÿz#_AssociationSet.intersection_updatec                 C   ób   t  | |¡stS |  |¡t| ƒ}}|| || }}|D ]}|  |¡ q|D ]}|  |¡ q'| S r0   )r   r:  rû   rB  rb   rá   r6  rD  r   r   r   Ú__iand__c  ó   z_AssociationSet.__iand__c                 C   r=  r0   )rb   Úsymmetric_differencerë   r   r   r   rL  p  r�   z$_AssociationSet.symmetric_differencec                 C   rC  r0   )rL  rb   rá   r6  rD  r   r   r   Úsymmetric_difference_updateu  rH  z+_AssociationSet.symmetric_difference_updatec                 C   rI  r0   )r   r:  rû   rL  rb   rá   r6  rD  r   r   r   Ú__ixor__  rK  z_AssociationSet.__ixor__c                 C   r=  r0   )rb   Úissubsetrë   r   r   r   rO  Œ  r�   z_AssociationSet.issubsetc                 C   r=  r0   )rb   Ú
issupersetrë   r   r   r   rP  �  r�   z_AssociationSet.issupersetc                 C   r   r0   r!  r#   r   r   r   rG   ’  r�   z_AssociationSet.clearc                 C   r	  r0   ©rb   r#   r   r   r   r
  •  r  z_AssociationSet.copyc                 C   ré   r0   rQ  rë   r   r   r   r~   ˜  rª   z_AssociationSet.__eq__c                 C   rí   r0   rQ  rë   r   r   r   r   ›  rª   z_AssociationSet.__ne__c                 C   rî   r0   rQ  rë   r   r   r   rï   ž  rª   z_AssociationSet.__lt__c                 C   rð   r0   rQ  rë   r   r   r   rñ   ¡  rª   z_AssociationSet.__le__c                 C   rò   r0   rQ  rë   r   r   r   ró   ¤  rª   z_AssociationSet.__gt__c                 C   rô   r0   rQ  rë   r   r   r   rõ   §  rª   z_AssociationSet.__ge__c                 C   r  r0   )r  rb   r#   r   r   r   r€   ª  rª   z_AssociationSet.__repr__c                 C   r  r  r  r#   r   r   r   r  ­  rÞ   z_AssociationSet.__hash__N)6r   r�   r‚   rƒ   r£   r§   r˜   r›   rž   rÉ   rÓ   r6  r7  rá   rp   rh   r;  rH   r>  Ú__or__r?  Ú__sub__r@  rA  rB  Ú__and__rG  rJ  rL  Ú__xor__rM  rN  rO  rP  rG   r
  r~   r   rï   rñ   ró   rõ   r€   r  r_   r  r  r  r  r   r  r  rb   r!   r   r   r   r   rc   ò  sj    

ÿ
ÿþ€rc   )rƒ   r[   r‰   Ú r   r   r   r   r   r   Úsqlr	   r   Úsymbolr   ÚInspectionAttrInfor
   Úobjectr@   r�   r`   r  ra   rc   r   r   r   r   Ú<module>   s2   
7	   `3 
P 