o
    miG                     @  s  U d Z ddlmZ ddlZddlZzddlmZ W n  ey9   zddlmZ W n ey6   dtd	d
ZY nw Y n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rddl m!Z! ddl"m#Z# g dZ$e%e&Z'G dd de(Z)G dd de(Z*h dZ+de,d< ddhZ-de,d< G dd de.Z/G d d! d!e/d"Z0G d#d$ d$e)Z1e)d%Z2erdd&l3m4Z4 d'Z5G d(d) d)Z6g d*Z7e7d+g Z8e7g d, Z9g d-Z:dud1d2Z;e8fdvd7d8Z<dwd<d=Z=dxd@dAZ>dydCdDZ?ddEl@mAZA ddFlBmCZC ddGlDmEZE ddHlFmGZG ddIlHmIZI ddJlJmKZK ddKlLmMZM ddLlNmOZO ddMlPmQZQ ddNlRmSZS ddOlTmUZU ddPlVmWZW ddQlXmYZY ddRlZm[Z[ ddSl\m]Z] ddTl^m_Z_ ddUl`maZa ddVlbmcZc ddWldmeZe ddXlfmgZg ddYlhmiZi ddZljmkZk dd[llmmZm dd\lnmoZo dd]lpmqZq dd^lrmsZs dd_ltmuZu dd`lvmwZw eYeaecewe2daZxi dbeAdceCddeEdeeIdfeKdgeMdheGdieOdjeQdkeSdleUdmeWdne[doe]dpe_dqeedregeiekemeoeqeseudsZydS )za  
# 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                 C  s   | j S N)__annotations__)r    r
   S/home/kim/smarthome/.venv/lib/python3.10/site-packages/rdflib/namespace/__init__.pyr   W   s   r   )	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                      sb   e Zd ZdZdddZeddd	ZdddZdddZdddZ	d fddZ
dddZ  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                 C  s6   z	t | |}W |S  ty   t | |d}Y |S w Nzutf-8)str__new__UnicodeDecodeErrorclsr@   rtr
   r
   r   rD      s   zNamespace.__new__r   c                 C  s   t | d S )Ntitler   selfr
   r
   r   rI      s   zNamespace.titlenamerC   c                 C  s   t | t|tr| S d S )N )r   
isinstancerC   rL   rM   r
   r
   r   term   s   zNamespace.termkeyc                 C  
   |  |S r   rQ   rL   rR   r
   r
   r   __getitem__      
zNamespace.__getitem__c                 C  s   | drt| |S N__)
startswithAttributeErrorrQ   rP   r
   r
   r   __getattr__   s   

zNamespace.__getattr__c                      dt    dS )N
Namespace()super__repr__rK   	__class__r
   r   rb         zNamespace.__repr__refboolc                 C  s
   | | 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

        ```
        rZ   rL   rf   r
   r
   r   __contains__   s   
zNamespace.__contains__)r@   rA   r   r    r   r   rM   rC   r   r   rR   rC   r   r   r   rC   rf   rC   r   rg   )__name__
__module____qualname____doc__rD   propertyrI   rQ   rV   r\   rb   rj   __classcell__r
   r
   rc   r   r       s    



r    c                      sH   e Zd ZdZdddZd fdd	Zd fd
dZd fddZ  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')

    ```
    r@   rA   r   c                 C  sH   z	t | |}W |S  ty#   trt|tsJ t | |d}Y |S w rB   )rC   rD   rE   r   rO   bytesrF   r
   r
   r   rD      s   zURIPattern.__new__r   c                      t t j|i |S r   )r   ra   __mod__rL   argskwargsrc   r
   r   ry         zURIPattern.__mod__c                   rx   r   )r   ra   formatrz   rc   r
   r   r~      r}   zURIPattern.formatrC   c                   r]   )NzURIPattern(r_   r`   rK   rc   r
   r   rb      re   zURIPattern.__repr__)r@   rA   r   rv   rk   rn   )	rp   rq   rr   rs   rD   ry   r~   rb   ru   r
   r
   rc   r   rv      s    
	rv   >   	__slots___extras_fail_underscore_num_warn_NSzSet[str]_DFNS_RESERVED_ATTRSZ_pytestfixturefunction_partialmethod_IGNORED_ATTR_LOOKUPc                      s   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*ddZd+ fddZd,ddZd,ddZd-ddZd.d d!Zd/d#d$Zd0d'd(Z  ZS )1DefinedNamespaceMetaz>Utility metaclass for generating URIRefs with a common prefix.Tuple[str, ...]r   r    r   Trg   r   Fr   	List[str]r   r   N)maxsizerM   rC   r   r   c                 C  s   t |}|tv rtd||tv rt | js| jr=|| vr=| jr/td| d| j dtj	d| d| j
 dd | j| S )	Nz6DefinedNamespace like object has no access item named term '' not in namespace ''zCode: z is not defined in namespace    )
stacklevel)rC   r   KeyErrorr   r   r   r[   r   warningswarnrp   )rG   rM   defaultr
   r
   r   rV     s   
z DefinedNamespaceMeta.__getitem__c                   sH   |t v rt |tv rtd||drtt| |S | |S )Nz.DefinedNamespace like object has no attribute rY   )r   r[   r   rZ   ra   r   __getattribute__rV   )rG   rM   rc   r
   r   r\   )  s   

z DefinedNamespaceMeta.__getattr__c                 C  s2   zt | j}W n ty   d}Y nw d| dS )N<DefinedNamespace>r^   r_   )reprr   r[   )rG   Zns_reprr
   r
   r   rb   4  s   zDefinedNamespaceMeta.__repr__c                 C  s"   zt | jW S  ty   Y dS w )Nr   )rC   r   r[   rG   r
   r
   r   __str__;  s
   zDefinedNamespaceMeta.__str__otherc                 C  rS   r   )rV   )rG   r   r
   r
   r   __add__A  rW   zDefinedNamespaceMeta.__add__itemc                   sf   z j }W n
 ty   Y dS w t|t|r%tt|d t fdd  D S )zGDetermine whether a URI or an individual item belongs to this namespaceFNc                 3  sR    | ]$}t |trt|v p$|jv p$ jo$d  dko$dd  V  qdS )r   _   N)
issubclassr"   r   r   r   isdigit).0crG   Zitem_strr
   r   	<genexpr>M  s     
z4DefinedNamespaceMeta.__contains__.<locals>.<genexpr>)r   r[   rC   rZ   lenanymro)rG   r   Zthis_nsr
   r   r   rj   D  s   
z!DefinedNamespaceMeta.__contains__Iterable[str]c                   s2   dd t  D }|t  fdd|D }|S )Nc                 S  s   h | ]}t |qS r
   rC   r   xr
   r
   r   	<setcomp>V  s    z/DefinedNamespaceMeta.__dir__.<locals>.<setcomp>c                   s   h | ]} t | qS r
   r   r   r   r
   r   r   Y  s    )r   difference_updater   )rG   attrsvaluesr
   r   r   __dir__U  s   
zDefinedNamespaceMeta.__dir__pfxr   c                 C  sH   |t | ji}t|  D ]\}}t|tr| d| ||< qd|iS )z;Returns this DefinedNamespace as a JSON-LD 'context' object:z@context)rC   r   r   itemsr   r   )rL   r   termsrR   rQ   r
   r
   r   as_jsonld_context\  s   
z&DefinedNamespaceMeta.as_jsonld_contextr   rl   )rM   rC   rn   )r   rC   r   r   )r   rC   r   rg   )r   r   )r   rC   r   r   )rp   rq   rr   rs   tupler   r	   r   r   r   r   r   rV   r\   rb   r   r   rj   r   r   ru   r
   r
   rc   r   r   
  s"   
 




r   c                   @  s(   e Zd ZU dZe Zded< 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                 C  s   t d)Nz!namespace may not be instantiated)	TypeErrorrK   r
   r
   r   __init__n     zDefinedNamespace.__init__N)rp   rq   rr   rs   r   r   r	   r   r
   r
   r
   r   r"   f  s   
 r"   )	metaclassc                      s   e Zd ZU dZded< d  fdd	Zed!ddZd"ddZd#ddZ	d"ddZ
d!ddZd$ddZd%ddZd$ddZ  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urirC   r   r   c                   s&   t  | |  fdd|D  _ S )Nc                   s   i | ]	}|t  | qS r
   rJ   )r   trH   r
   r   
<dictcomp>}  s    z+ClosedNamespace.__new__.<locals>.<dictcomp>)ra   rD   r   )rG   r   r   rc   r   r   rD   {  s   zClosedNamespace.__new__r   c                 C     t | S r   r   rK   r
   r
   r   r        zClosedNamespace.urirM   r   c                 C  s.   | j |}|d u rtd| d|  d|S )Nr   r   r   )r   getr   )rL   rM   r   r
   r
   r   rQ     s   zClosedNamespace.termrR   c                 C  rS   r   rT   rU   r
   r
   r   rV     rW   zClosedNamespace.__getitem__c              
   C  s<   | drtz| |W S  ty } zt|d }~ww rX   )rZ   r[   rQ   r   )rL   rM   er
   r
   r   r\     s   
zClosedNamespace.__getattr__c                 C  s    | j  d| jj dt| dS )N.(r_   )rq   rd   rp   rC   rK   r
   r
   r   rb     s    zClosedNamespace.__repr__c                 C  s
   t | jS r   )listr   rK   r
   r
   r   r     rW   zClosedNamespace.__dir__rf   rg   c                 C  s   || j  v S r   )r   r   ri   r
   r
   r   rj     s   zClosedNamespace.__contains__c                 C  r   r   )dirrK   r
   r
   r   _ipython_key_completions_  r   z)ClosedNamespace._ipython_key_completions_)r   rC   r   r   rn   rl   rm   )r   r   ro   )rp   rq   rr   rs   r	   rD   rt   r   rQ   rV   r\   rb   r   rj   r   ru   r
   r
   rc   r   r!   r  s   
 



	

r!   z$http://www.w3.org/XML/1998/namespace)_NamespaceSetStringTc                   @  s   e Zd ZdZd?d@ddZdAddZdBddZedCddZdDddZ	dEdFddZ
dDddZdGdd ZdEdHd"d#Z	dEdId%d&ZdJd)d*ZdKd.d/Z		0dLdMd4d5ZdNd7d8ZdOdPd<d=Zd>S )Qr#   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                 C  s   || _ i | _i | _d | _i | _i | _|dkrd S |dkr<t D ]
\}}| || q t	 D ]
\}}| || q/d S |dkrDt
d|dkrYt	 D ]
\}}| || qLd S td| )Nnoner   cczHaven't got to this option yetcorezunsupported namespace set )r   _NamespaceManager__cache_NamespaceManager__cache_strictZ_NamespaceManager__log_NamespaceManager__strie_NamespaceManager__trie_NAMESPACE_PREFIXES_RDFLIBr   bind_NAMESPACE_PREFIXES_CORENotImplementedError
ValueError)rL   r   r   prefixnsr
   r
   r   r     s*   zNamespaceManager.__init__rf   rC   r   rg   c                   s   t  fdd|  D S )Nc                 3  s    | ]
\}}  |V  qd S r   rh   )r   r   r   rf   r
   r   r     s    z0NamespaceManager.__contains__.<locals>.<genexpr>)r   
namespacesri   r
   r   r   rj     s   zNamespaceManager.__contains__Nonec                 C  s8   i | _ i | _i | _|  D ]\}}t| jt| qd S r   )r   r   r   r   insert_trierC   )rL   pnr
   r
   r   reset
  s   zNamespaceManager.resetr   c                 C  s   | j jS r   )r   storerK   r
   r
   r   r     r   zNamespaceManager.storer   c                 C  *   |  |\}}}|dkr|S d||fS NrN   r   compute_qnamejoinrL   r   r   	namespacerM   r
   r
   r   qname     zNamespaceManager.qnameTgeneratec                 C  s"   | j ||d\}}}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   )rL   r   r   r   r   rM   r
   r
   r   curie  s   zNamespaceManager.curiec                 C  r   r   )compute_qname_strictr   r   r
   r
   r   qname_strict=  r   zNamespaceManager.qname_strictrdfTermc                 C  s   zt |\}}|| jvrt| j| jt| tt|}W n ty5   t|tr/d|  Y S d|  Y S w | j	
|}|du rIt|trId| S |du rQd| 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   rC   r   	ExceptionrO   r   r   r   r   r   )rL   r   r   rM   r   Z
qNamePartsr
   r
   r   normalizeUriD  s"   


zNamespaceManager.normalizeUriTuple[str, URIRef, str]c           	   
   C  s@  || j vrt|std|zt|\}}W n" ty: } zt|}| j|}d}|s0|W Y d }~nd }~ww || jvrHt	| j| j
| | j| rct| j| |}|d urc|}|t|d  }t|}| j|}|d u r|sztd|d}	 d| }| j|sn|d7 }q}| || |||f| j |< | j | S )NzY"{}" does not look like a valid URI, cannot serialize this. Did you want to urlencode it?rN   )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   )	rL   r   r   r   rM   r   r   Zpl_namespacenumr
   r
   r   r   ]  sT   



zNamespaceManager.compute_qnameTuple[str, str, str]c                 C  s   |  ||\}}}tt|r|||fS || jvrxz	t|t\}}W n ty2   d|}t|w || jvr@t	| j| j
| t|}| j|}|d u rp|sWtd|d}	 d| }| j|sen|d7 }qZ| || |||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   rC   r   r   NAME_START_CATEGORIESr   r~   r   r   r   r   r   r   r   r   r   )rL   r   r   r   r   rM   messager   r
   r
   r   r     sF   


	
z%NamespaceManager.compute_qname_strictr   r   c                 C  s   t |turtdt |j d|dd}t|dkr!td| j|d }|dur9t	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.)
typerC   r   rp   splitr   r   r   r   r   )rL   r   partsr   r
   r
   r   expand_curie  s   zNamespaceManager.expand_curier   r   overridec              
   C  s   t s	| j||S z
| jj|||dW S  tyD } z%dt|v r9tjdt| jdd | j||W  Y d }~S W Y d }~d S d }~ww )Nr  r  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   rC   loggerdebugr   )rL   r   r   r  errorr
   r
   r   _store_bind  s   zNamespaceManager._store_bindFOptional[str]r   replacec           
      C  s<  t t|}|du rd}nd|v rtd| j|}|r!t |}|rm||krm|r;| j|||d t| jt| dS |s?d}d}	 d||f }| j|}|rX|t |krXdS | j|s_n|d7 }qB| j|||d n'| j|}	|	du r| j|||d n|	|krn|s|		d	r| j|||d 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
        NrN    z Prefixes may not contain spaces.r  r   r   z%s%sr   )
r   rC   r   r   r   r	  r   r   r   rZ   )
rL   r   r   r  r  Zbound_namespacer   
new_prefixZ
tnamespaceZbound_prefixr
   r
   r   r     sD   
zNamespaceManager.bindIterable[Tuple[str, URIRef]]c                 c  s,    | j  D ]\}}t|}||fV  qd S r   )r   r   r   )rL   r   r   r
   r
   r   r   4  s
   zNamespaceManager.namespacesr   defragintc                 C  s`   t   }td| || d}|rt|d }|s,|r,|d dkr,|d dkr,d| }t|S )Nz%s/)allow_fragmentsr   r   #z%s#)r   cwdas_urir   r   r   )rL   r   r  baseresultr
   r
   r   
absolutize9  s   zNamespaceManager.absolutizeN)r   )r   r   r   r   ro   )r   r   )r   r   )r   rC   r   rC   )T)r   rC   r   rg   r   rC   )r   rC   r   rC   )r   rC   r   rg   r   r   )r   rC   r   rg   r   r   )r   rC   r   r   )r   rC   r   r   r  rg   r   r   )TF)
r   r
  r   r   r  rg   r  rg   r   r   )r   r  )r   )r   rC   r  r  r   r   )rp   rq   rr   rs   r   rj   r   rt   r   r   r   r   r   r   r   r  r	  r   r   r  r
   r
   r
   r   r#     s*    0
%


!
.
<

Br#   )ZLlZLuZLoLtZNlNd)ZMcZMeZMnZLmr  )   ·u   ·-r   r   %r   r_   rM   rC   r  c                 C  s`   | r.| d }|dkst |tv r.tdt| D ]}| | }t |tvr+|tv r(q dS qdS dS )Nr   r   r   )r   r   ranger   NAME_CATEGORIESALLOWED_NAME_CHARS)rM   firstir   r
   r
   r   r   s  s   r   r   split_startr   Tuple[str, str]c                 C  s   |  trt| td fS t| }td|D ]F}| | d  }t|tvr]|tv r+qtd| |D ](}t| | |v sB| | dkrZ| d | }|sL n| |d  }||f    S q2 nqtd	| )Nr   r   r   r   zCan't split '{}')
rZ   XMLNSr   r   r  r   r  r  r   r~   )r   r"  lengthr!  r   jr   lnr
   r
   r   r     s&   
r   trieDict[str, Any]r@   c                 C  s   || v r| | S d}t |  D ]0}t|t|kr(||r(t| | |  S ||r@|s5i | |< d}| |}|| | |< q|| vrIi | |< | | 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   rZ   r   pop)r(  r@   Zmulti_checkrR   Zdict_r
   r
   r   r     s$   
r   strier   c                 C  s   || vrt ||| |< d S d S r   )r   )r,  r(  r@   r
   r
   r   r     s   r   r
  c                 C  s>   | D ]}| |rt| | |}|d u r|  S |  S qd S r   )rZ   r   )r(  r@   rR   outr
   r
   r   r     s   
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?   )owlZrdfZrdfsZxsdxmlbrickZcsvwZdcZdcatZdcmitypeZdctermsZdcamZdoapZfoafZgeoZodrlorgZprofZprovZqbZschemash)ZskosZsosaZssntimeZvannvoidZwgs)r   r   r   r   )rM   rC   r   r  )r   rC   r"  r   r   r#  )r(  r)  r@   rC   r   r)  )r,  r)  r(  r)  r@   rC   r   r   )r(  r)  r@   rC   r   r
  )zrs   
__future__r   loggingr   Zannotationlibr   ImportErrorinspect	functoolsr   pathlibr   typingr   r   r   r   r   r   r   r   r   unicodedatar   urllib.parser   r   Zrdflib.termr   r   r   Zrdflib.graphr   Zrdflib.storer   __all__	getLoggerrp   r  rC   r    rv   r   r	   r   r   r   r"   r!   r$  Zrdflib._type_checkingr   r  r#   r   ZSPLIT_START_CATEGORIESr  r  r   r   r   r   r   Zrdflib.namespace._BRICKr$   Zrdflib.namespace._CSVWr%   Zrdflib.namespace._DCr&   Zrdflib.namespace._DCAMr'   Zrdflib.namespace._DCATr(   Zrdflib.namespace._DCMITYPEr)   Zrdflib.namespace._DCTERMSr*   Zrdflib.namespace._DOAPr+   Zrdflib.namespace._FOAFr,   Zrdflib.namespace._GEOr-   Zrdflib.namespace._ODRL2r.   Zrdflib.namespace._ORGr/   Zrdflib.namespace._OWLr0   Zrdflib.namespace._PROFr1   Zrdflib.namespace._PROVr2   Zrdflib.namespace._QBr3   Zrdflib.namespace._RDFr4   Zrdflib.namespace._RDFSr5   Zrdflib.namespace._SDOr6   Zrdflib.namespace._SHr7   Zrdflib.namespace._SKOSr8   Zrdflib.namespace._SOSAr9   Zrdflib.namespace._SSNr:   Zrdflib.namespace._TIMEr;   Zrdflib.namespace._VANNr<   Zrdflib.namespace._VOIDr=   Zrdflib.namespace._WGSr>   Zrdflib.namespace._XSDr?   r   r   r
   r
   r
   r   <module>   s   F
,
%D%\3   <





	
