ó
    ô®iZ  ã                   óB   • S r SSKJr  SSKJr  SSKJr   " S S\5      rg)zá
altgraph.ObjectGraph - Graph of objects with an identifier
==========================================================

A graph of objects that have a "graphident" attribute.
graphident is the key for the object in the graph
é    )Ú
GraphError)ÚGraph)Úfilter_stackc                   óœ   • \ rS rSrSrSS jrS rSS jrS rS r	S	 r
S
 rS rS rS rS rS rS rS rS rSS jrS rS rS rS rSrg)ÚObjectGraphé   zj
A graph of objects that have a "graphident" attribute.
graphident is the key for the object in the graph
Nc                 ót   • Uc
  [        5       nX l        Xl        X l        SU l        UR                  U S 5        g ©Nr   )r   Ú
graphidentÚgraphÚdebugÚindentÚadd_node)Úselfr   r   s      ÚAC:\des-py\RoboSAPF\venv\Lib\site-packages\altgraph\ObjectGraph.pyÚ__init__ÚObjectGraph.__init__   s2   € Ø‰=Ü“GˆEØŒØŒ
ØŒ
ØˆŒØ�‰�t˜TÕ"ó    c                 ó6   • S[        U 5      R                  < S3$ )NÚ<Ú>)ÚtypeÚ__name__)r   s    r   Ú__repr__ÚObjectGraph.__repr__   s   � Ü˜d›×,Ô,Ð.Ð.r   c                 ó`   • Uc  U nU R                  U5      nU R                  R                  X!S9$ )z~
Iterate over the subgraph that is entirely reachable by condition
starting from the given start node or the ObjectGraph root
)ÚstartÚ	condition)ÚgetRawIdentr   Úiterdata)r   r   r   s      r   ÚflattenÚObjectGraph.flatten    s6   € ð
 ‰=ØˆEØ× Ñ  Ó'ˆØ�z‰z×"Ñ"¨Ð"ÐDÐDr   c              #   ó¬   #   • U R                    H@  nU R                   R                  U5      nUc  M#  U R                   R                  U5      v •  MB     g 7f©N)r   Ú	node_data)r   ÚidentÚnodes      r   ÚnodesÚObjectGraph.nodes*   sB   é € Ø—Z”ZˆEØ—:‘:×'Ñ'¨Ó.ˆDØÓØ—j‘j×*Ñ*¨5Ó1Ô1ò  ùs
   ‚,A²"Ac                 óž   ^ • Uc  T nT R                  U5      nT R                  R                  U5      u    p4nU 4S jnU" US5      U" US5      4$ )Nc              3   ó¦   >#   • [        5       nU4S jU  5        H2  nX1   nXB;  d  M  TR                  U5      v •  UR                  U5        M4     g 7f)Nc              3   óZ   >#   • U  H   nTR                   R                  U5      v •  M"     g 7fr$   )r   Údescribe_edge)Ú.0Úer   s     €r   Ú	<genexpr>Ú<ObjectGraph.get_edges.<locals>.iter_edges.<locals>.<genexpr>8   s#   øé € ÐAºS¸˜Ÿ
™
×0Ñ0°×3Ð3ºSùs   ƒ(+)ÚsetÚfindNodeÚadd)ÚlstÚnÚseenÚtplr&   r   s        €r   Ú
iter_edgesÚ)ObjectGraph.get_edges.<locals>.iter_edges6   sD   øé € Ü“5ˆDÜA¹SÖA�Ø™�ØÕ$ØŸ-™-¨Ó.Ò.Ø—H‘H˜U–Oò	 Bùs
   ƒ!A¨)Aé   é   )r   r   Údescribe_node)r   r'   r   Ú_ÚoutrawÚincrawr9   s   `      r   Ú	get_edgesÚObjectGraph.get_edges0   sX   ø€ Ø‰<ØˆDØ× Ñ  Ó&ˆØ#Ÿz™z×7Ñ7¸Ó>Ñˆˆ1�fõ	$ñ ˜& !Ó$¡j°¸Ó&;Ð;Ð;r   c                 ó¼   • Uc  U nU R                  U5      nU R                  U5      nU R                  R                  X45      nU R                  R                  U5      $ r$   )r   r   Úedge_by_nodeÚ	edge_data)r   ÚfromNodeÚtoNoder   ÚstopÚedges         r   ÚedgeDataÚObjectGraph.edgeData@   sV   € ØÑØˆHØ× Ñ  Ó*ˆØ×Ñ Ó'ˆØ�z‰z×&Ñ& uÓ3ˆØ�z‰z×#Ñ# DÓ)Ð)r   c                 ó¾   • Uc  U nU R                  U5      nU R                  U5      nU R                  R                  XE5      nU R                  R                  Xc5        g r$   )r   r   rD   Úupdate_edge_data)r   rF   rG   rJ   r   rH   rI   s          r   ÚupdateEdgeDataÚObjectGraph.updateEdgeDataH   sS   € ØÑØˆHØ× Ñ  Ó*ˆØ×Ñ Ó'ˆØ�z‰z×&Ñ& uÓ3ˆØ�
‰
×#Ñ# DÕ3r   c                 ó  • [        U R                  X5      u  p#nU H  u  pVU R                  R                  XVSS9  M!     U H  nU R                  R                  U5        M      [	        U5      S-
  [	        U5      [	        U5      4$ )zÖ
Filter the ObjectGraph in-place by removing all edges to nodes that
do not match every filter in the given filter list

Returns a tuple containing the number of:
    (nodes_visited, nodes_removed, nodes_orphaned)
Úorphan©rE   é   )r   r   Úadd_edgeÚ	hide_nodeÚlen)r   ÚfiltersÚvisitedÚremovesÚorphansÚ	last_goodÚtailr'   s           r   ÚfilterStackÚObjectGraph.filterStackP   sz   € ô %1°·±¸TÓ$KÑ!ˆ˜'ã&‰OˆIØ�J‰J×Ñ 	¸8ÐÓDñ  'ó ˆDØ�J‰J× Ñ  Ö&ñ ô �7‹|˜aÑ¤ W£¬s°7«|Ð;Ð;r   c                 ód   • U R                  U5      nUb  U R                  R                  U5        gg)z3
Remove the given node from the graph if it exists
N)ÚgetIdentr   rU   ©r   r'   r&   s      r   Ú
removeNodeÚObjectGraph.removeNodeb   s/   € ð —‘˜dÓ#ˆØÑØ�J‰J× Ñ  Õ'ð r   c                 óÚ   • Uc  U nU R                  U5      nU R                  U5      nUbA  Ub=   U R                  R                  X45      nUc  gU R                  R                  U5        M<  gg)z*
Remove all edges from fromnode to tonode
N)r`   r   rD   Ú	hide_edge)r   ÚfromnodeÚtonodeÚ	fromidentÚtoidentrI   s         r   ÚremoveReferenceÚObjectGraph.removeReferencej   st   € ð ÑØˆHØ—M‘M (Ó+ˆ	Ø—-‘- Ó'ˆØÑ  WÑ%8ØØ—z‘z×.Ñ.¨yÓB�Ø‘<ØØ—
‘
×$Ñ$ TÔ*ñ	 ð &9Ð r   c                 óp   • U R                  U5      nUb  U$ U R                  U5      nUc  gUR                  $ )z%
Get the graph identifier for a node
N)r   r3   r   ra   s      r   r`   ÚObjectGraph.getIdenty   s?   € ð × Ñ  Ó&ˆØÑØˆLØ�}‰}˜TÓ"ˆØ‰<ØØ�‰Ðr   c                 ó,   • XL a  U$ [        USS5      nU$ )z&
Get the identifier for a node object
r   N)Úgetattrra   s      r   r   ÚObjectGraph.getRawIdent…   s!   € ð Š<ØˆKÜ˜˜l¨DÓ1ˆØˆr   c                 ó(   • U R                  U5      S L$ r$   )r3   ©r   r'   s     r   Ú__contains__ÚObjectGraph.__contains__Ž   s   € Ø�}‰}˜TÓ"¨$Ð.Ð.r   c                 ó†   • U R                  U5      nUc  Un U R                  R                  U5      $ ! [         a     gf = f)z
Find the node on the graph
N)r   r   r%   ÚKeyErrorra   s      r   r3   ÚObjectGraph.findNode‘   sJ   € ð × Ñ  Ó&ˆØ‰=ØˆEð	Ø—:‘:×'Ñ'¨Ó.Ð.øÜó 	Ùð	ús   ˜3 ³
A ¿A c                 óâ   • U R                  SSU5         U R                  R                  UR                  5        g! [         a)    U R                  R                  UR                  U5         gf = f)z0
Add a node to the graph referenced by the root
é   ÚaddNodeN)Úmsgr   Úrestore_noder   r   r   rr   s     r   rz   ÚObjectGraph.addNode�   sV   € ð 	�‰��I˜tÔ$ð	7Ø�J‰J×#Ñ# D§O¡OÕ4øÜó 	7Ø�J‰J×Ñ §¡°Ö6ð	7ús   •%; »0A.Á-A.c                 óº   • Uc  U nU R                  U5      U R                  U5      pTUb  Uc  gU R                  SSXU5        U R                  R                  XEUS9  g)z,
Create a reference from fromnode to tonode
Nry   ÚcreateReferencerR   )r`   r{   r   rT   )r   rf   rg   rE   rh   ri   s         r   r   ÚObjectGraph.createReference¨   s_   € ð ÑØˆHØ!Ÿ]™]¨8Ó4°d·m±mÀFÓ6K�7ØÑ ¡ØØ�‰�Ð% x¸ÔCØ�
‰
×Ñ˜I¸)ÐÒDr   c                 óh   • U R                  U5      nUc  U" U/UQ70 UD6nU R                  U5        U$ )zT
Add a node of type cls to the graph if it does not already exist
by the given name
)r3   rz   )r   ÚclsÚnameÚargsÚkwÚms         r   Ú
createNodeÚObjectGraph.createNode´   s;   € ð
 �M‰M˜$ÓˆØ‰9Ù�DÐ&˜4Ò& 2Ñ&ˆAØ�L‰L˜ŒOØˆr   c                 ó²   • U(       aP  XR                   ::  a@  [        SU R                  -  < U< SSR                  [	        [
        U5      5      < 35        ggg)z,
Print a debug message with the given level
z  Ú N)r   Úprintr   ÚjoinÚmapÚrepr©r   ÚlevelÚsr„   s       r   r{   ÚObjectGraph.msg¿   s>   € ö �Ÿ*™*Ó$Ü˜t d§k¡kÓ1³1°c·h±h¼sÄ4È»Õ6OÐPÕQð %ˆ1r   c                 ór   • XR                   ::  a(  U R                  " X/UQ76   U R                  S-   U l        gg)z"
Print a debug message and indent
rS   N)r   r{   r   r�   s       r   ÚmsginÚObjectGraph.msginÆ   s3   € ð —J‘JÓØ�HŠH�UÐ% Ó%ØŸ+™+¨™/ˆD�Kð r   c                 ór   • XR                   ::  a(  U R                  S-
  U l        U R                  " X/UQ76   gg)z"
Dedent and print a debug message
rS   N)r   r   r{   r�   s       r   ÚmsgoutÚObjectGraph.msgoutÎ   s3   € ð —J‘JÓØŸ+™+¨™/ˆDŒKØ�HŠH�UÐ% Ô%ð r   )r   r   r   r   r
   )NNr$   )r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r!   r(   rA   rJ   rN   r]   rb   rj   r`   r   rs   r3   rz   r   r‡   r{   r”   r—   Ú__static_attributes__© r   r   r   r      sn   † ñô
#ò/ôEò2ò<ò *ò4ò<ò$(ò+ò
òò/ò
ò	7ô
Eò	òRò*õ&r   r   N)	rœ   Úaltgraphr   Úaltgraph.Graphr   Úaltgraph.GraphUtilr   Úobjectr   rž   r   r   Ú<module>r£      s#   ðñõ  Ý  Ý +ôF&�&õ F&r   