Ë
    M<¹es  ã                   óX   — g d ¢Z ddlZddlZddlmZ ddlmZ d
d„Zdd„Z	dd„Z
dd	„ZeZy))ÚparentÚ	referenceÚatÚparentsÚchildrené    Né   )Ú_proxy_helper)Ú_locate_objectc                 óP   — d}t        | |||«      }|j                  «       }|| u ry|S )al  
>>> listiter = iter([4,5,6,7])
>>> obj = parent(listiter, list)
>>> obj == [4,5,6,7]  # actually 'is', but don't have handle any longer
True

NOTE: objtype can be a single type (e.g. int or list) or a tuple of types.

WARNING: if obj is a sequence (e.g. list), may produce unexpected results.
Parent finds *one* parent (e.g. the last member of the sequence).
    r   N)r   Úpop)ÚobjÚobjtypeÚignoreÚdepthÚchainr   s         ú//usr/lib/python3/dist-packages/dill/pointers.pyr   r      s3   € ð €EÜ�C˜ %¨Ó0€EØ�Y‰Y‹[€FØ��}ØØ€Mó    c                 óŽ   ‡— t         j                  }ˆfd„}t        |d«      s|fn|}d„ |D «       }t        | |||«      ddd…   }|S )zúFind the chain of referents for obj. Chain will end with obj.

    objtype: an object type or tuple of types to search for
    depth: search depth (e.g. depth=2 is 'grandparents')
    ignore: an object or tuple of objects to ignore in the search
    c                 ó   •— t        | ‰«      S ©N©Ú
isinstance©Úxr   s    €r   ú<lambda>zparents.<locals>.<lambda>-   ó   ø€ œ* Q¨Ó0€ r   Ú__len__c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr   ©Úid©Ú.0r   s     r   ú	<genexpr>zparents.<locals>.<genexpr>0   ó   è ø€ Ò(˜#Œb��gÑ(ùó   ‚Néÿÿÿÿ)ÚgcÚget_referentsÚhasattrÚ
find_chain©r   r   r   r   Ú	edge_funcÚ	predicater   s    `     r   r   r   %   sO   ø€ ô × Ñ €IÛ0€Iä% f¨iÔ8ˆf‰Y¸f€FÙ( Ô(€FÜ�s˜I y°%Ó8¹¸2¸Ñ>€Eà€Lr   c                 ó„   ‡— t         j                  }ˆfd„}t        |d«      s|fn|}d„ |D «       }t        | ||||«      }|S )a  Find the chain of referrers for obj. Chain will start with obj.

    objtype: an object type or tuple of types to search for
    depth: search depth (e.g. depth=2 is 'grandchildren')
    ignore: an object or tuple of objects to ignore in the search

    NOTE: a common thing to ignore is all globals, 'ignore=(globals(),)'

    NOTE: repeated calls may yield different results, as python stores
    the last value in the special variable '_'; thus, it is often good
    to execute something to replace '_' (e.g. >>> 1+1).
    c                 ó   •— t        | ‰«      S r   r   r   s    €r   r   zchildren.<locals>.<lambda>D   r   r   r   c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr   r   r!   s     r   r#   zchildren.<locals>.<genexpr>G   r$   r%   )r'   Úget_referrersr)   r*   r+   s    `     r   r   r   6   sH   ø€ ô × Ñ €IÛ0€Iä% f¨iÔ8ˆf‰Y¸f€FÙ( Ô(€FÜ�s˜I y°%¸Ó@€Eà€Lr   c                 ó  — | g}t        | «      di}t        | «      d i}t        |«      }|j                  t        |«      «       |j                  t        |«      «       |j                  t        |«      «       |j                  t        |«      «       |j                  t        |«      «       |j                  t        t        j                  «       «      «       |j                  t        t        j                  d«      «      «       t        j                  «        |rå|j                  d«      }	 ||	«      rA|	g}
|t        |	«         �.|t        |	«         }	|
j                  |	«       |t        |	«         �Œ.|
S |t        |	«         }||k  ru ||	«      }|j                  t        |«      «       |D ]N  }t        |«      |v rŒt        |«      |vsŒ|dz   |t        |«      <   |	|t        |«      <   |j                  |«       ŒP |rŒå| gS )Nr   r   )	r    ÚsetÚaddÚsysÚ	_getframer'   Úcollectr   Úappend)r   r-   r,   Ú	max_depthÚextra_ignoreÚqueuer   r   r   Útargetr   ÚtdepthÚ	referrersÚsources                 r   r*   r*   S   s¬  € ØˆE€EÜ�‹W�aˆL€EÜ�‹g�tˆ_€FÜ�Ó€FØ
‡J�JŒr�,ÓÔ Ø
‡J�JŒr�%‹yÔØ
‡J�JŒr�%‹yÔØ
‡J�JŒr�&‹zÔØ
‡J�JŒr�&‹zÔØ
‡J�JŒr”#—-‘-“/Ó"Ô#Ø
‡J�JŒr”#—-‘- Ó"Ó#Ô$Ü‡J�J„LÙ
Ø—‘˜1“ˆÙ�VÔØ�HˆEØœ˜F›Ñ$Ð0Ø¤ 6£
Ñ+�Ø—‘˜VÔ$ð œ˜F›Ñ$Ñ0ð ˆLØ”r˜&“zÑ"ˆØ�IÒÙ! &Ó)ˆIØ�J‰J”r˜)“}Ô%Ø#ò )�Ü�f“: Ñ'ØÜ�f“: UÒ*Ø(.°©
�Eœ"˜V›*Ñ%Ø)/�Fœ2˜f›:Ñ&Ø—L‘L Õ(ð)ò ð& ˆ5€Lr   )© )r   r@   )é   r@   )Ú__all__r'   r5   Ú_dillr	   r   r
   r   r   r   r   r*   Ú	refobjectr@   r   r   ú<module>rE      s4   ðò ?€ã 	Û 
å -Ý 'óó(ó"ó: ðH �	r   