
    PiG              	      ^   U d Z ddlmZ ddlZddlZ	 ddlmZ n"# e$ r 	 ddlmZ n# e$ r dnd	ZY nw xY wY nw xY wdd
l	m
Z
 ddlmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZ ddlmZmZmZ erddl m!Z! ddl"m#Z# g dZ$ ej%        e&          Z' G d de(          Z) G d de(          Z*h dZ+de,d<   ddhZ-de,d<    G d de.          Z/ G d d e/!          Z0 G d" d#e)          Z1 e)d$          Z2erdd%l3m4Z4 d&Z5 G d' d(          Z6g d)Z7e7d*gz   Z8e7g d+z   Z9g d,Z:dod0Z;e8fdpd5Z<dqd9Z=drd<Z>dsd>Z?dd?l@mAZA dd@lBmCZC ddAlDmEZE ddBlFmGZG ddClHmIZI ddDlJmKZK ddElLmMZM ddFlNmOZO ddGlPmQZQ ddHlRmSZS ddIlTmUZU ddJlVmWZW ddKlXmYZY ddLlZm[Z[ ddMl\m]Z] ddNl^m_Z_ ddOl`maZa ddPlbmcZc ddQldmeZe ddRlfmgZg ddSlhmiZi ddTljmkZk ddUllmmZm ddVlnmoZo ddWlpmqZq ddXlrmsZs ddYltmuZu ddZlvmwZw eYeaecewe2d[Zxi d\eAd]eCd^eEd_eId`eKdaeMdbeGdceOddeQdeeSdfeUdgeWdhe[die]dje_dkeedlegeiekemeoeqeseudmZydS )ta  
# 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_annotationsthingAnyreturndictc                    | j         S N)__annotations__)r   s    m/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/rdflib/namespace/__init__.pyr   r   W   s    ((    )	lru_cache)Path)	TYPE_CHECKINGr   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                  d     e Zd ZdZddZedd            Zdd
ZddZddZ	d fdZ
ddZ xZS )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

    ```
    valueUnion[str, bytes]r   c                    	 t                               | |          }n,# t          $ r t                               | |d          }Y nw xY w|S Nzutf-8)str__new__UnicodeDecodeErrorclsrC   rts      r   rH   zNamespace.__new__   sU    	2S%((BB! 	2 	2 	2S%11BBB	2	s    &AAr   c                &    t          | dz             S )Ntitler   selfs    r   rN   zNamespace.title   s     dWn%%%r   namerG   c                T    t          | t          |t                    r|ndz             S )N )r   
isinstancerG   rQ   rR   s     r   termzNamespace.term   s(    djs&;&;CddDEEEr   keyc                ,    |                      |          S r
   rW   rQ   rX   s     r   __getitem__zNamespace.__getitem__       yy~~r   c                d    |                     d          rt          |                     |          S N__)
startswithAttributeErrorrW   rV   s     r   __getattr__zNamespace.__getattr__   s,    ??4   	!  yyr   c                L    dt                                                       dS )N
Namespace()super__repr__rQ   	__class__s    r   ri   zNamespace.__repr__   s$    1EGG,,..1111r   refboolc                ,    |                     |           S )a  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

        ```
        ra   rQ   rl   s     r   __contains__zNamespace.__contains__   s    $ ~~d###r   )rC   rD   r   r"   r   r   rR   rG   r   r   rX   rG   r   r   r   rG   rl   rG   r   rm   )__name__
__module____qualname____doc__rH   propertyrN   rW   r\   rc   ri   rq   __classcell__rk   s   @r   r"   r"      s         $    & & & X&F F F F      
2 2 2 2 2 2$ $ $ $ $ $ $ $r   r"   c                  D     e Zd ZdZddZd fdZd fdZd fd
Z xZS )
URIPatternaL  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')

    ```
    rC   rD   r   c                    	 t                               | |          }nJ# t          $ r= t          rt	          |t
                    sJ t                               | |d          }Y nw xY w|S rF   )rG   rH   rI   r   rU   bytesrJ   s      r   rH   zURIPattern.__new__   su    	2S%((BB! 	2 	2 	2 0!%/////S%11BBB	2 	s    AA%$A%r   c                P    t           t                      j        |i |          S r
   )r   rh   __mod__rQ   argskwargsrk   s      r   r   zURIPattern.__mod__   s&    oeggot6v66777r   c                P    t           t                      j        |i |          S r
   )r   rh   formatr   s      r   r   zURIPattern.format   s&    neggnd5f55666r   rG   c                L    dt                                                       dS )NzURIPattern(rf   rg   rj   s    r   ri   zURIPattern.__repr__   s$    2UWW--//2222r   )rC   rD   r   r   rr   ru   )	rw   rx   ry   rz   rH   r   r   ri   r|   r}   s   @r   r   r      s            8 8 8 8 8 87 7 7 7 7 73 3 3 3 3 3 3 3 3 3r   r   >   _NS_fail_warn_extras	__slots___underscore_numzSet[str]_DFNS_RESERVED_ATTRS_pytestfixturefunction_partialmethod_IGNORED_ATTR_LOOKUPc                       e Zd ZU dZ e            Zded<   ded<   dZded<   d	Zded
<   g Z	ded<   d	Z
ded<    ed          d!d"d            Zd# fdZd$dZd$dZd%dZd&dZd'dZd(d Z xZS ))DefinedNamespaceMetaz>Utility metaclass for generating URIRefs with a common prefix.Tuple[str, ...]r   r"   r   Trm   r   Fr   	List[str]r   r   N)maxsizerR   rG   r   r   c                H   t          |          }|t          v rt          d|          |t          v rt                      | j        s| j        rG|| vrC| j        rt          d| d| j         d          t          j	        d| d| j
         d           | j        |         S )	Nz6DefinedNamespace like object has no access item named term '' not in namespace ''zCode: z is not defined in namespace    )
stacklevel)rG   r   KeyErrorr   r   r   rb   r   warningswarnrw   )rK   rR   defaults      r   r\   z DefinedNamespaceMeta.__getitem__  s    4yy'''QQQ   )))**I 	 	Cy $%Rd%R%R%R%R%RSSSNTNNNN     wt}r   c                   |t           v rt                      |t          v rt          d|          |                    d          r(t	          t
          |                               |          S |                     |          S )Nz.DefinedNamespace like object has no attribute r`   )r   rb   r   ra   rh   r   __getattribute__r\   )rK   rR   rk   s     r   rc   z DefinedNamespaceMeta.__getattr__)  s    ''' """))) III   __T"" 	K-s33DDTJJJt$$$r   c                ^    	 t          | j                  }n# t          $ r d}Y nw xY wd| dS )N<DefinedNamespace>re   rf   )reprr   rb   )rK   ns_reprs     r   ri   zDefinedNamespaceMeta.__repr__4  sK    	+37mmGG 	+ 	+ 	+*GGG	+&G&&&&s    &&c                N    	 t          | j                  S # t          $ r Y dS w xY w)Nr   )rG   r   rb   )rK   s    r   __str__zDefinedNamespaceMeta.__str__;  s9    	(sw<< 	( 	( 	('''	(s    
$$otherc                ,    |                      |          S r
   )r\   )rK   r   s     r   __add__zDefinedNamespaceMeta.__add__A  s    u%%%r   itemc                @    	  j         }n# t          $ r Y dS w xY wt          |                              t          |                    r$t	          t          |                    d         t           fd                                 D                       S )zGDetermine whether a URI or an individual item belongs to this namespaceFNc              3     K   | ]b}t          |t                    t          |          v p7|j        v p.j        o'd          dk    odd                                         V  cdS )r   _   N)
issubclassr$   r   r   r   isdigit).0crK   item_strs     r   	<genexpr>z4DefinedNamespaceMeta.__contains__.<locals>.<genexpr>M  s       
 
 !-..
*** W19$W#Us(:Ux|?S?S?U?U
 
 
 
 
 
r   )r   rb   rG   ra   lenanymro)rK   r   this_nsr   s   `  @r   rq   z!DefinedNamespaceMeta.__contains__D  s    	gGG 	 	 	55	t99s7||,, 	5CLL 1 1 3 34H 
 
 
 
 
 WWYY	
 
 
 
 
 	
s    
Iterable[str]c                     d t                     D             }|                    t                      fd|D             }|S )Nc                ,    h | ]}t          |          S  rG   )r   xs     r   	<setcomp>z/DefinedNamespaceMeta.__dir__.<locals>.<setcomp>V  s    666AQ666r   c                :    h | ]}t          |                   S r   r   )r   r   rK   s     r   r   z/DefinedNamespaceMeta.__dir__.<locals>.<setcomp>Y  s#    ---!#c!ff+---r   )r   difference_updater   )rK   attrsvaluess   `  r   __dir__zDefinedNamespaceMeta.__dir__U  sQ    66!5!5666 4555----u---r   pfxr   c                    |t          | j                  i}t          |                                           D ]$\  }}t	          |t
                    r
| d| ||<   %d|iS )z;Returns this DefinedNamespace as a JSON-LD 'context' object:z@context)rG   r   r   itemsr   r   )rQ   r   termsrX   rW   s        r   as_jsonld_contextz&DefinedNamespaceMeta.as_jsonld_context\  sl    c$(mm$(..4466 	, 	,IC$'' , #^^c^^c
E""r   r
   rs   )rR   rG   ru   )r   rG   r   r   )r   rG   r   rm   )r   r   )r   rG   r   r   )rw   rx   ry   rz   tupler   r   r   r   r   r   r   r\   rc   ri   r   r   rq   r   r   r|   r}   s   @r   r   r   
  sR        HH!&I((((NNNEEG!O!!!!Yt    &	% 	% 	% 	% 	% 	%' ' ' '( ( ( (& & & &
 
 
 
"   # # # # # # # #r   r   c                  8    e Zd ZU dZ e            Zded<   d ZdS )r$   zA Namespace with an enumerated list of members.

    Warnings are emitted if unknown members are referenced if _warn is True.
    r   r   c                     t          d          )Nz!namespace may not be instantiated)	TypeErrorrP   s    r   __init__zDefinedNamespace.__init__n  s    ;<<<r   N)rw   rx   ry   rz   r   r   r   r   r   r   r   r$   r$   f  sH          
 "'I((((= = = = =r   r$   )	metaclassc                       e Zd ZU dZded<   d fdZedd
            ZddZddZ	ddZ
ddZddZddZddZ xZS )r#   zf
    A namespace with a closed list of members

    Trying to create terms not listed is an error
    zDict[str, URIRef]_ClosedNamespace__urisurirG   r   r   c                t    t                                          | |          fd|D             _        S )Nc                6    i | ]}|t          |z             S r   rO   )r   trL   s     r   
<dictcomp>z+ClosedNamespace.__new__.<locals>.<dictcomp>}  s%    6661QrAv666r   )rh   rH   r   )rK   r   r   rL   rk   s      @r   rH   zClosedNamespace.__new__{  s;    WW__S#&&6666666		r   r   c                     t          |           S r
   r   rP   s    r   r   zClosedNamespace.uri  s    4yyr   rR   r   c                j    | j                             |          }|t          d| d|  d          |S )Nr   r   r   )r   getr   )rQ   rR   r   s      r   rW   zClosedNamespace.term  sA    kood##;EDEEdEEEFFF
r   rX   c                ,    |                      |          S r
   rZ   r[   s     r   r\   zClosedNamespace.__getitem__  r]   r   c                    |                     d          rt          	 |                     |          S # t          $ r}t          |          d }~ww xY wr_   )ra   rb   rW   r   )rQ   rR   es      r   rc   zClosedNamespace.__getattr__  s^    ??4   	(  (yy& ( ( ($Q'''(s   3 
AAAc                P    | j          d| j        j         dt          |           dS )N.(rf   )rx   rk   rw   rG   rP   s    r   ri   zClosedNamespace.__repr__  s.    /LLDN$;LLc$iiLLLLr   c                *    t          | j                  S r
   )listr   rP   s    r   r   zClosedNamespace.__dir__  s    DK   r   rl   rm   c                8    || j                                         v S r
   )r   r   rp   s     r   rq   zClosedNamespace.__contains__  s    4;%%'''	
r   c                     t          |           S r
   )dirrP   s    r   _ipython_key_completions_z)ClosedNamespace._ipython_key_completions_  s    4yyr   )r   rG   r   r   ru   rs   rt   )r   r   rv   )rw   rx   ry   rz   r   rH   r{   r   rW   r\   rc   ri   r   rq   r   r|   r}   s   @r   r#   r#   r  s               
    X      ( ( ( (M M M M! ! ! !
 
 
 

       r   r#   z$http://www.w3.org/XML/1998/namespace)_NamespaceSetStringTc                      e Zd ZdZd0d1dZd2dZd3dZed4d            Zd5dZ	d6d7dZ
d5dZd8dZd6d9dZ	 d6d:dZd;dZd<d#Z	 	 d=d>d(Zd?d*Zd@dAd.Zd/S )Br%   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

    ```
    rdflibgraphr   bind_namespacesr   c                   || _         i | _        i | _        d | _        i | _        i | _        |dk    rd S |dk    rlt                                          D ]\  }}|                     ||           t                                          D ]\  }}|                     ||           d S |dk    rt          d          |dk    r7t                                          D ]\  }}|                     ||           d S t          d|           )Nnoner   cczHaven't got to this option yetcorezunsupported namespace set )r   _NamespaceManager__cache_NamespaceManager__cache_strict_NamespaceManager__log_NamespaceManager__strie_NamespaceManager__trie_NAMESPACE_PREFIXES_RDFLIBr   bind_NAMESPACE_PREFIXES_CORENotImplementedError
ValueError)rQ   r   r   prefixnss        r   r   zNamespaceManager.__init__  sB   
;=BD
')&( f$$ D((8>>@@ & &
		&"%%%%6<<>> & &
		&"%%%%& &$$
 &&FGGG&&6<<>> & &
		&"%%%%& & K/KKLLLr   rl   rG   r   rm   c                ^    t          fd|                                 D                       S )Nc              3  H   K   | ]\  }}                     |          V  d S r
   ro   )r   r   r   rl   s      r   r   z0NamespaceManager.__contains__.<locals>.<genexpr>  s3      JJ*&"3>>"%%JJJJJJr   )r   
namespacesrp   s    `r   rq   zNamespaceManager.__contains__  s2    
 JJJJ8I8IJJJJJJr   Nonec                    i | _         i | _        i | _        |                                 D ]'\  }}t	          | j        t          |                     (d S r
   )r   r   r   r  insert_trierG   )rQ   pns      r   resetzNamespaceManager.reset
  sY    OO%% 	- 	-DAqSVV,,,,	- 	-r   r   c                    | j         j        S r
   )r   storerP   s    r   r
  zNamespaceManager.store  s    zr   r   c                r    |                      |          \  }}}|dk    r|S d                    ||f          S NrT   r   compute_qnamejoinrQ   r   r   	namespacerR   s        r   qnamezNamespaceManager.qname  s@    "&"4"4S"9"9	4R<<K88VTN+++r   Tgeneratec                f    |                      ||          \  }}}d                    ||f          S )a  
        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.
        )r  r   r  )rQ   r   r  r   r  rR   s         r   curiezNamespaceManager.curie  s9    < #'"4"4S8"4"L"L	4xx'''r   c                r    |                      |          \  }}}|dk    r|S d                    ||f          S r  )compute_qname_strictr  r  s        r   qname_strictzNamespaceManager.qname_strict=  s@    "&";";C"@"@	4R<<K88VTN+++r   rdfTermc                   	 t          |          \  }}|| j        vr(t          | j        | j        t	          |                     t          t	          |                    }n1# t          $ r$ t          |t                    rd|z  cY S d|z  cY S w xY w| j	        
                    |          }|t          |t                    rd|z  S |d|z  S |                     |          }d                    |d         |d         g          S )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>Nr   r   )r!   r   insert_strier   rG   r   	ExceptionrU   r   r
  r   r  r  )rQ   r  r  rR   r   
qNamePartss         r   normalizeUrizNamespaceManager.normalizeUriD  s   		('00OIt,,T\4;IGGGs9~~..II 	( 	( 	('8,, (w&&&''''		(
 ""9-->j(;;>7?"^G##++G44J88Z]JrN;<<<s   AA" "$BBBTuple[str, URIRef, str]c                J   || j         vrt          |          s"t          d                    |                    	 t	          |          \  }}nF# t          $ r9}t          |          }| j                            |          }d}|s|Y d }~nd }~ww xY w|| j        vrt          | j        | j
        |           | j        |         r6t          | j        |         |          }||}|t          |          d          }t          |          }| j                            |          }|c|s"t          d                    |                    d}	 d|z  }| j                            |          sn|dz  }&|                     ||           |||f| j         |<   | j         |         S )NzY"{}" does not look like a valid URI, cannot serialize this. Did you want to urlencode it?rT   )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   )	rQ   r   r  r  rR   r   r   pl_namespacenums	            r   r  zNamespaceManager.compute_qname]  s   dl"" %%  ovv   "+C..	44   "3KK	**955 G    	 ,,T\4;	BBB|I& 14T\)5LcRR+ ,Is9~~//0Dy))IZ&&y11F~ "CJJ9UU   #c\F://77 1HC	
 		&),,,!'D 9DL|C  s   A 
B/BBTuple[str, str, str]c                   |                      ||          \  }}}t          t          |                    r|||fS || j        vr	 t	          |t
                    \  }}n2# t          $ r% d                    |          }t          |          w xY w|| j        vrt          | j        | j
        |           t          |          }| j                            |          }|c|s"t          d                    |                    d}	 d|z  }| j                            |          sn|dz  }&|                     ||           |||f| j        |<   | j        |         S )Nz^This graph cannot be serialized to a strict format because there is no valid way to shorten {}r"  r   r#  )r  r    rG   r   r!   NAME_START_CATEGORIESr   r   r   r  r   r   r
  r   r   r  r   )rQ   r   r  r   r  rR   messager&  s           r   r  z%NamespaceManager.compute_qname_strict  s    #'"4"4S("C"C	4SYY 1	,9d**$---.&/5J&K&KOItt! . . .FFLfSkk  %W---. DL00 t{IFFF #9--	**  ># &GNN )   
 C!!'##z33F;; "!q	!
 IIfi000,2It+D#C(&s++s   A   /Br  r   c                   t          |          t          ur%t          dt          |          j         d          |                    dd          }t          |          dk    rt          d          | j                            |d                   }|&t          t          |           |d                    S t          d	|                    d          d          d
          )aw  
        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   NzPrefix "z" not bound to any namespace.)
typerG   r   rw   splitr   r   r
  r  r   )rQ   r  partsr   s       r   expand_curiezNamespaceManager.expand_curie  s     E{{c!!Ud5kk>RUUUVVVC##u::??R   Z!!%(++>SWW0eAh00111OEKK,,Q/OOO  r   r   r  overridec                r   t           s| j                            ||          S 	 | j                            |||          S # t          $ rk}dt	          |          v rOt
                              dt          | j                  d           | j                            ||          cY d }~S Y d }~d S d }~ww xY w)Nr1  r1  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   rG   loggerdebugr-  )rQ   r   r  r1  errors        r   _store_bindzNamespaceManager._store_bind  s    & 	6:??69555	::??69x?HHH 		: 		: 		:SZZ''U $$!     zvy99999999 ('''''		:s   A 
B6AB1%B61B6FOptional[str]r   replacec                Z   t          t          |                    }|d}nd|v rt          d          | j                            |          }|rt          |          }|r||k    r|r<|                     |||           t          | j        t          |                     dS |sd}d}	 ||}| j                            |          }|r|t          |          k    rdS | j                            |          sn|dz  }X|                     |||           nk| j                            |          }	|	|                     |||           n6|	|k    rn/|s|		                    d          r|                     |||           t          | j        t          |                     dS )	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
        NrT    z Prefixes may not contain spaces.r3  r   r   r   )
r   rG   r   r
  r  r9  r  r   r   ra   )
rQ   r   r  r1  r;  bound_namespacer&  
new_prefix
tnamespacebound_prefixs
             r   r   zNamespaceManager.bind  s    3y>>**	>FFF]]=>>>*..v66  	6$_55O  	K);;   X FFFDKY888
  #"C	'-vss3
!Z11*==
 )vj/A/A"A"A Fz++J77 q	 ZXFFFF:,,Y77L#  X FFFF'' K|66s;; K$$VY$JJJDKY00000r   Iterable[Tuple[str, URIRef]]c              #  r   K   | j                                         D ]\  }}t          |          }||fV  d S r
   )r
  r  r   )rQ   r   r  s      r   r  zNamespaceManager.namespaces4  sS      !%!6!6!8!8 	$ 	$FIy))I)#####	$ 	$r   r   defragintc                   t          j                                                    }t          d|z  ||           }|rt	          |          d         }|s|r|d         dk    r|d         dk    rd|z  }t          |          S )Nz%s/)allow_fragmentsr   r  #z%s#)r   cwdas_urir   r   r   )rQ   r   rD  baseresults        r   
absolutizezNamespaceManager.absolutize9  s    xzz  ""sJGGG 	*v&&q)F 	( (s2w#~~&**;*;f~~r   N)r   )r   r   r   r   rv   )r   r  )r   r   )r   rG   r   rG   )T)r   rG   r  rm   r   rG   )r  rG   r   rG   )r   rG   r  rm   r   r   )r   rG   r  rm   r   r'  )r  rG   r   r   )r   rG   r  r   r1  rm   r   r  )TF)
r   r:  r  r   r1  rm   r;  rm   r   r  )r   rB  )r   )r   rG   rD  rE  r   r   )rw   rx   ry   rz   r   rq   r  r{   r
  r  r  r  r  r  r  r0  r9  r   r  rM  r   r   r   r%   r%     s       . .`#M #M #M #M #MJK K K K- - - -       X , , , ,( ( ( ( (B, , , ,= = = =2+! +! +! +! +!\ *.:, :, :, :, :,x   8: : : :( @1 @1 @1 @1 @1D$ $ $ $
      r   r%   )LlLuLoLtNlNd)McMeMnLmrS  )   ·u   ·-r   r   %r   rf   rR   rG   rE  c                    | rq| d         }|dk    st          |          t          v rMt          dt          |                     D ]-}| |         }t          |          t          vr|t
          v r* dS .dS dS )Nr   r   r   )r   r)  ranger   NAME_CATEGORIESALLOWED_NAME_CHARS)rR   firstir   s       r   r    r    s  s     QC<<8E??.CCC1c$ii((  G{{o55... 11 6 11r   r   split_startr   Tuple[str, str]c                   |                      t                    r't          |                     t                    d         fS t          |           }t	          d|          D ]}| | dz
           }t          |          t          vre|t          v r.t	          d|z
  |          D ]E}t          | |                   |v s| |         dk    r | d |         }|s n| |d          }||fc c S F nt          d	                    |                     )Nr   r   r  r   zCan't split '{}')
ra   XMLNSr.  r   r\  r   r]  r^  r   r   )r   ra  lengthr`  r   jr   lns           r   r!   r!     s0    ~~e ,syy''*++XXF1f  QK{{o--&&&266** $ $CF##{22c!fmmRaRB QRRB8OOOOO 7D E . '..s33
4
44r   trieDict[str, Any]rC   c                   || v r| |         S d}t          |                                           D ]}t          |          t          |          k    r-|                    |          rt	          | |         |          c S |                    |          r)|si | |<   d}|                     |          }|| |         |<   || vri | |<   | |         S )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   ra   r  pop)rh  rC   multi_checkrX   dict_s        r   r  r    s     }}E{KTYY[[!! 
% 
%u::C  U%5%5c%:%: tCy%00000^^E"" 	% # U"HH E  %DKDU;r   strier  c                8    || vrt          ||          | |<   d S d S r
   )r  )ro  rh  rC   s      r   r  r    s,    E"4//e r   r:  c                z    | D ]7}|                     |          r t          | |         |          }||c S |c S 8d S r
   )ra   r$  )rh  rC   rX   outs       r   r$  r$    s]      C   	'S	599C{





	 4r   )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?   )r@   )rA   )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   r   r   )rR   rG   r   rE  )r   rG   ra  r   r   rb  )rh  ri  rC   rG   r   ri  )ro  ri  rh  ri  rC   rG   r   r  )rh  ri  rC   rG   r   r:  )zrz   
__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__	getLoggerrw   r6  rG   r"   r   r   r   r   r-  r   r$   r#   rd  rdflib._type_checkingr   r5  r%   r)  SPLIT_START_CATEGORIESr]  r^  r    r!   r  r  r$  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._ODRL2r0   rdflib.namespace._ORGr1   rdflib.namespace._OWLr2   rdflib.namespace._PROFr3   rdflib.namespace._PROVr4   rdflib.namespace._QBr5   rdflib.namespace._RDFr6   rdflib.namespace._RDFSr7   rdflib.namespace._SDOr8   rdflib.namespace._SHr9   rdflib.namespace._SKOSr:   rdflib.namespace._SOSAr;   rdflib.namespace._SSNr<   rdflib.namespace._TIMEr=   rdflib.namespace._VANNr>   rdflib.namespace._VOIDr?   rdflib.namespace._WGSr@   rdflib.namespace._XSDrA   r   r   r   r   r   <module>r     s-  D D DL # " " " " "  )        ) ) ))+++++++ ) ) )	) 	) 	) 	) 	) 	))	)              X X X X X X X X X X X X X X X X X X X X X X             + + + + + + + + 7 7 7 7 7 7 7 7 7 7 #""""""""""""# # #J 
	8	$	$A$ A$ A$ A$ A$ A$ A$ A$H3 3 3 3 3 3 3 3J" " "      "     Y# Y# Y# Y# Y#4 Y# Y# Y#x	= 	= 	= 	= 	=!5 	= 	= 	= 	=0 0 0 0 0i 0 0 0f 		899 :999999 T T T T T T T Tr 766 .$7 '*H*H*HHGGG    ( (>5 5 5 5 5.   20 0 0 0
    * ) ) ) ) ) ' ' ' ' ' ' # # # # # # ' ' ' ' ' ' ' ' ' ' ' ' / / / / / / - - - - - - ' ' ' ' ' ' ' ' ' ' ' ' % % % % % % ) ) ) ) ) ) % % % % % % % % % % % % ' ' ' ' ' ' ' ' ' ' ' ' # # # # # # % % % % % % ' ' ' ' ' ' % % % % % % # # # # # # ' ' ' ' ' ' ' ' ' ' ' ' % % % % % % ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' % % % % % % % % % % % %   U
D 	" D	
  w D D D 
3 E 
3 D D 	"  c!" 	"#$ 1     s$    9'9	39399