
    01iG              	      n   % S r SSKJr  SSKrSSKr SSKJr  SSK	J
r
  SSKJr  SSKJrJrJrJrJr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JrJr  \(       a  SSK J!r!  SSK"J#r#  / SQr$\RJ                  " \&5      r' " S S\(5      r) " S S\(5      r*1 Skr+S\,S'   SS1r-S\,S'    " S S\.5      r/ " S S\/S9r0 " S S\)5      r1\)" S 5      r2\(       a  SS!K3J4r4  S"r5 " S# S$5      r6/ S%Qr7\7S&/-   r8\7/ S'Q-   r9/ S(Qr:S^S) jr;\84     S_S* jjr<      S`S+ jr=SaS, jr>SbS- jr?SS.K@JArA  SS/KBJCrC  SS0KDJErE  SS1KFJGrG  SS2KHJIrI  SS3KJJKrK  SS4KLJMrM  SS5KNJOrO  SS6KPJQrQ  SS7KRJSrS  SS8KTJUrU  SS9KVJWrW  SS:KXJYrY  SS;KZJ[r[  SS<K\J]r]  SS=K^J_r_  SS>K`Jara  SS?KbJcrc  SS@KdJere  SSAKfJgrg  SSBKhJiri  SSCKjJkrk  SSDKlJmrm  SSEKnJoro  SSFKpJqrq  SSGKrJsrs  SSHKtJuru  SSIKvJwrw  \Y\a\c\w\2SJ.rx0 SK\A_SL\C_SM\E_SN\I_SO\K_SP\M_SQ\G_SR\O_SS\Q_ST\S_SU\U_SV\W_SW\[_SX\]_SY\__SZ\e_S[\g_\i\k\m\o\q\s\uS\.Eryg! \ a     SSKJr   GN! \ a
    S]S jr  GNf = ff = f)ca  
# Namespace Utilities

RDFLib provides mechanisms for managing Namespaces.

In particular, there is a [`Namespace`][rdflib.namespace.Namespace] class
that takes as its argument the base URI of the namespace.

```python
>>> from rdflib.namespace import Namespace
>>> RDFS = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")

```

Fully qualified URIs in the namespace can be constructed either by attribute
or by dictionary access on Namespace instances:

```python
>>> RDFS.seeAlso
rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#seeAlso')
>>> RDFS['seeAlso']
rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#seeAlso')

```

## Automatic handling of unknown predicates

As a programming convenience, a namespace binding is automatically
created when [`URIRef`][rdflib.term.URIRef] predicates are added to the graph.

## Importable namespaces

The following namespaces are available by directly importing from rdflib:

* BRICK
* CSVW
* DC
* DCAT
* DCMITYPE
* DCTERMS
* DCAM
* DOAP
* FOAF
* ODRL2
* ORG
* OWL
* PROF
* PROV
* QB
* RDF
* RDFS
* SDO
* SH
* SKOS
* SOSA
* SSN
* TIME
* VANN
* VOID
* WGS
* XSD

```python
>>> from rdflib.namespace import RDFS
>>> RDFS.seeAlso
rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#seeAlso')

```
    )annotationsN)get_annotationsc                    U R                   $ N)__annotations__)things    S/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/namespace/__init__.pyr   r   W   s    (((    )	lru_cache)Path)	TYPE_CHECKINGAnyDictIterableListOptionalSetTupleUnion)category)	urldefragurljoin)URIRefVariable_is_valid_uri)Graph)Store)"	is_ncname	split_uri	NamespaceClosedNamespaceDefinedNamespaceNamespaceManagerBRICKCSVWDCDCAMDCATDCMITYPEDCTERMSDOAPFOAFGEOODRL2ORGOWLPROFPROVQBRDFRDFSSDOSHSKOSSOSASSNTIMEVANNVOIDWGSXSDc                  v   ^  \ rS rSrSrSS jr\SS j5       rSS jrSS jr	SS jr
SU 4S jjrSS	 jrS
rU =r$ )r       a  Utility class for quickly generating URIRefs with a common prefix.

```python
>>> from rdflib.namespace import Namespace
>>> n = Namespace("http://example.org/")
>>> n.Person # as attribute
rdflib.term.URIRef('http://example.org/Person')
>>> n['first-name'] # as item - for things that are not valid python identifiers
rdflib.term.URIRef('http://example.org/first-name')
>>> n.Person in n
True
>>> n2 = Namespace("http://example2.org/")
>>> n.Person in n2
False

```
c                     [         R                  X5      nU$ ! [         a    [         R                  XS5      n U$ f = fNzutf-8)str__new__UnicodeDecodeErrorclsvaluerts      r	   rE   Namespace.__new__   sB    	2S(B 	 " 	2S1B		2s     ==c                    [        U S-   5      $ )Ntitle)r   selfs    r	   rM   Namespace.title   s     dWn%%r
   c                X    [        U [        U[        5      (       a  U-   5      $ S-   5      $ )N )r   
isinstancerD   rO   names     r	   termNamespace.term   s)    djs&;&;dDEEDEEr
   c                $    U R                  U5      $ r   rV   rO   keys     r	   __getitem__Namespace.__getitem__       yy~r
   c                \    UR                  S5      (       a  [        eU R                  U5      $ N__)
startswithAttributeErrorrV   rT   s     r	   __getattr__Namespace.__getattr__   s%    ??4    yyr
   c                (   > S[         TU ]  5        S3$ )N
Namespace()super__repr__rO   	__class__s    r	   rk   Namespace.__repr__   s    EG,./q11r
   c                $    UR                  U 5      $ )ay  Allows to check if a URI is within (starts with) this Namespace.

```python
>>> from rdflib import URIRef
>>> namespace = Namespace('http://example.org/')
>>> uri = URIRef('http://example.org/foo')
>>> uri in namespace
True
>>> person_class = namespace['Person']
>>> person_class in namespace
True
>>> obj = URIRef('http://not.example.org/bar')
>>> obj in namespace
False

```
rb   rO   refs     r	   __contains__Namespace.__contains__   s    $ ~~d##r
    )rI   Union[str, bytes]returnr    rw   r   rU   rD   rw   r   r[   rD   rw   r   rw   rD   rr   rD   rw   bool)__name__
__module____qualname____firstlineno____doc__rE   propertyrM   rV   r\   rd   rk   rs   __static_attributes____classcell__rm   s   @r	   r    r       s@    $ & &F
2$ $r
   r    c                  Z   ^  \ rS rSrSrSS jrS	U 4S jjrS	U 4S jjrS
U 4S jjrSr	U =r
$ )
URIPattern   a,  Utility class for creating URIs according to some pattern.

This supports either new style formatting with .format
or old-style with % operator.

```python
>>> u=URIPattern("http://example.org/%s/%d/resource")
>>> u%('books', 12345)
rdflib.term.URIRef('http://example.org/books/12345/resource')

```
c                     [         R                  X5      nU$ ! [         a<    [        (       a  [	        U[
        5      (       d   e[         R                  XS5      n U$ f = frC   )rD   rE   rF   r   rS   bytesrG   s      r	   rE   URIPattern.__new__   sZ    	2S(B
 		 " 	2}!%////S1B			2s    AAAc                6   > [        [        TU ]  " U0 UD65      $ r   )r   rj   __mod__rO   argskwargsrm   s      r	   r   URIPattern.__mod__   s    egot6v677r
   c                6   > [        [        TU ]  " U0 UD65      $ r   )r   rj   formatr   s      r	   r   URIPattern.format   s    egnd5f566r
   c                (   > S[         TU ]  5        S3$ )NzURIPattern(rh   ri   rl   s    r	   rk   URIPattern.__repr__   s    UW-/022r
   ru   )rI   rv   rw   r   rx   r{   )r~   r   r   r   r   rE   r   r   rk   r   r   r   s   @r	   r   r      s!    873 3r
   r   >   _NS_fail_warn_extras	__slots___underscore_numzSet[str]_DFNS_RESERVED_ATTRS_pytestfixturefunction_partialmethod_IGNORED_ATTR_LOOKUPc                     ^  \ rS rSr% Sr\" 5       rS\S'   S\S'   SrS\S	'   S
r	S\S'   / r
S\S'   S
rS\S'   \" SS9SSS jj5       rSU 4S jjrSS jrSS jrSS jrSS jrS S jrS!S jrSrU =r$ )"DefinedNamespaceMetai
  z>Utility metaclass for generating URIRefs with a common prefix.Tuple[str, ...]r   r    r   Tr}   r   Fr   	List[str]r   r   N)maxsizec                   [        U5      nU[        ;   a  [        SU< 35      eU[        ;   a
  [        5       eU R                  (       d  U R
                  (       aW  X;  aR  U R
                  (       a  [        SU SU R                   S35      e[        R                  " SU SU R                   3SS9  U R                  U   $ )	Nz6DefinedNamespace like object has no access item named term '' not in namespace ''zCode: z is not defined in namespace    )
stacklevel)rD   r   KeyErrorr   r   r   rc   r   warningswarnr~   )rH   rU   defaults      r	   r\    DefinedNamespaceMeta.__getitem__  s    4y''HQ  ))*IIyy$vdV3GyPQ%RSSTF"?~N  wwt}r
   c                   > U[         ;   a
  [        5       eU[        ;   a  [        SU< 35      eUR                  S5      (       a  [        [
        U ]  U5      $ U R                  U5      $ )Nz.DefinedNamespace like object has no attribute ra   )r   rc   r   rb   rj   r   __getattribute__r\   )rH   rU   rm   s     r	   rd    DefinedNamespaceMeta.__getattr__)  sh    '' "")) @I  __T""-sDTJJt$$r
   c                ^     [        U R                  5      nSU S3$ ! [         a    Sn Nf = f)N<DefinedNamespace>rg   rh   )reprr   rc   )rH   ns_reprs     r	   rk   DefinedNamespaceMeta.__repr__4  s;    	+377mG G9A&&  	+*G	+s    ,,c                N     [        U R                  5      $ ! [         a     gf = f)Nr   )rD   r   rc   )rH   s    r	   __str__DefinedNamespaceMeta.__str__;  s'    	(sww< 	('	(s    
$$c                $    U R                  U5      $ r   )r\   )rH   others     r	   __add__DefinedNamespaceMeta.__add__A  s    u%%r
   c                
  ^ ^  T R                   n[        U5      mTR                  [        U5      5      (       a  T[	        [        U5      5      S m[        U U4S jT R                  5        5       5      $ ! [         a     gf = f)zGDetermine whether a URI or an individual item belongs to this namespaceFNc              3    >#    U  H|  n[        U[        5      (       d  M  T[        U5      ;   =(       dK    TUR                  ;   =(       d5    TR                  =(       a"    TS    S:H  =(       a    TSS R                  5       v   M~     g7f)r   _   N)
issubclassr"   r   r   r   isdigit).0crH   item_strs     r	   	<genexpr>4DefinedNamespaceMeta.__contains__.<locals>.<genexpr>M  s}      
 !-.	WH** W199$W##Us(:Ux|?S?S?UW s   BA'B)r   rc   rD   rb   lenanymro)rH   itemthis_nsr   s   `  @r	   rs   !DefinedNamespaceMeta.__contains__D  s}    	ggG t9s7|,,CL 1 34H 
 WWY	
 
 	
  		s   A5 5
BBc                    [        U 5       Vs1 s H  n[        U5      iM     nnUR                  [        5        U Vs1 s H  o[        U5         iM     nnU$ s  snf s  snf r   )r   rD   difference_updater   )rH   xattrsvaluess       r	   __dir__DefinedNamespaceMeta.__dir__U  sY    !0!56!5AQ!56 45',-u!c!f+u-	 7 .s
   AAc                    U[        U R                  5      0n[        U 5      R                  5        H%  u  p4[	        U[
        5      (       d  M  U SU 3X#'   M'     SU0$ )z;Returns this DefinedNamespace as a JSON-LD 'context' object:z@context)rD   r   r   itemsr   r   )rO   pfxtermsr[   rV   s        r	   as_jsonld_context&DefinedNamespaceMeta.as_jsonld_context\  sY    c$((m$(.446IC$'' #uAcU^
 7 E""r
   ru   r   ry   )rU   rD   r{   )r   rD   rw   r   )r   rD   rw   r}   )rw   zIterable[str])r   rD   rw   dict)r~   r   r   r   r   tupler   r   r   r   r   r   r   r\   rd   rk   r   r   rs   r   r   r   r   r   s   @r	   r   r   
  s~    H!&I(	NE4E4GY!OT!t &	%'(&
"# #r
   r   c                  8    \ rS rSr% Sr\" 5       rS\S'   S rSr	g)r"   if  zzA Namespace with an enumerated list of members.

Warnings are emitted if unknown members are referenced if _warn is True.
r   r   c                    [        S5      e)Nz!namespace may not be instantiated)	TypeErrorrN   s    r	   __init__DefinedNamespace.__init__n  s    ;<<r
   ru   N)
r~   r   r   r   r   r   r   r   r   r   ru   r
   r	   r"   r"   f  s    
 "'I(=r
   r"   )	metaclassc                     ^  \ rS rSr% SrS\S'   SU 4S jjr\SS j5       rSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSrU =r$ )r!   ir  zZ
A namespace with a closed list of members

Trying to create terms not listed is an error
zDict[str, URIRef]_ClosedNamespace__urisc                v   > [         TU ]  X5      nU Vs0 s H  oD[        X4-   5      _M     snUl        U$ s  snf r   )rj   rE   r   r   )rH   urir   rJ   trm   s        r	   rE   ClosedNamespace.__new__{  s:    W_S&0561rv&6		 7s   6c                    [        U 5      $ r   )rD   rN   s    r	   r   ClosedNamespace.uri  s    4yr
   c                f    U R                   R                  U5      nUc  [        SU SU  S35      eU$ )Nr   r   r   )r   getr   )rO   rU   r   s      r	   rV   ClosedNamespace.term  s9    kkood#;VD6)=dV1EFF
r
   c                $    U R                  U5      $ r   rY   rZ   s     r	   r\   ClosedNamespace.__getitem__  r^   r
   c                    UR                  S5      (       a  [        e U R                  U5      $ ! [         a  n[        U5      eS nAff = fr`   )rb   rc   rV   r   )rO   rU   es      r	   rd   ClosedNamespace.__getattr__  sE    ??4    (yy& ($Q''(s   / 
A	AA	c                h    U R                    SU R                  R                   S[        U 5      < S3$ )N.(rh   )r   rm   r~   rD   rN   s    r	   rk   ClosedNamespace.__repr__  s/    //"!DNN$;$;#<Ac$i]!LLr
   c                ,    [        U R                  5      $ r   )listr   rN   s    r	   r   ClosedNamespace.__dir__  s    DKK  r
   c                :    XR                   R                  5       ;   $ r   )r   r   rq   s     r	   rs   ClosedNamespace.__contains__  s    ;;%%''	
r
   c                    [        U 5      $ r   )dirrN   s    r	   _ipython_key_completions_)ClosedNamespace._ipython_key_completions_  s    4yr
   ru   )r   rD   r   r   r{   ry   rz   )rw   r   r|   )r~   r   r   r   r   r   rE   r   r   rV   r\   rd   rk   r   rs   r  r   r   r   s   @r	   r!   r!   r  sR     
  (M!

 r
   r!   z$http://www.w3.org/XML/1998/namespace)_NamespaceSetStringTc                      \ rS rSrSrSSS jjrSS jrSS jr\SS j5       r	SS jr
SSS jjrSS	 jrSS
 jrSSS jjr S     SS jjrSS jrS S jr  S!         S"S jjrS#S jrS$S%S jjrSrg)&r#   i  a  Class for managing prefix => namespace mappings

This class requires an RDFlib Graph as an input parameter and may optionally have
the parameter bind_namespaces set. This second parameter selects a strategy which
is one of the following:

* core:
    * binds several core RDF prefixes only
    * owl, rdf, rdfs, xsd, xml from the NAMESPACE_PREFIXES_CORE object
* rdflib:
    * binds all the namespaces shipped with RDFLib as DefinedNamespace instances
    * all the core namespaces and all the following: brick, csvw, dc, dcat
    * dcmitype, dcterms, dcam, doap, foaf, geo, odrl, org, prof, prov, qb, schema
    * sh, skos, sosa, ssn, time, vann, void
    * see the NAMESPACE_PREFIXES_RDFLIB object for the up-to-date list
    * this is default
* none:
    * binds no namespaces to prefixes
    * note this is NOT default behaviour
* cc:
    * using prefix bindings from prefix.cc which is a online prefixes database
    * not implemented yet - this is aspirational

!!! warning "Breaking changes"

    The namespaces bound for specific values of `bind_namespaces`
    constitute part of RDFLib's public interface, so changes to them should
    only be additive within the same minor version. Removing values, or
    removing namespaces that are bound by default, constitutes a breaking
    change.

See the sample usage

```python
>>> import rdflib
>>> from rdflib import Graph
>>> from rdflib.namespace import Namespace, NamespaceManager
>>> EX = Namespace('http://example.com/')
>>> namespace_manager = NamespaceManager(Graph())
>>> namespace_manager.bind('ex', EX, override=False)
>>> g = Graph()
>>> g.namespace_manager = namespace_manager
>>> all_ns = [n for n in g.namespace_manager.namespaces()]
>>> assert ('ex', rdflib.term.URIRef('http://example.com/')) in all_ns

```
c                   Xl         0 U l        0 U l        S U l        0 U l        0 U l        US:X  a  g US:X  a]  [        R                  5        H  u  p4U R                  X45        M     [        R                  5        H  u  p4U R                  X45        M     g US:X  a  [        S5      eUS:X  a/  [        R                  5        H  u  p4U R                  X45        M     g [        SU 35      e)NnonerdflibcczHaven't got to this option yetcorezunsupported namespace set )graph_NamespaceManager__cache_NamespaceManager__cache_strict_NamespaceManager__log_NamespaceManager__strie_NamespaceManager__trie_NAMESPACE_PREFIXES_RDFLIBr   bind_NAMESPACE_PREFIXES_CORENotImplementedError
ValueError)rO   r  bind_namespacesprefixnss        r	   r   NamespaceManager.__init__  s    
;=BD
')&( f$ (8>>@
		&% A 7<<>
		&% ?$
 &&FGG&6<<>
		&% ? 9/9JKLLr
   c                J   ^ [        U4S jU R                  5        5       5      $ )Nc              3  J   >#    U  H  u  pTR                  U5      v   M     g 7fr   rp   )r   r  r  rr   s      r	   r   0NamespaceManager.__contains__.<locals>.<genexpr>  s!     J8I*&3>>"%%8Is    #)r   
namespacesrq   s    `r	   rs   NamespaceManager.__contains__  s    
 J8IJJJr
   c                    0 U l         0 U l        0 U l        U R                  5        H$  u  p[	        U R                  [        U5      5        M&     g r   )r  r  r  r  insert_trierD   )rO   pns      r	   resetNamespaceManager.reset
  s<    OO%DASV, &r
   c                .    U R                   R                  $ r   )r  storerN   s    r	   r'  NamespaceManager.store  s    zzr
   c                ^    U R                  U5      u  p#nUS:X  a  U$ SR                  X$45      $ NrR   r   compute_qnamejoinrO   r   r  	namespacerU   s        r	   qnameNamespaceManager.qname  s4    "&"4"4S"94R<K88VN++r
   c                J    U R                  XS9u  p4nSR                  X545      $ )at  
From a URI, generate a valid CURIE.

Result is guaranteed to contain a colon separating the prefix from the
name, even if the prefix is an empty string.

!!! warning "Side-effect"
    When `generate` is `True` (which is the default) and there is no
    matching namespace for the URI in the namespace manager then a new
    namespace will be added with prefix `ns{index}`.

    Thus, when `generate` is `True`, this function is not a pure
    function because of this side-effect.

    This default behaviour is chosen so that this function operates
    similarly to `NamespaceManager.qname`.

Args:
    uri: URI to generate CURIE for.
    generate: Whether to add a prefix for the namespace if one doesn't
        already exist.  Default: `True`.

Returns:
    CURIE for the URI

Raises:
    KeyError: If generate is `False` and the namespace doesn't already have
        a prefix.
)generater   r+  )rO   r   r3  r  r/  rU   s         r	   curieNamespaceManager.curie  s-    < #'"4"4S"4"L4xx''r
   c                ^    U R                  U5      u  p#nUS:X  a  U$ SR                  X$45      $ r*  )compute_qname_strictr-  r.  s        r	   qname_strictNamespaceManager.qname_strict=  s4    "&";";C"@4R<K88VN++r
   c                    [        U5      u  p#X R                  ;  a*  [        U R                  U R                  [	        U5      5        [        [	        U5      5      nU R                  R                  U5      nUc  [        U[        5      (       a  SU-  $ Uc  SU-  $ U R                  U5      nSR                  US   US   /5      $ ! [         a$    [        U[        5      (       a  SU-  s $ SU-  s $ f = f)z
Takes an RDF Term and 'normalizes' it into a QName (using the
registered prefix) or (unlike compute_qname) the Notation 3
form for URIs: <...URI...>
z?%sz<%s>r   r   )r   r  insert_strier  rD   r   	ExceptionrS   r   r'  r  r,  r-  )rO   rdfTermr/  rU   r  
qNamePartss         r	   normalizeUriNamespaceManager.normalizeUriD  s    		('0OI,T\\4;;IGs9~.I ""9->j(;;7?"^G##++G4J88Z]JrN;<<  	('8,,w&''		(s   AC $C4,C43C4c                Z   XR                   ;  GaD  [        U5      (       d  [        SR                  U5      5      e [	        U5      u  p4X0R                  ;  a!  [        U R                  U R                  U5        U R                  U   (       a,  [        U R                  U   U5      nUb  UnU[        U5      S  n[        U5      nU R                  R                  U5      nUcb  U(       d  [        SR                  U5      5      eSn SU-  nU R                  R                  U5      (       d  OUS-  nM-  U R                  Xc5        XcU4U R                   U'   U R                   U   $ ! [         a<  n[        U5      nU R                  R                  U5      nSnU(       d  Ue S nAGN\S nAff = f)NzY"{}" does not look like a valid URI, cannot serialize this. Did you want to urlencode it?rR   )No known prefix for {} and generate=Falser   ns%s)r  r   r  r   r   r   r'  r  r  r<  r  get_longest_namespacer   r   r/  r  )	rO   r   r3  r/  rU   r   r  pl_namespacenums	            r	   r,  NamespaceManager.compute_qname]  s   ll" %% ovv "+C.	 ,T\\4;;	B||I&4T\\)5LcR+ ,Is9~/0Dy)IZZ&&y1F~"CJJ9U  #c\F:://771HC	 
 		&,!'D 9DLL||C  ?  "3K	**95G 	s   E$ $
F*.1F%%F*c                   U R                  X5      u  p4n[        [        U5      5      (       a  X4U4$ XR                  ;  a   [	        U[
        5      u  pEX@R                  ;  a!  [        U R                  U R                  U5        [        U5      nU R                  R                  U5      nUcb  U(       d  [        SR                  U5      5      eSn SU-  nU R                  R                  U5      (       d  OUS-  nM-  U R!                  X45        X4U4U R                  U'   U R                  U   $ ! [         a    SR                  U5      n[        U5      ef = f)Nz^This graph cannot be serialized to a strict format because there is no valid way to shorten {}rC  r   rD  )r,  r   rD   r  r   NAME_START_CATEGORIESr  r   r  r<  r  r   r'  r  r   r/  r  )rO   r   r3  r  r/  rU   messagerG  s           r	   r7  %NamespaceManager.compute_qname_strict  s^    #'"4"4S"C4SYd**---.&/5J&KOI LL0 t{{IF #9-	** >#&GNN ) 
 C!'##zz33F;;!q	 
 IIf0,2t+D##C(&&s++W " .FFLfSk  %W--.s   D/ /'Ec                |   [        U5      [        La"  [        S[        U5      R                   S35      eUR	                  SS5      n[        U5      S:w  a  [        S5      eU R                  R                  US   5      nUb  [        [        U5       US    35      $ [        SUR	                  S5      S    S	35      e)
a7  
Expand a CURIE of the form <prefix:element>, e.g. "rdf:type"
into its full expression:

>>> import rdflib
>>> g = rdflib.Graph()
>>> g.namespace_manager.expand_curie("rdf:type")
rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')

Raises exception if a namespace is not bound to the prefix.

zArgument must be a string, not r   r   r      u@   Malformed curie argument, format should be e.g. “foaf:name”.r   zPrefix "z" not bound to any namespace.)
typerD   r   r~   splitr   r  r'  r/  r   )rO   r4  partsr  s       r	   expand_curieNamespaceManager.expand_curie  s     E{c!=d5k>R>R=SSTUVVC#u:?R  ZZ!!%(+>SWIeAhZ011EKK,Q/00NO r
   c                `   [         (       d  U R                  R                  X5      $  U R                  R                  XUS9$ ! [         aa  nS[	        U5      ;   aH  [
        R                  S[        U R                  5      SS9  U R                  R                  X5      s S nA$  S nAg S nAff = f)NoverriderV  z}caught a TypeError, retrying call to %s.bind without override, see https://github.com/RDFLib/rdflib/issues/1880 for more infoT)exc_info)_with_bind_override_fixr'  r  r   rD   loggerdebugrO  )rO   r  r/  rV  errors        r	   _store_bindNamespaceManager._store_bind  s    &&::??655	:::??6x?HH 		:SZ'U $!   zzv99 (		:s   A 
B-AB(B-(B-c                :   [        [        U5      5      nUc  SnOSU;   a  [        S5      eU R                  R	                  U5      nU(       a  [        U5      nU(       a  XR:w  a  U(       a0  U R                  XUS9  [        U R                  [        U5      5        gU(       d  SnSn U< U< 3nU R                  R	                  U5      nU(       a  U[        U5      :X  a  gU R                  R	                  U5      (       d  OUS-  nMb  U R                  XrUS9  ObU R                  R                  U5      n	U	c  U R                  XUS9  O3X:X  a  O-U(       d  U	R                  S5      (       a  U R                  XUS9  [        U R                  [        U5      5        g)	zBind a given namespace to the prefix

If override, rebind, even if the given namespace is already
bound to another prefix.

If replace, replace any existing prefix with the new namespace
NrR    z Prefixes may not contain spaces.rU  r   r   r   )
r   rD   r   r'  r/  r\  r!  r  r  rb   )
rO   r  r/  rV  replacebound_namespacerG  
new_prefix
tnamespacebound_prefixs
             r	   r  NamespaceManager.bind  sr    3y>*	>FF]=>>**..v6 $_5O;  X FDKKY8
 "C'-s3
!ZZ11*=
)vj/A"A zz++J77q  ZXF::,,Y7L#  X F'|66s;;$$V$JDKKY0r
   c              #  r   #    U R                   R                  5        H  u  p[        U5      nX4v   M     g 7fr   )r'  r  r   )rO   r  r/  s      r	   r  NamespaceManager.namespaces4  s2     !%!6!6!8Fy)I## "9s   57c                    [         R                  " 5       R                  5       n[        SU-  X(       + S9nU(       a  [	        U5      S   nU(       d  U(       a  US   S:X  a  US   S:w  a  SU-  n[        U5      $ )Nz%s/)allow_fragmentsr   r;  #z%s#)r   cwdas_urir   r   r   )rO   r   defragbaseresults        r	   
absolutizeNamespaceManager.absolutize9  sh    xxz  "sJGv&q)Fs2w#~&**;f~r
   )__cache__cache_strict__log__strie__trier  N)r	  )r  r   r  r  r|   )rw   None)rw   r   )r   rD   rw   rD   )T)r   rD   r3  r}   rw   rD   )r>  rD   rw   rD   )r   rD   r3  r}   rw   zTuple[str, URIRef, str])r   rD   r3  r}   rw   zTuple[str, str, str])r4  rD   rw   r   )r  rD   r/  r   rV  r}   rw   rw  )TF)
r  Optional[str]r/  r   rV  r}   r`  r}   rw   rw  )rw   zIterable[Tuple[str, URIRef]])r   )r   rD   rm  intrw   r   )r~   r   r   r   r   r   rs   r$  r   r'  r0  r4  r8  r@  r,  r7  rR  r\  r  r  rp  r   ru   r
   r	   r#   r#     s    .`#MJK-    ,(B,=2+!\ *.:,:,"&:,	:,x8:( @1@1 @1 	@1
 @1 
@1D$
 r
   r#   )LlLuLoLtNlNd)McMeMnLmr  )   ·u   ·-r   r   %r   rh   c                    U (       a`  U S   nUS:X  d  [        U5      [        ;   aB  [        S[        U 5      5       H(  nX   n[        U5      [        ;  d  M  U[
        ;   a  M(    g   gg)Nr   r   r   )r   rJ  ranger   NAME_CATEGORIESALLOWED_NAME_CHARS)rU   firstir   s       r	   r   r   s  s`    QC<8E?.CC1c$i(G{o5..  ) r
   c                   U R                  [        5      (       a  [        U R                  [        5      S   4$ [        U 5      n[	        SU5       Ht  nX* S-
     n[        U5      [        ;  d  M   U[        ;   a  M,  [	        SU-
  U5       H5  n[        X   5      U;   d
  X   S:X  d  M  U S U nU(       d    OXS  nXg4s  s  $      O   [        SR                  U 5      5      e)Nr   r   r;  r   zCan't split '{}')
rb   XMLNSrP  r   r  r   r  r  r  r   )r   split_startlengthr  r   jr  lns           r	   r   r     s     ~~esyy'*++XF1fQK{o-&&266*CF#{2cfmRaBRB8O +   '..s3
44r
   c                h   X;   a  X   $ Sn[        U R                  5       5       H~  n[        U5      [        U5      :  a&  UR                  U5      (       a  [	        X   U5      s  $ UR                  U5      (       d  MY  U(       d  0 X'   SnU R                  U5      nX@U   U'   M     X;  a  0 X'   X   $ )zInsert a value into the trie if it is not already contained in the trie.
Return the subtree for the value regardless of whether it is a new value
or not.FT)r   keysr   rb   r!  pop)trierI   multi_checkr[   dict_s        r	   r!  r!    s     }{KTYY[!u:C U%5%5c%:%:ty%00^^E"" "HHE  %K " ;r
   c                *    X ;  a  [        X5      X'   g g r   )r!  )strier  rI   s      r	   r<  r<    s    "4/ r
   c                t    U  H2  nUR                  U5      (       d  M  [        X   U5      nUc  Us  $ Us  $    g r   )rb   rE  )r  rI   r[   outs       r	   rE  rE    s?    C  '	59C{

  r
   )r$   )r%   )r&   )r'   )r(   )r)   )r*   )r+   )r,   )r-   )r.   )r/   )r0   )r1   )r2   )r3   )r4   )r5   )r6   )r7   )r8   )r9   )r:   )r;   )r<   )r=   )r>   )r?   )owlrdfrdfsxsdxmlbrickcsvwdcdcatdcmitypedctermsdcamdoapfoafgeoodrlorgprofprovqbschemash)skossosassntimevannvoidwgs)r   r   rw   r   )rU   rD   rw   ry  )r   rD   r  r   rw   zTuple[str, str])r  Dict[str, Any]rI   rD   rw   r  )r  r  r  r  rI   rD   rw   rw  )r  r  rI   rD   rw   rx  )zr   
__future__r   loggingr   annotationlibr   ImportErrorinspect	functoolsr   pathlibr   typingr   r   r   r   r   r   r   r   r   unicodedatar   urllib.parser   r   rdflib.termr   r   r   rdflib.graphr   rdflib.storer   __all__	getLoggerr~   rY  rD   r    r   r   r   r   rO  r   r"   r!   r  rdflib._type_checkingr  rX  r#   rJ  SPLIT_START_CATEGORIESr  r  r   r   r!  r<  rE  rdflib.namespace._BRICKr$   rdflib.namespace._CSVWr%   rdflib.namespace._DCr&   rdflib.namespace._DCAMr'   rdflib.namespace._DCATr(   rdflib.namespace._DCMITYPEr)   rdflib.namespace._DCTERMSr*   rdflib.namespace._DOAPr+   rdflib.namespace._FOAFr,   rdflib.namespace._GEOr-   rdflib.namespace._ODRL2r.   rdflib.namespace._ORGr/   rdflib.namespace._OWLr0   rdflib.namespace._PROFr1   rdflib.namespace._PROVr2   rdflib.namespace._QBr3   rdflib.namespace._RDFr4   rdflib.namespace._RDFSr5   rdflib.namespace._SDOr6   rdflib.namespace._SHr7   rdflib.namespace._SKOSr8   rdflib.namespace._SOSAr9   rdflib.namespace._SSNr:   rdflib.namespace._TIMEr;   rdflib.namespace._VANNr<   rdflib.namespace._VOIDr=   rdflib.namespace._WGSr>   rdflib.namespace._XSDr?   r  r  ru   r
   r	   <module>r     s  DL #  )    X X X   + 7 7""#J 
		8	$A$ A$H3 3J" h  " h Y#4 Y#x	=!5 	=0i 0f 	899 T Tr 7 .$7 '*HHG ( (>5	5$55.
!$20
 * ' # ' ' / - ' ' % ) % % ' ' # % ' % # ' ' % ' ' ' % %  U
D 	" D	
  w D D D 
3 E 
3 D D 	"  c!" 	"#$ 1 }  ))++ )	) 	))	)s)   H H4H  H0+H4/H00H4