o
    ÝîiÌ	  ã                   @   s*   d Z ddlZe e¡ZG dd„ deƒZdS )a»  cdict (ClassDict) is a funny kind of dict that tries to return the values for
the base classes of a key when the entry for the key is not found. It is not a
generalized dictionary that can handle any type of key -- it relies on
spyne.model api to look for classes. It also assumes cdict never changes after
the first lookup.

>>> from spyne.util.cdict import cdict
>>> class A(object):
...     pass
...
>>> class B(A):
...     pass
...
>>> class C(object):
...     pass
...
>>> class D:
...     pass
...
>>> d=cdict({A: "fun", object: "base"})
>>> print d[A]
fun
>>> print d
{<class '__main__.A'>: 'fun', <type 'object'>: 'base'}
>>> print d[B]
fun
>>> print d
{<class '__main__.A'>: 'fun', <class '__main__.B'>: 'fun', <type 'object'>: 'base'}
>>> print d[C]
base
>>> print d
{<class '__main__.A'>: 'fun', <class '__main__.B'>: 'fun', <class '__main__.C'>: 'base', <type 'object'>: 'base'}
>>> print d[D]
*** KeyError: <class __main__.D at 0x8d92c0>
>>>
é    Nc                   @   s   e Zd Zdd„ Zddd„ZdS )Úcdictc                 C   s„   zt  | |¡W S  tyA } z.t|dƒs|j}t|jƒD ]}z| | }|| |< |W   W  Y d }~S  ty:   Y qw |‚d }~ww )NÚ	__bases__)ÚdictÚ__getitem__ÚKeyErrorÚhasattrÚ	__class__Úreversedr   )ÚselfÚclsÚeÚbÚretval© r   úP/var/www/html/LicenciasMIG/venv/lib/python3.10/site-packages/spyne/util/cdict.pyr   =   s    
ÿ€ózcdict.__getitem__Nc                 C   s"   z| | W S  t y   | Y S w ©N)r   )r
   ÚkÚdr   r   r   ÚgetP   s
   
ÿz	cdict.getr   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   <   s    r   )Ú__doc__ÚloggingÚ	getLoggerr   Úloggerr   r   r   r   r   r   Ú<module>   s   %
