
    01ic                    L   S r SSKJr  SSKJrJrJrJr  SSKJ	r	  SSK
JrJr  SSKJr  SSKJrJr  SSKJrJr  SS	KJr  SS
KJrJrJr  SSKJr    S       SS jjr  S       SS jjr   S           SS jjr " S S\5      r  " S S\5      r! " S S\5      r"g)z`
Code for tying SPARQL Engine into RDFLib

These should be automatically registered with RDFLib
    )annotations)AnyMappingOptionalUnion)Graph)translateQuerytranslateUpdate)	evalQuery)
parseQueryparseUpdate)QueryUpdate)
evalUpdate)	ProcessorResultUpdateProcessor)
IdentifierNc                L    Uc  0 n[        [        U 5      X!5      nXU4Ul        U$ )z$
Parse and translate a SPARQL Query
)r	   r   _original_args)queryStringinitNsbaserets       Y/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/plugins/sparql/processor.pyprepareQueryr      s1     ~
K0$
?C%t4CJ    c                L    Uc  0 n[        [        U 5      X!5      nXU4Ul        U$ )z%
Parse and translate a SPARQL Update
)r
   r   r   )updateStringr   r   r   s       r   prepareUpdater    $   s1     ~
+l3T
BC&5CJr   c                D    [        U [        [        U5      XC5      U5        g)zZ
Process a SPARQL Update Request
returns Nothing on success or raises Exceptions on error
N)r   r
   r   )graphr   initBindingsr   r   s        r   processUpdater$   3   s     {<8$Gr   c                      \ rS rSrSS jrSrg)SPARQLResultC   c                    [         R                  " XS   5        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        UR                  S5      U l        g )Ntype_vars_bindings	askAnswerr"   )r   __init__getvarsr+   r,   r"   )selfress     r   r-   SPARQLResult.__init__D   sR    'l+GGG$	
+-WWW%
r   )r,   r+   r"   r/   N)r1   Mapping[str, Any])__name__
__module____qualname____firstlineno__r-   __static_attributes__ r   r   r&   r&   C   s    &r   r&   c                  :    \ rS rSrS r  S       SS jjrSrg)SPARQLUpdateProcessorM   c                    Xl         g Nr"   r0   r"   s     r   r-   SPARQLUpdateProcessor.__init__N       
r   Nc                ~    [        U[        5      (       a  [        [        U5      US9n[	        U R
                  X5      $ )a  
!!! warning "Caution"

    This method can access indirectly requested network endpoints, for
    example, query processing will attempt to access network endpoints
    specified in `SERVICE` directives.

    When processing untrusted or potentially malicious queries, measures
    should be taken to restrict network and file access.

    For information on available security measures, see the RDFLib
    [Security Considerations](../security_considerations.md)
    documentation.
)r   )
isinstancestrr
   r   r   r"   )r0   
strOrQueryr#   r   s       r   updateSPARQLUpdateProcessor.updateQ   s3    * j#&&(Z)@PJ$**j??r   r?   NN)rF   zUnion[str, Update]r#   "Optional[Mapping[str, Identifier]]r   Optional[Mapping[str, Any]]returnNone)r4   r5   r6   r7   r-   rG   r8   r9   r   r   r;   r;   M   sF     <@.2	@&@ 9@ ,	@
 
@ @r   r;   c                  F    \ rS rSrS r    S           SS jjrSrg)SPARQLProcessorl   c                    Xl         g r>   r?   r@   s     r   r-   SPARQLProcessor.__init__m   rB   r   Nc                    [        U[        5      (       a  [        [        U5      XC5      n[	        U R
                  XU5      $ )a  
Evaluate a query with the given initial bindings, and initial
namespaces. The given base is used to resolve relative URIs in
the query and will be overridden by any BASE given in the query.

!!! warning "Caution"

    This method can access indirectly requested network endpoints, for
    example, query processing will attempt to access network endpoints
    specified in `SERVICE` directives.

    When processing untrusted or potentially malicious queries, measures
    should be taken to restrict network and file access.

    For information on available security measures, see the RDFLib
    [Security Considerations](../security_considerations.md)
    documentation.
)rD   rE   r	   r   r   r"   )r0   rF   r#   r   r   DEBUGs         r   querySPARQLProcessor.queryt   s5    6 j#&&'
:(>MJZtDDr   r?   )NNNF)rF   zUnion[str, Query]r#   rJ   r   rK   r   Optional[str]rT   boolrL   r3   )r4   r5   r6   r7   r-   rU   r8   r9   r   r   rO   rO   l   sb     <@.2"E%E 9E ,	E
 E E 
E Er   rO   rI   )r   rE   r   rK   r   rW   rL   r   )r   rE   r   rK   r   rW   rL   r   )NNN)r"   r   r   rE   r#   rJ   r   rK   r   rW   rL   rM   )#__doc__
__future__r   typingr   r   r   r   rdflib.graphr   rdflib.plugins.sparql.algebrar	   r
   rdflib.plugins.sparql.evaluater   rdflib.plugins.sparql.parserr   r   rdflib.plugins.sparql.sparqlr   r   rdflib.plugins.sparql.updater   rdflib.queryr   r   r   rdflib.termr   r   r    r$   r&   r;   rO   r9   r   r   <module>rd      s   # 0 0  I 4 @ 6 3 ; ; "
 +/'  	" +/'  	$ 8<*. 5 (	
  
 &6 &@O @>&Ei &Er   