
    01iS                     \    S r SSKJr  SSKJrJr   " S S\5      rS r\S:X  a  \" 5         gg)	ze
A commandline tool for testing if RDF graphs are isomorpic, i.e. equal
if BNode labels are ignored.
    )combinations)BNodeGraphc                   Z   ^  \ rS rSrSrU 4S jrS rS rSS jrS r	S r
S	 rS
 rSrU =r$ )IsomorphicTestableGraph   z
Ported from:
http://www.w3.org/2001/sw/DataAccess/proto-tests/tools/rdfdiff.py
(Sean B Palmer's RDF Graph Isomorphism Tester)
c                 <   > [         [        U ]
  " S0 UD6  S U l        g )N )superr   __init__hash)selfkargs	__class__s     W/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/tools/graphisomorphism.pyr    IsomorphicTestableGraph.__init__   s    %t5>>	    c                 X    [        [        [        U R                  5       5      5      5      $ )z
This is defined instead of __hash__ to avoid a circular recursion
scenario with the Memory store for rdflib which requires a hash
lookup in order to return a generator of triples
)r   tuplesortedhashtriples)r   s    r   internal_hash%IsomorphicTestableGraph.internal_hash   s"     E&!1!1!34566r   c              #   d   ^ #    T  H%  nU 4S jU 5       n[        [        U5      5      v   M'     g 7f)Nc              3      >#    U  H6  n[        U[        5      =(       a    TR                  U5      =(       d    Uv   M8     g 7fN)
isinstancer   vhash).0tr   s     r   	<genexpr>6IsomorphicTestableGraph.hashtriples.<locals>.<genexpr>    s-     O1*Q&84::a=>Q>s   >A)r   r   )r   triplegs   `  r   r   #IsomorphicTestableGraph.hashtriples   s(     FOOAuQx.  s   -0c                 H    [        [        U R                  X5      5      5      $ r   )r   r   vhashtriples)r   termdones      r   r   IsomorphicTestableGraph.vhash#   s    VD--d9:;;r   c              #   f   #    U  H'  nX;   d  M
  [        U R                  X1U5      5      v   M)     g 7fr   )r   vhashtriple)r   r(   r)   r    s       r   r'   $IsomorphicTestableGraph.vhashtriples&   s,     AyD,,Qd;<< s   	1"1c              #      #    [        S5       HK  n[        X   [        5      (       d  X   v   M"  U(       d  X   U:X  a  Uv   M7  U R                  X   SS9v   MM     g 7f)N   T)r)   )ranger   r   r   )r   r#   r(   r)   ps        r   r,   #IsomorphicTestableGraph.vhashtriple+   sO     qAfi//i&)t+jjj66 s   AAc                     [        U[        5      (       d  g[        U 5      [        U5      :w  a  g[        R	                  [        U 5      [        U5      5      (       a  gU R                  5       UR                  5       :H  $ )zGraph isomorphism testing.FT)r   r   lenlist__eq__r   r   Gs     r   r6   IsomorphicTestableGraph.__eq__4   s]    !455Y#a& [[dT!W--!!#q'888r   c                 .    U R                  U5      (       + $ )z#Negative graph isomorphism testing.)r6   r7   s     r   __ne__IsomorphicTestableGraph.__ne__>   s    ;;q>!!r   )r   )F)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r'   r,   r6   r;   __static_attributes____classcell__)r   s   @r   r   r      s5    7!
<=
79" "r   r   c            	      X   SS K n SSKJn  SnU" US9nUR                  SSSSS	S
9  UR                  SSSS/ SQSS9  UR	                  5       u  pE/ n0 nUR
                  (       aA  [        5       R                  U R
                  UR                  S9nUR                  U5        SXx'   U H9  n	[        5       R                  XR                  S9nUR                  U5        XU'   M;     [        5       n
[        US5       H.  u  pX4U
;  d  M  X4U
;  d  M  X:X  a  M   X{   < SX|   < 35       e   g )Nr   )OptionParserz,usage: %prog [options] file1 file2 ... fileN)usagez-sz--stdin
store_trueFzLoad from STDIN as well)actiondefaulthelpz--formatxmlinputFormat
RDF_FORMAT)rK   trixn3ntrdfazoThe format of the RDF document(s) to compareOne of 'xml','n3','trix', 'nt', or 'rdfa'.  The default is %default)rI   destmetavarchoicesrJ   )formatz(STDIN)   z != )sysoptparserE   
add_option
parse_argsstdinr   parserL   appendsetr   )rW   rE   rF   opoptionsargsgraphsgraph2FNamegraphfncheckedgraph1graph2s                r   mainri   C   sC   %>E	E	"BMM&   MM30  	 mmoOWFK}}')//		'BUBU/Ve&')//;N;N/OeE  eG&vq17*/?w/N# ##& # 2r   __main__N)	rA   	itertoolsr   rdflibr   r   r   ri   r=   r
   r   r   <module>rm      s9   
 # 5"e 5"p*Z zF r   