
    01ie                      % S r SSKJr  SSKrSSKrSSKJr  / SQrSSKrSSK	r	SSK
r
SSKrSSKJrJr  SSKJrJr  SSKJr  SS	KJrJrJrJr  SS
KJr  SSKJrJr  SSKJr  SSKJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*  SSK+J,r,J-r-J.r.  SSK/J0r0  SSK1r1SSK2r1SSK3J4r4  SSK5J6r6J7r7J8r8J9r9J:r:J;r;  \ (       a  SSK<J=r=  SSK>J?r?J@r@JArAJBrBJCrC  SrD SSKErESrDSrG\R                  " \I5      rJSrKSrL0 rMS\NS'   SrOSS jrP\" S5      rQSS jrRSS  jrS " S! S"\R                  5      rU " S# S$\U\V5      rW " S% S&\W5      rX " S' S(\X5      rY " S) S*\Y5      rZ " S+ S,\Z5      r[SS- jr\ " S. S/\X5      r] " S0 S1\W5      r^SS2 jr_SS3 jr`SS4 jra    SS5 jrbSS6 jrcSS7 jrdSS8 jreSS9 jrfSS: jrgSS; jrhSS< jriSS= jrjSS> jrkSS? jrlSS@ jrmSSA jrnSSB jroSSC jrpSSD jrqSErrSFrs\Y" \sSG-   5      rt\Y" \sSH-   5      ru\Y" \rSI-   5      rv\Y" \rSJ-   5      rw\Y" \rSK-   5      rx\Y" \rSL-   5      ry\Y" \rSM-   5      rz\Y" \rSN-   5      r{\Y" \rSO-   5      r|\Y" \rSP-   5      r}\Y" \rSQ-   5      r~\Y" \rSR-   5      r\Y" \rSS-   5      r\Y" \rST-   5      r\Y" \rSU-   5      r\Y" \rSV-   5      r\Y" SW5      r\Y" \rSX-   5      r\Y" \rSY-   5      r\Y" \rSZ-   5      r\Y" \rS[-   5      r\|\{\z\Y" \rSL-   5      \Y" \rS\-   5      \Y" \rS]-   5      \Y" \rS^-   5      \Y" \rS_-   5      \Y" \rS`-   5      \Y" \rSa-   5      \Y" \rSb-   5      \Y" \rSc-   5      \Y" \rSd-   5      \Y" \rSe-   5      \Y" \rSf-   5      \Y" \rSg-   5      4rSh\NSi'   \|\}\z\{\4rSh\NSj'   \Y" \rSL-   5      \z\{4rSh\NSk'   \~\\4rSh\NSl'   \\4rSh\NSm'   \\-   rSh\NSn'   \So \Sp \GR                  GR                   GR"                  Sq 0rSr\NSs'   \v\t\u\Y" \rSJ-   5      \Y" \rSK-   5      4rSh\NSt'   \)" Su\VSv9r          SSw jr      SSx jr\VSy4\S\z44\Sz \}44\S\|44\4S\|44\S{ \{44\S| \~44\S} \44\S~ \44\6S \44\S \44\GR                  GR                   GR"                  \b\t44\S\44/rS\NS'   \Eb7  \GR7                  \GR                  GR                   GR8                  \a\u445        \" \5      r\\4S 4\\4S 4\V\4\4\\4\4\V\4\4\\4\4/rS\NS'   \" \5      r0 SS_\Y" \rSS-   5      \9_\Y" \rSR-   5      \:_\Y" \rSQ-   5      \8_\Y" \rST-   5      \;_\Y" \rSU-   5      \;_\Y" \rSV-   5      \;_\Y" \rSY-   5      \c_\Y" \rSI-   5      S_\Y" \rSJ-   5      S_\Y" \rSK-   5      S_\Y" \rS-   5      S_\Y" \rSP-   5      \d_\Y" \rSN-   5      \_\Y" \rSO-   5      \4_\Y" \rSa-   5      \4_\Y" \rS^-   5      \4_\Y" \rS`-   5      \4\Y" \rS_-   5      \4\Y" \rS]-   5      \\Y" \rSf-   5      \4\Y" \rSb-   5      \4\Y" \rSc-   5      \\Y" \rSe-   5      \\Y" \rS\-   5      \\Y" \rSg-   5      \\Y" \rSd-   5      \\Y" \rSL-   5      \\Y" \rSM-   5      \\Y" \rSX-   5      \\Y" \rS-   5      S\t\_0ErS\NS'   \Eb  \`\\u'   \t\u4rSh\NS'   O\t4r\Y" \rSP-   5      \g\Y" \rSa-   5      \p\Y" \rS`-   5      \n\Y" \rS_-   5      \q\Y" \rSb-   5      \o\Y" \rS]-   5      \h\Y" \rSc-   5      \j\Y" \rS\-   5      \l\Y" \rSe-   5      \i\Y" \rSf-   5      \f\Y" \rSg-   5      \k\Y" \rSd-   5      \m0rS\NS'   0 rS\NS'   \GRM                  \5        SS jr      SS jr\)" S\!Sv9rSS jrSS jr   S           SS jjr " S S\W5      r\" \5      rS\NS'   \GRM                  \]S\S\YS\^S05              SS jrg! \F a    SrE GNf = f)a  
This module defines the different types of terms. Terms are the kinds of
objects that can appear in a quoted/asserted triple. This includes those
that are core to RDF:

* [Blank Nodes][rdflib.term.BNode] - Blank Nodes
* [URI References][rdflib.term.URIRef] - URI References
* [Literals][rdflib.term.Literal] - Literals (which consist of a literal value, datatype and language tag)

Those that extend the RDF model into N3:

* [`QuotedGraph`][rdflib.graph.QuotedGraph] - Formulae
* [`Variable`][rdflib.term.Variable] - Universal Quantifications (Variables)

And those that are primarily for matching against 'Nodes' in the
underlying Graph:

* REGEX Expressions
* Date Ranges
* Numerical Ranges
    )annotationsN)Fraction)	bind_is_valid_uriNodeIdentifiedNode
IdentifierURIRefBNodeLiteralVariable)	b64decode	b64encode)hexlify	unhexlify)defaultdict)datedatetimetime	timedelta)Decimal)compilesub)GeneratorType)TYPE_CHECKINGAnyCallableDict	GeneratorListOptionalTupleTypeTypeVarUnion)	urldefragurljoinurlparse)uuid4)	long_type   )Durationduration_isoformatparse_datetime
parse_timeparse_xsd_dateparse_xsd_duration)NamespaceManager)AlternativePathInvPathNegatedPathPathSequencePathFTzhttps://rdflib.github.ioz/.well-known/genid/z/.well-known/genid/rdflib/zDict[str, BNode]skolemsz
<>" {}|\^`c                ,    [          H
  nX;   d  M
    g   g)NFT)_invalid_uri_chars)urics     E/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/term.pyr   r   h   s    8       z^[a-zA-Z]+(?:-[a-zA-Z0-9]+)*$c                >    [        [        R                  U 5      5      $ N)bool_lang_tag_regexmatch)tags    r=   _is_valid_langtagrE   r   s    %%c*++r>   c                    [        U [        5      (       a  [        U S5      Sp!O[        U p! U" U5        g! [         a     gf = f)zO
Verify that the provided value can be converted into a Python
unicode object.
decodeutf-8FT)
isinstancebytesgetattrstrUnicodeError)valuecoding_funcparams      r=   _is_valid_unicoderQ   v   sL    
 %$UH5wU %UE   s   5 
AAc                  H    \ rS rSrSrSr\R                  SSS jj5       rSr	g)r      zA Node in the Graph. Nc                    g r@   rT   selfnamespace_managers     r=   n3Node.n3   s    ORr>   r@   rX   zOptional[NamespaceManager]returnrL   )
__name__
__module____qualname____firstlineno____doc__	__slots__abcabstractmethodrY   __static_attributes__rT   r>   r=   r   r      s    IR Rr>   r   c                      \ rS rSrSrS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S jrSS jrSSS jjr\R"                  rSrg)r	      zYSee http://www.w3.org/2002/07/rdf-identifer-terminology/
regarding choice of terminology.rT   c                ,    [         R                  X5      $ r@   )rL   __new__clsrN   s     r=   ri   Identifier.__new__   s    {{3&&r>   c                $    U R                  U5      $ )zFA "semantic"/interpreted equality function,
by default, same as __eq____eq__rW   others     r=   eqIdentifier.eq        {{5!!r>   c                $    U R                  U5      $ )zGA "semantic"/interpreted not equal function,
by default, same as __ne__)__ne__rp   s     r=   neqIdentifier.neq   rt   r>   c                .    U R                  U5      (       + $ r@   rn   rp   s     r=   rv   Identifier.__ne__   s    ;;u%%%r>   c                `    [        U 5      [        U5      L a  [        U 5      [        U5      :H  $ g)a"  Equality for Nodes.

```python
>>> BNode("foo")==None
False
>>> BNode("foo")==URIRef("foo")
False
>>> URIRef("foo")==BNode("foo")
False
>>> BNode("foo")!=URIRef("foo")
True
>>> URIRef("foo")!=BNode("foo")
True
>>> Variable('a')!=URIRef('a')
True
>>> Variable('a')!=Variable('a')
False

```
F)typerL   rp   s     r=   ro   Identifier.__eq__   s*    , :e$t9E
**r>   c                    Uc  g[        U 5      [        U5      L a  [        U 5      [        U5      :  $ [        U[        5      (       a%  [        [        U 5         [        [        U5         :  $ [
        $ )zThis implements ordering for Nodes.

This tries to implement this:
http://www.w3.org/TR/sparql11-query/#modOrderBy

Variables are not included in the SPARQL list, but
they are greater than BNodes and smaller than everything else
Tr|   rL   rI   r   	_ORDERINGNotImplementedrp   s     r=   __gt__Identifier.__gt__   s_     =$Z4;&t9s5z))t$$T$Z(9T%[+AAAr>   c                    Uc  g[        U 5      [        U5      L a  [        U 5      [        U5      :  $ [        U[        5      (       a%  [        [        U 5         [        [        U5         :  $ [
        $ NFr   rp   s     r=   __lt__Identifier.__lt__   s]    =$Z4;&t9s5z))t$$T$Z(9T%[+AAAr>   c                <    U R                  U5      nU(       a  gX:H  $ NT)r   rW   rq   rs      r=   __le__Identifier.__le__       KK}r>   c                <    U R                  U5      nU(       a  gX:H  $ r   )r   r   s      r=   __ge__Identifier.__ge__   r   r>   c                H    [        U 5      R                  [        U5      5      $ r@   )rL   
startswith)rW   prefixstartends       r=   r   Identifier.startswith   s    4y##CK00r>   NrN   rL   rq   r   r\   rA   )..)r   rL   r\   rA   )r]   r^   r_   r`   ra   rb   ri   rr   rw   rv   ro   r   r   r   r   r   rL   __hash__re   rT   r>   r=   r	   r	      sK    ( I'"
"
&6$1 ||Hr>   r	   c                  >    \ rS rSrSrSrSS jrS	S
S jjrSS jrSr	g)r      z
An abstract class, primarily defined to identify Nodes that are not Literals.

The name "Identified Node" is not explicitly defined in the RDF specification, but can be drawn from this section: https://www.w3.org/TR/rdf-concepts/#section-URI-Vocabulary
rT   c                    [        U 5      4$ r@   rL   rW   s    r=   __getnewargs__IdentifiedNode.__getnewargs__   s    D	|r>   Nc                    [        5       er@   )NotImplementedErrorrV   s     r=   rY   IdentifiedNode.n3  s    !##r>   c                    [        U 5      $ r@   r   r   s    r=   toPythonIdentifiedNode.toPython  s    4yr>   )r\   z
Tuple[str]r@   r[   r\   rL   )
r]   r^   r_   r`   ra   rb   r   rY   r   re   rT   r>   r=   r   r      s     I$r>   r   c                      \ rS rSr% SrSrS\S'   S\S'   S\S	'   S
\S'   SSS jjrSSS jjrSS 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rg)r
   i
  a  [RDF 1.1's IRI Section](https://www.w3.org/TR/rdf11-concepts/#section-IRIs)

!!! info "Terminology"
    Documentation on RDF outside of RDFLib uses the term IRI or URI whereas this class is called URIRef. This is because it was made when the first version of the RDF specification was current, and it used the term *URIRef*, see [RDF 1.0 URIRef](http://www.w3.org/TR/rdf-concepts/#section-Graph-URIref)

An IRI (Internationalized Resource Identifier) within an RDF graph is a Unicode string that conforms to the syntax defined in RFC 3987.

IRIs in the RDF abstract syntax MUST be absolute, and MAY contain a fragment identifier.

IRIs are a generalization of URIs [RFC3986] that permits a wider range of Unicode characters.
rT   z8Callable[[URIRef, Union[URIRef, Path]], AlternativePath]__or__zCallable[[URIRef], InvPath]
__invert__zCallable[[URIRef], NegatedPath]__neg__z5Callable[[URIRef, Union[URIRef, Path]], SequencePath]__truediv__Nc                P   Ub=  UR                  S5      n[        X!SS9nU(       a  UR                  S5      (       d  US-  n[        U5      (       d  [        R	                  U S35         [
        R                  X5      nU$ ! [         a    [
        R                  XS5      n U$ f = f)N#r+   )allow_fragmentszE does not look like a valid URI, trying to serialize this will break.rH   )endswithr'   r   loggerwarningrL   ri   UnicodeDecodeError)rk   rN   baseends_in_hashrts        r=   ri   URIRef.__new__  s     >>#.LD;E~~c**SLEU##NN'^_	2S(B 	 " 	2S1B		2s   *B  B%$B%c                |    [        U 5      (       d  [        SU  S35      eU(       a  UR                  U 5      $ SU  S3$ )zThis will do a limited check for valid URIs,
essentially just making sure that the string includes no illegal
characters (`<, >, ", {, }, |, \, `, ^`)

Args:
    namespace_manager: if not None, will be used to make up a prefixed name
"zk" does not look like a valid URI, I cannot serialize this as N3/Turtle. Perhaps you wanted to urlencode it?<>)r   	ExceptionnormalizeUrirV   s     r=   rY   	URIRef.n33  sS     T""D6  E  F  $11$77tfA;r>   c                B    SU ;   a  [        U 5      u  p[        U5      $ U $ )Nr   )r&   r
   )rW   urlfrags      r=   defragURIRef.defragF  s#    $;!$IC#;Kr>   c                ,    [        U 5      R                  $ )zReturn the URL Fragment

```python
>>> URIRef("http://example.com/some/path/#some-fragment").fragment
'some-fragment'
>>> URIRef("http://example.com/some/path/").fragment
''

```
)r(   fragmentr   s    r=   r   URIRef.fragmentM  s     ~&&&r>   c                &    [         [        U 5      44$ r@   )r
   rL   r   s    r=   
__reduce__URIRef.__reduce__[  s    T%%r>   c                    U R                   [        L a  SnOU R                   R                  nU S[        R	                  U 5       S3$ )Nzrdflib.term.URIRef())	__class__r
   r]   rL   __repr__rW   clsNames     r=   r   URIRef.__repr__^  s?    >>V#*Gnn--G!CLL./q11r>   c                <    U R                  [        U 5      U-   5      $ r@   r   rL   rp   s     r=   __add__URIRef.__add__f      ~~c$i%/00r>   c                <    U R                  U[        U 5      -   5      $ r@   r   rp   s     r=   __radd__URIRef.__radd__i  s    ~~ec$i/00r>   c                <    U R                  [        U 5      U-  5      $ r@   r   rp   s     r=   __mod__URIRef.__mod__l  r   r>   c                (   [        U [        5      (       a/  [        U  5      n[        UR                  [        [        5      S S9$ [        U [        5      (       a+  U  nU[        ;   a	  [        U   $ [        5       nU[        U'   U$ [        SU  S35      e)zCreate a Blank Node from a skolem URI, in accordance
with http://www.w3.org/TR/rdf11-concepts/#section-skolemization.
This function accepts only rdflib type skolemization, to provide
a round-tripping within the system.

Added in version 4.0
NrN   r   z> is not a skolem URI)
rI   RDFLibGenidr(   r   pathlenrdflib_skolem_genidGenidr8   r   )rW   
parsed_uribnode_idretvals       r=   de_skolemizeURIRef.de_skolemizeo  s     dK((!TF,Jzs3F/G/IJKKe$$H7"x(($*!av%:;<<r>   r@   )rN   rL   r   Optional[str]r[   )r\   r
   r   )r\   zTuple[Type[URIRef], Tuple[str]])r\   r   )r]   r^   r_   r`   ra   rb   __annotations__ri   rY   r   propertyr   r   r   r   r   r   r   re   rT   r>   r=   r
   r
   
  sg    
 IDD++,,FF*& ' '&2111=r>   r
   c                  ,    \ rS rSrSr\SS j5       rSrg)r   i  rT   c                    [        U [        5      (       d  [        U 5      n [        U 5      nUR                  R	                  [
        5      nUS:w  a  gg)Nr   FT)rI   rL   r(   r   rfindskolem_genidr;   r   gen_ids      r=   _is_external_skolemGenid._is_external_skolem  sB    #s##c(Cc]
&&|4Q;r>   Nr;   r   r\   rA   )r]   r^   r_   r`   rb   staticmethodr   re   rT   r>   r=   r   r     s    I r>   r   c                  ,    \ rS rSrSr\SS j5       rSrg)r   i  rT   c                   [        U [        5      (       d  [        U 5      n [        U 5      nUR                  S:w  d   UR                  S:w  d  UR
                  S:w  a  gUR                  R                  [        5      nUS:w  a  gg)N Fr   T)	rI   rL   r(   paramsqueryr   r   r   r   r   s      r=   _is_rdflib_skolemRDFLibGenid._is_rdflib_skolem  sp    #s##c(Cc]
#2%""b(&&':;Q;r>   Nr   )r]   r^   r_   r`   rb   r   r   re   rT   r>   r=   r   r     s    I r>   r   c                     g)NNrT   rT   r>   r=   
_unique_idr     s     r>   c                      \ rS rSrSrSrSS\" 5       4     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rg)r   i  a3  
RDF 1.1's Blank Nodes Section: https://www.w3.org/TR/rdf11-concepts/#section-blank-nodes

Blank Nodes are local identifiers for unnamed nodes in RDF graphs that are used in
some concrete RDF syntaxes or RDF store implementations. They are always locally
scoped to the file or RDF store, and are not persistent or portable identifiers for
blank nodes. The identifiers for Blank Nodes are not part of the RDF abstract
syntax, but are entirely dependent on particular concrete syntax or implementation
(such as Turtle, JSON-LD).

---

RDFLib's `BNode` class makes unique IDs for all the Blank Nodes in a Graph but you
should *never* expect, or reply on, BNodes' IDs to match across graphs, or even for
multiple copies of the same graph, if they are regenerated from some non-RDFLib
source, such as loading from RDF data.
rT   Nc                    Uc[  Ub>  [        U5      (       a  U" 5       nOUn[        U[        5      (       a  [        U5      nOUnO[	        5       R
                  nX5 -   nO [        R                  X5      $ )z5
# only store implementations should pass in a value
)callablerI   r   nextr)   hexr	   ri   )rk   rN   _sn_gen_prefix	sn_resultnode_ids         r=   ri   BNode.__new__  sr     = "G$$7>yI 'Ii77"9oG'G'++ 	*E  !!#--r>   c                    SU -   $ )Nz_:rT   rV   s     r=   rY   BNode.n3  s    d{r>   c                &    [         [        U 5      44$ r@   )r   rL   r   s    r=   r   BNode.__reduce__  s    D	|$$r>   c                    U R                   [        L a  SnOU R                   R                  nU S[        R	                  U 5       S3$ )Nzrdflib.term.BNoder   r   )r   r   r]   rL   r   r   s     r=   r   BNode.__repr__  s?    >>U")Gnn--G!CLL./q11r>   c                j    Uc  [         nUc  [        nU[        U 5      -   n[        [	        X5      5      $ )zCreate a URIRef "skolem" representation of the BNode, in accordance
with http://www.w3.org/TR/rdf11-concepts/#section-skolemization

Added in version 4.0
)_SKOLEM_DEFAULT_AUTHORITYr   rL   r
   r'   )rW   	authoritybasepathskolems       r=   	skolemizeBNode.skolemize  s8     1I*HCI%gi011r>   )rN   r   r  z-Optional[Union[Callable[[], str], Generator]]r  rL   r@   r[   )r\   zTuple[Type[BNode], Tuple[str]]r   NN)r  r   r  r   r\   r
   )r]   r^   r_   r`   ra   rb   r   ri   rY   r   r   r  re   rT   r>   r=   r   r     su    $ I  $AE!|	#.#. ?#. 	#.J%2 JN2&29F2	2 2r>   r   c                     \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   Sr   S,       S-S jjrS.S jr\	S/S j5       r
\	S0S j5       r\	S1S j5       r\	S2S j5       r  S3S jrS4S jrS5S jrS6S jrS6S jrS7S jrS.S jrS.S jrS.S jrS.S jrS8S jrS8S jrS8S jrS8S  jrS8S! jrS9S" jrS8S# jrS8S$ jrS8S% jr S:S;S& jjr!  S<     S=S' jjr"S>S( jr#S>S) jr$S0S* jr%S+r&g)?r   i  ad  

RDF 1.1's Literals Section: http://www.w3.org/TR/rdf-concepts/#section-Graph-Literal

Literals are used for values such as strings, numbers, and dates.

A literal in an RDF graph consists of two or three elements:

* a lexical form, being a Unicode string, which SHOULD be in Normal Form C
* a datatype IRI, being an IRI identifying a datatype that determines how the lexical form maps to a literal value, and
* if and only if the datatype IRI is `http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`, a non-empty language tag. The language tag MUST be well-formed according to section 2.2.9 of `Tags for identifying languages <http://tools.ietf.org/html/bcp47>`_.

A literal is a language-tagged string if the third element is present. Lexical representations of language tags MAY be converted to lower case. The value space of language tags is always in lower case.

---

For valid XSD datatypes, the lexical form is optionally normalized
at construction time. Default behaviour is set by `rdflib.NORMALIZE_LITERALS`
and can be overridden by the normalize parameter to `__new__`

Equality and hashing of Literals are done based on the lexical form, i.e.:

```python
>>> from rdflib.namespace import XSD
>>> Literal('01') != Literal('1')  # clear - strings differ
True

```

but with data-type they get normalized:

```python
>>> Literal('01', datatype=XSD.integer) != Literal('1', datatype=XSD.integer)
False

```

unless disabled:

```python
>>> Literal('01', datatype=XSD.integer, normalize=False) != Literal('1', datatype=XSD.integer)
True

```

Value based comparison is possible:

```python
>>> Literal('01', datatype=XSD.integer).eq(Literal('1', datatype=XSD.float))
True

```

The eq method also provides limited support for basic python types:

```python
>>> Literal(1).eq(1) # fine - int compatible with xsd:integer
True
>>> Literal('a').eq('b') # fine - str compatible with plain-lit
False
>>> Literal('a', datatype=XSD.string).eq('a') # fine - str compatible with xsd:string
True
>>> Literal('a').eq(1) # not fine, int incompatible with plain-lit
NotImplemented

```

Greater-than/less-than ordering comparisons are also done in value
space, when compatible datatypes are used.  Incompatible datatypes
are ordered by DT, or by lang-tag.  For other nodes the ordering
is None < BNode < URIRef < Literal

Any comparison with non-rdflib Node are "NotImplemented"
In PY3 this is an error.

```python
>>> from rdflib import Literal, XSD
>>> lit2006 = Literal('2006-01-01',datatype=XSD.date)
>>> lit2006.toPython()
datetime.date(2006, 1, 1)
>>> lit2006 < Literal('2007-01-01',datatype=XSD.date)
True
>>> Literal(datetime.utcnow()).datatype
rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTime')
>>> Literal(1) > Literal(2) # by value
False
>>> Literal(1) > Literal(2.0) # by value
False
>>> Literal('1') > Literal(1) # by DT
True
>>> Literal('1') < Literal('1') # by lexical form
False
>>> Literal('a', lang='en') > Literal('a', lang='fr') # by lang-tag
False
>>> Literal(1) > URIRef('foo') # by node-type
True

```

The > < operators will eat this NotImplemented and throw a TypeError (py3k):

```python
>>> Literal(1).__gt__(2.0)
NotImplemented

```
r   _valuer   	_languageOptional[URIRef]	_datatypeOptional[bool]
_ill_typed)r  r  r  r  Nc                   US:X  a  SnUb  UO[         R                  nUb  Ub  [        S5      eUb(  [        U5      (       d  [	        S[        U5       S35      eUb  [        U5      nSnSn[        U[        5      (       a>  U=(       d    UR                  nUb  [        X5      nGOUR                  nUR                  nO[        U[
        5      (       d  [        U[        5      (       a  [        X5      nUbG  U[        ;   a=  [        U5      n[        R!                  U["        5      nU" X5      n	U=(       d    U	(       + nUb)  U(       a"  [%        XS5      u  pU
b  ['        U
5      (       a  U
nOHUn[%        X5      u  pUc  SO
[        U5      n[         R(                  R+                  X;5      nU
b  U
nUb  Sn[        U[        5      (       a  UR-                  S5      nU[.        [0        4;   a  [3        U5      nU[0        4;   a  [5        U5      n [
        R7                  X5      nX,l        X<l        X\l        Xll         U$ ! [8         a    [
        R7                  XS5      n N<f = f)zCreate a new Literal instance.r   NzmA Literal can only have one of lang or datatype, per http://www.w3.org/TR/rdf-concepts/#section-Graph-Literal'z' is not a valid language tag!rH   )!rdflibNORMALIZE_LITERALS	TypeErrorrE   
ValueErrorrL   r
   rI   r   language_castLexicalToPythondatatyperN   rJ   _toPythonMapping_check_well_formed_typesget_well_formed_by_value_castPythonToLiteralrQ   util	_coalescerG   _XSD_NORMALISED_STRING
_XSD_TOKEN_normalise_XSD_STRING_strip_and_collapse_whitespaceri   r   r  r  r  r  )rk   lexical_or_valuelangr(  	normalizerN   	ill_typeddt_uricheckerwell_formedr  r  insts                r=   ri   Literal.__new__  sV    2:D!*!6IF<U<U	 4O 
 $5d$;$;qT+IJKKh'H$(	&00 4+44D#,-=H+44(..(#..*=Mu2U2U ))9DE#4D(D "(!1266v?TU%&6>%:k/	 Y$8$I!%*;F*C*C'-$ %E 45E PF ) 1vi7HI{{,,XAH!#) #&../66w?.
;;45EF
}$=>NO	?;;s5D !# " 	?;;sg>D	?s   H: : IIc                r    U R                   b)  [        U R                   U R                  U R                  S9$ U $ )a  
Returns a new literal with a normalised lexical representation
of this literal

```python
>>> from rdflib import XSD
>>> Literal("01", datatype=XSD.integer, normalize=False).normalize()
rdflib.term.Literal('1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

```

Illegal lexical forms for the datatype given are simply passed on

```python
>>> Literal("a", datatype=XSD.integer, normalize=False)
rdflib.term.Literal('a', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

```
)r(  r5  )rN   r   r(  r&  r   s    r=   r6  Literal.normalize  s.    * ::!4::DMMRRKr>   c                    U R                   $ )aQ  
For `recognized datatype IRIs
<https://www.w3.org/TR/rdf11-concepts/#dfn-recognized-datatype-iris>`_,
this value will be `True` if the literal is ill formed, otherwise it
will be `False`. `Literal.value` (i.e. the `literal value <https://www.w3.org/TR/rdf11-concepts/#dfn-literal-value>`_) should always be defined if this property is `False`, but should not be considered reliable if this property is `True`.

If the literal's datatype is `None` or not in the set of `recognized datatype IRIs
<https://www.w3.org/TR/rdf11-concepts/#dfn-recognized-datatype-iris>`_ this value will be `None`.
)r  r   s    r=   r7  Literal.ill_typed  s     r>   c                    U R                   $ r@   )r  r   s    r=   rN   Literal.value   s    {{r>   c                    U R                   $ r@   )r  r   s    r=   r&  Literal.language      ~~r>   c                    U R                   $ r@   )r  r   s    r=   r(  Literal.datatype  rE  r>   c                R    [         [        U 5      U R                  U R                  44$ r@   )r   rL   r&  r(  r   s    r=   r   Literal.__reduce__  s'     Yt}}5
 	
r>   c                B    S [        U R                  U R                  S94$ )N)r&  r(  )dictr&  r(  r   s    r=   __getstate__Literal.__getstate__  s    dDMMDMMJKKr>   c                4    Uu  p#US   U l         US   U l        g )Nr&  r(  )r  r  )rW   arg_ds       r=   __setstate__Literal.__setstate__  s    ::r>   c                   Uc  U $ [        U[        5      (       d  [        U5      nU R                  [        [        4;   aK  UR                  [
        ;   a7  U R                  5       nUR                  5       nX#-   n[        X@R                  S9$ U R                  [        :X  a{  UR                  [
        ;   ag  U R                  5       nUR                  5       n[        R                  " [        SSS5      U5      U-   n[        UR                  5       U R                  S9$ U R                  [        ;   a  UR                  [        ;  dj  U R                  [        ;  a  UR                  [        ;   dB  U R                  [
        ;   ae  UR                  [
        ;  d  U R                  UR                  :w  a7  [        S[        UR                  5       S[        U R                  5       35      eU R                  UR                  :X  a>  [        U R                  5       UR                  5       -   U R                  U R                  S9$ U R                  [         ;   a  UR                  [         ;   ar  [        [#        [%        [#        U R                  5       5      [#        UR                  5       5      -   S5      S R'                  S5      R'                  S	5      5      [(        S9$  [        R+                  X5      nU R                  [.        ;   a  U R                  n	O[0        n	[        XR                  U	S9$ ! [         a$    [        U R,                  5      [        U5      -   n Nhf = f)
a   
```python
>>> from rdflib.namespace import XSD
>>> Literal(1) + 1
rdflib.term.Literal('2', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))
>>> Literal("1") + "1"
rdflib.term.Literal('11')

# Handling dateTime/date/time based operations in Literals
>>> a = Literal('2006-01-01T20:50:00', datatype=XSD.dateTime)
>>> b = Literal('P31D', datatype=XSD.duration)
>>> (a + b)
rdflib.term.Literal('2006-02-01T20:50:00', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))
>>> from rdflib.namespace import XSD
>>> a = Literal('2006-07-01T20:52:00', datatype=XSD.dateTime)
>>> b = Literal('P122DT15H58M', datatype=XSD.duration)
>>> (a + b)
rdflib.term.Literal('2006-11-01T12:50:00', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))

```
r(    r+   z!Cannot add a Literal of datatype z to a Literal of datatype    f0.)rI   r   r(  _XSD_DATETIME	_XSD_DATE_TIME_DELTA_TYPESr   	_XSD_TIMEr   combiner   r   _ALL_DATE_AND_TIME_TYPESr$  rL   r&  _NUMERIC_LITERAL_TYPESr   roundrstrip_XSD_DECIMALr   rN   _STRING_LITERAL_TYPES_XSD_STRING)
rW   valdate1duration
differenceselfvvalvsdtsnew_datatypes
             r=   r   Literal.__add__  s   0 ;K #w''#,C MMmY77 11+/==?E36<<>H)J:>> ]]i'CLL<M,M--/E/2||~D""4a#3U;dBC388:>>
 !99LL(@@ %==LL$<< !22\\)::5 3C4E3FF`adeiereras`tu 
 ==CLL(#,,.0$--$--  MM33 66WT]]_58OOQSTUVW__f &	 	/KK*
 }} 55#}}  +1mmlCC  /

Oc#h./s   L& &+MMc                l   Uc  U $ [        U[        5      (       d  [        U5      n[        U S5      (       d  [        S5      e[        US5      (       d  [        S5      eU R                  [
        [        4;   aK  UR                  [        ;   a7  U R                  5       nUR                  5       nX#-
  n[        X@R                  S9$ U R                  [        :X  a{  UR                  [        ;   ag  U R                  5       nUR                  5       n[        R                  " [        SSS5      U5      U-
  n[        UR                  5       U R                  S9$ U R                  UR                  :X  a  U R                  [        :X  a  [        R                  " [        R                  " 5       U R                  5       5      n[        R                  " [        R                  " 5       UR                  5       5      n[        Xx-
  [        S9$ [        U R                  5       UR                  5       -
  U R                   U R                  [
        [        [        4;   a  [        S9$ U R                  S9$ U R                  ["        ;   a  UR                  ["        ;   ar  [        [%        ['        [%        U R                  5       5      [%        UR                  5       5      -
  S5      S R)                  S	5      R)                  S
5      5      [*        S9$ [        S[-        UR                  5       S[-        U R                  5       35      e)a  Implements subtraction between Literals or between a Literal and a Python object.

Example:
    ```python
    from rdflib.namespace import XSD

    # Basic numeric subtraction
    Literal(2) - 1
    # rdflib.term.Literal('1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    Literal(1.1) - 1.0
    # rdflib.term.Literal('0.10000000000000009', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#double'))

    Literal(1.1) - 1
    # rdflib.term.Literal('0.1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#decimal'))

    Literal(1.1, datatype=XSD.float) - Literal(1.0, datatype=XSD.float)
    # rdflib.term.Literal('0.10000000000000009', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#float'))

    # This will raise a TypeError
    Literal("1.1") - 1.0
    # TypeError: Not a number; rdflib.term.Literal('1.1')

    Literal(1.1, datatype=XSD.integer) - Literal(1.0, datatype=XSD.integer)
    # rdflib.term.Literal('0.10000000000000009', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # Handling dateTime/date/time based operations in Literals
    a = Literal('2006-01-01T20:50:00', datatype=XSD.dateTime)
    b = Literal('2006-02-01T20:50:00', datatype=XSD.dateTime)
    (b - a)
    # rdflib.term.Literal('P31D', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#duration'))

    a = Literal('2006-07-01T20:52:00', datatype=XSD.dateTime)
    b = Literal('2006-11-01T12:50:00', datatype=XSD.dateTime)
    (a - b)
    # rdflib.term.Literal('-P122DT15H58M', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#duration'))
    (b - a)
    # rdflib.term.Literal('P122DT15H58M', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#duration'))
    ```
r(  zCMinuend Literal must have Numeric, Date, Datetime or Time datatype.zFSubtrahend Literal must have Numeric, Date, Datetime or Time datatype.rU  rV  r+   rW  rX  rY  rZ  z&Cannot subtract a Literal of datatype z from a Literal of datatype )rI   r   rK   r$  r(  r[  r\  r]  r   r^  r   r_  r   r   today_XSD_DURATIONr&  ra  r   rb  rc  rd  rL   )	rW   rg  rh  ri  rj  rk  rl  rm  vdts	            r=   __sub__Literal.__sub__  s   T ;K #w''#,CtZ((U  j))X 
 MMmY77 11+/==?E36<<>H)J:>> ]]i'CLL<M,M--/E/2||~D""4a#3U;dBC388:>> ==CLL(}}	)&&tzz|T]]_E&&tzz|S\\^Dsy=AAMMOclln4MM  ==]Iy,QQ &	  "]]  MM33 66WT]]_58OOQSTUVW__f &	 	 8S\\9J8KKghklplylyhzg{| r>   c                b    U R                   b  [        U R                   5      $ [        U 5      S:g  $ )zXDetermines the truth value of the Literal.

Used for if statements, bool(literal), etc.
r   )rN   rA   r   r   s    r=   __bool__Literal.__bool__  s+    
 ::!

##4yA~r>   c                    [        U R                  [        [        [        45      (       a#  [        U R                  R                  5       5      $ [        SU < 35      e)a  Implements unary negation for Literals with numeric values.

Example:
    ```python
    # Negating an integer Literal
    -Literal(1)
    # rdflib.term.Literal('-1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # Negating a float Literal
    -Literal(10.5)
    # rdflib.term.Literal('-10.5', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#double'))

    # Using a string with a datatype
    from rdflib.namespace import XSD
    -Literal("1", datatype=XSD.integer)
    # rdflib.term.Literal('-1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # This will raise a TypeError
    -Literal("1")
    # TypeError: Not a number; rdflib.term.Literal('1')
    ```
Not a number; )rI   rN   intr*   floatr   r   r$  r   s    r=   r   Literal.__neg__  sF    0 djj3	5"9::4::--/00nTH566r>   c                    [        U R                  [        [        [        45      (       a#  [        U R                  R                  5       5      $ [        SU < 35      e)a  Implements unary plus operation for Literals with numeric values.

Example:
    ```python
    # Applying unary plus to an integer Literal
    +Literal(1)
    # rdflib.term.Literal('1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # Applying unary plus to a negative integer Literal
    +Literal(-1)
    # rdflib.term.Literal('-1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # Using a string with a datatype
    from rdflib.namespace import XSD
    +Literal("-1", datatype=XSD.integer)
    # rdflib.term.Literal('-1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # This will raise a TypeError
    +Literal("1")
    # TypeError: Not a number; rdflib.term.Literal('1')
    ```
r{  )rI   rN   r|  r*   r}  r   __pos__r$  r   s    r=   r  Literal.__pos__  sF    . djj3	5"9::4::--/00nTH566r>   c                    [        U R                  [        [        [        45      (       a#  [        U R                  R                  5       5      $ [        SU < 35      e)ag  Implements absolute value operation for Literals with numeric values.

Example:
    ```python
    # Absolute value of a negative integer Literal
    abs(Literal(-1))
    # rdflib.term.Literal('1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # Using a string with a datatype
    from rdflib.namespace import XSD
    abs(Literal("-1", datatype=XSD.integer))
    # rdflib.term.Literal('1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # This will raise a TypeError
    abs(Literal("1"))
    # TypeError: Not a number; rdflib.term.Literal('1')
    ```
r{  )rI   rN   r|  r*   r}  r   __abs__r$  r   s    r=   r  Literal.__abs__:  sF    & djj3	5"9::4::--/00nTH566r>   c                    [        U R                  [        [        [        45      (       a#  [        U R                  R                  5       5      $ [        SU < 35      e)a[  Implements bitwise NOT operation for Literals with numeric values.

Example:
    ```python
    # Bitwise NOT of a negative integer Literal
    ~(Literal(-1))
    # rdflib.term.Literal('0', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # Using a string with a datatype
    from rdflib.namespace import XSD
    ~(Literal("-1", datatype=XSD.integer))
    # rdflib.term.Literal('0', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

    # This will raise a TypeError
    ~(Literal("1"))
    # TypeError: Not a number; rdflib.term.Literal('1')
    ```
r{  )rI   rN   r|  r*   r}  r   r   r$  r   s    r=   r   Literal.__invert__R  sF    & djj3	5"9::4::00233nTH566r>   c                P   Uc  g[        U[        5      (       Gaa  U R                  [        ;   ai  UR                  [        ;   aU  U R                  (       dD  UR                  (       d3  U R
                  b&  UR
                  b  U R
                  UR
                  :  $ [        R                  R                  U R                  [        S9n[        R                  R                  UR                  [        S9nX#:w  a  [        R                  (       a  [        $ X#:  $ U R                  UR                  :w  a=  U R                  (       d  gUR                  (       d  gU R                  UR                  :  $ U R
                  b  UR
                  bx  [        U R
                  5      [        ;   aA  [        [        U R
                  5         nU" U R
                  5      U" UR
                  5      :  $  U R
                  UR
                  :  $ [!        U 5      [!        U5      :w  a  [!        U 5      [!        U5      :  $ U R                  UR                  :w  a5  U R                  c  gUR                  c  gU R                  UR                  :  $ g[        U["        5      (       a  g[        $ ! [         a     Nf = f)a:  Implements the greater-than comparison for Literals.

This is the base method for ordering comparisons - other comparison methods delegate here.

Implements the ordering rules described in http://www.w3.org/TR/sparql11-query/#modOrderBy

In summary:
1. Literals with compatible data-types are ordered in value space
2. Incompatible datatypes are ordered by their datatype URIs
3. Literals with language tags are ordered by their language tags
4. Plain literals come before xsd:string literals
5. In the node order: None < BNode < URIRef < Literal

Example:
    ```python
    from rdflib import XSD
    from decimal import Decimal

    # Comparing numeric literals in value space
    Literal(1) > Literal(2)  # int/int
    # False

    Literal(2.0) > Literal(1)  # double/int
    # True

    Literal(Decimal("3.3")) > Literal(2.0)  # decimal/double
    # True

    Literal(Decimal("3.3")) < Literal(4.0)  # decimal/double
    # True

    # Comparing string literals
    Literal('b') > Literal('a')  # plain lit/plain lit
    # True

    Literal('b') > Literal('a', datatype=XSD.string)  # plain lit/xsd:str
    # True

    # Incompatible datatypes ordered by DT
    Literal(1) > Literal("2")  # int>string
    # False

    # Langtagged literals ordered by lang tag
    Literal("a", lang="en") > Literal("a", lang="fr")
    # False
    ```
TdefaultF)rI   r   r(  ra  r7  rN   r"  r.  r/  rf  DAWG_LITERAL_COLLATIONr   r&  r|   _TOTAL_ORDER_CASTERSr$  rL   r   )rW   rq   dtselfdtothercasters        r=   r   Literal.__gt__k  s   ` =eW%%
 MM%;;*@@..5??ZZ+0GzzEKK// [[**4==+*NFkk++ENNK+PG 00))!++}}.}} ==5>>99zz%%++*A

#';;1$tzz2BCF!$**-u{{0CCC::33 4yCJ&4y3u:-- }}.==( ^^+==5>>99t$$!!+ ! s   $J 
J%$J%c                    Uc  g[        U[        5      (       a4   U R                  U5      (       + =(       a    U R                  U5      (       + $ [        U[        5      (       a  g[
        $ ! [         a	    [
        s $ f = fr   )rI   r   r   rr   r$  r   r   rp   s     r=   r   Literal.__lt__  sm    =eW%%&;;u--Ddggen2DD eT""  &%%&s   2A* *A=<A=c                    U R                  U5      nU(       a  g U R                  U5      $ ! [         a	    [        s $ f = f)zLess than or equal operator for Literals.

Example:
    ```python
    from rdflib.namespace import XSD
    Literal('2007-01-01T10:00:00', datatype=XSD.dateTime) <= Literal('2007-01-01T10:00:00', datatype=XSD.dateTime)
    # True
    ```
T)r   rr   r$  r   r   s      r=   r   Literal.__le__  s@     KK	"775>! 	"!!	"   , ??c                    U R                  U5      nU(       a  g U R                  U5      $ ! [         a	    [        s $ f = fr   )r   rr   r$  r   r   s      r=   r   Literal.__ge__  s>    KK	"775>! 	"!!	"r  c                   [        U[        5      (       a  U R                  bQ  UR                  bD  U R                  [        ;  d  UR                  [        ;  a  U R                  UR                  :w  a  ggU R                  [        :X  a6  UR                  (       d%  UR                  [        :X  a  U R                  (       d  gU R
                  =(       d    SR                  5       UR
                  =(       d    SR                  5       :w  a  gg)zVHelper method to decide which things are meaningful to rich-compare with this literal.Fr   T)rI   r   r(  XSDToPythonrf  r&  lowerrp   s     r=   _comparable_toLiteral._comparable_to  s    eW%%}}(U^^-G MM4~~[8 }}6$  4U^^NNk1$--  MM'R..0U^^5Ir4P4P4RR r>   c                    [         R                  U 5      nU R                  (       a&  U[        U R                  R	                  5       5      -  nU R
                  b  U[        U R
                  5      -  nU$ )a  Hash function for Literals to enable their use as dictionary keys.

Example:
    ```python
    from rdflib.namespace import XSD
    a = {Literal('1', datatype=XSD.integer):'one'}
    Literal('1', datatype=XSD.double) in a
    # False
    ```

Notes:
    "Called for the key object for dictionary operations,
    and by the built-in function hash(). Should return
    a 32-bit integer usable as a hash value for
    dictionary operations. The only required property
    is that objects which compare equal have the same
    hash value; it is advised to somehow mix together
    (e.g., using exclusive or) the hash values for the
    components of the object that also play a part in
    comparison of objects." -- 3.4.1 Basic customization (Python)

    "Two literals are equal if and only if all of the following hold:
    * The strings of the two lexical forms compare equal, character by character.
    * Either both or neither have language tags.
    * The language tags, if any, compare equal.
    * Either both or neither have datatype URIs.
    * The two datatype URIs, if any, compare equal, character by character."
    -- 6.5.1 Literal Equality (RDF: Concepts and Abstract Syntax)
)rL   r   r  hashr  r  )rW   ress     r=   r   Literal.__hash__!  sW    > ll4 >>4,,.//C>>%4''C
r>   c                n   XL a  gUc  g[        U[        5      (       a  U R                  UR                  :H  =(       aw    U R                  (       a  U R                  R	                  5       OSUR                  (       a  UR                  R	                  5       OS:H  =(       a    [
        R                  X5      $ g)a{  Equality operator for Literals.

Literals are only equal to other literals.

Notes:
    "Two literals are equal if and only if all of the following hold:
    * The strings of the two lexical forms compare equal, character by character.
    * Either both or neither have language tags.
    * The language tags, if any, compare equal.
    * Either both or neither have datatype URIs.
    * The two datatype URIs, if any, compare equal, character by character."
    -- 6.5.1 Literal Equality (RDF: Concepts and Abstract Syntax)

Example:
    ```python
    Literal("1", datatype=URIRef("foo")) == Literal("1", datatype=URIRef("foo"))
    # True
    Literal("1", datatype=URIRef("foo")) == Literal("1", datatype=URIRef("foo2"))
    # False

    Literal("1", datatype=URIRef("foo")) == Literal("2", datatype=URIRef("foo"))
    # False
    Literal("1", datatype=URIRef("foo")) == "asdf"
    # False

    from rdflib import XSD
    Literal('2007-01-01', datatype=XSD.date) == Literal('2007-01-01', datatype=XSD.date)
    # True
    Literal('2007-01-01', datatype=XSD.date) == date(2007, 1, 1)
    # False

    Literal("one", lang="en") == Literal("one", lang="en")
    # True
    Literal("hast", lang='en') == Literal("hast", lang='de')
    # False

    Literal("1", datatype=XSD.integer) == Literal(1)
    # True
    Literal("1", datatype=XSD.integer) == Literal("01", datatype=XSD.integer)
    # True
    ```
TNF)rI   r   r  r  r  rL   ro   rp   s     r=   ro   Literal.__eq__H  s    V ==eW%%%//1 ,/3~~T^^))+4/4EOO))+DJ, JJt+	 r>   c                   [        U[        5      (       Ga  U R                  [        ;   a  UR                  [        ;   a  U R                  (       d  UR                  (       dy  U R
                  bl  UR
                  b_  U R
                  b&  UR
                  b  U R
                  UR
                  :H  $ [        R                  X5      (       a  g[        SU  SU 35      eU R                  =(       d    SR                  5       UR                  =(       d    SR                  5       :w  a  g[        R                  R                  U R                  [        S9n[        R                  R                  UR                  [        S9nU[        :X  a  U[        :X  a  [        R                  X5      $ U[        ;   ab  U[        ;   aX  U R                  SLaI  UR                  SLa:  U R
                  b-  UR
                  b   [!        U R
                  UR
                  5      $ X#:w  a;  [        R"                  (       a%  [        SU R                   SUR                   35      egU R
                  b&  UR
                  b  U R
                  UR
                  :H  $ [        R                  X5      (       a  gU R                  [        :X  a  g[        SU  SU 35      e[        U[$        5      (       a  g[        U[        5      (       aD  U R                  b  gU R                  [        :X  d  U R                  c  [        U 5      U:H  $  [F        $ [        U[&        [(        [*        45      (       a*  U R                  [        ;   a  U R
                  U:H  $  [F        $ [        U[,        [.        [0        45      (       a5  U R                  [2        [4        [6        4;   a  U R
                  U:H  $  [F        $ [        U[8        [:        45      (       a5  U R                  [<        [>        [@        4;   a  U R
                  U:H  $  [F        $ [        U[B        5      (       a#  U R                  [D        :X  a  U R
                  U:H  $ [F        $ )a>  Compare the value of this literal with something else.

This comparison can be done in two ways:

1. With the value of another literal - comparisons are then done in literal "value space"
    according to the rules of XSD subtype-substitution/type-promotion

2. With a Python object:
   * string objects can be compared with plain-literals or those with datatype xsd:string
   * bool objects with xsd:boolean
   * int, long or float with numeric xsd types
   * date, time, datetime objects with xsd:date, xsd:time, xsd:datetime

Any other operations returns NotImplemented.
TzII cannot know that these two lexical forms do not map to the same value: z and r   Fr  z4I don't know how to compare literals with datatypes )$rI   r   r(  ra  r7  rN   rL   ro   r$  r&  r  r"  r.  r/  rf  _XML_COMPARABLE_isEqualXMLNoder  r   r|  r*   r}  r   r   r   r[  r\  r^  r   r,   rs  _XSD_DAYTIMEDURATION_XSD_YEARMONTHDURATIONrA   _XSD_BOOLEANr   )rW   rq   r  r  s       r=   rr   
Literal.eq  s     eW%%
 MM%;;*@@..5??ZZ+0G::)ekk.E::44zz$..##''+fE%: 
 #**,1E20L0L0NN[[**4==+*NFkk++ENNK+PG$K)?zz$.. ?*w//I ..,5??$3NZZ+0G&tzz5;;?? 00#Nt}}o]bchcqcqbrs  ! zz%%++*AzzU[[00::d**==K/   "V51  t$$s## }}(}}+t}}/D4yE)) 0E* % Y677}} 66zzU** 7"  h566}}	9 EEzzU** F  	8455}}$&! 
 zzU** 	 t$$}},zzU**r>   c                .    U R                  U5      (       + $ r@   )rr   rp   s     r=   rw   Literal.neq  s    775>!!r>   c                b    U(       a  U R                  UR                  S9$ U R                  5       $ )aE  Returns a representation in the N3 format.

```python
>>> Literal("foo").n3()
'"foo"'

```

Strings with newlines or triple-quotes:

```python
>>> Literal("foo\nbar").n3()
'"""foo\nbar"""'
>>> Literal("''\'").n3()
'"\'\'\'"'
>>> Literal('"""').n3()
'"\\"\\"\\""'

```

Language:

```python
>>> Literal("hello", lang="en").n3()
'"hello"@en'

```

Datatypes:

```python
>>> Literal(1).n3()
'"1"^^<http://www.w3.org/2001/XMLSchema#integer>'
>>> Literal(1.0).n3()
'"1.0"^^<http://www.w3.org/2001/XMLSchema#double>'
>>> Literal(True).n3()
'"true"^^<http://www.w3.org/2001/XMLSchema#boolean>'

```

Datatype and language isn't allowed (datatype takes precedence):

```python
>>> Literal(1, lang="en").n3()
'"1"^^<http://www.w3.org/2001/XMLSchema#integer>'

```

Custom datatype:

```python
>>> footype = URIRef("http://example.org/ns#foo")
>>> Literal("1", datatype=footype).n3()
'"1"^^<http://example.org/ns#foo>'

```

Passing a namespace-manager will use it to abbreviate datatype URIs:

```python
>>> from rdflib import Graph
>>> Literal(1).n3(Graph().namespace_manager)
'"1"^^xsd:integer'

```
)qname_callback)_literal_n3r   rV   s     r=   rY   
Literal.n3  s2    F ##3D3Q3Q#RR##%%r>   c                   U(       Ga  U R                   [        ;   a  U R                  b  U R                   [        ;   aU   [	        U 5      n[
        R                  " U5      (       d  [
        R                  " U5      (       a  U R                  SU5      $  U R                   [        :X  a  [        SS[	        U 5      S 5      $ U R                   [        :X  a  U  nSU;  a  SU;  a  SU;  a  US-  nU$ U R                   [        :X  a  U  R                  5       $ U  $ U R                  5       nU R                   nSnUb  U(       a  U" U5      nU(       d  SU S	3nU[        ;   av   [	        U 5      n[
        R                  " U5      (       a"  UR!                  S
S5      R!                  SS5      n[
        R                  " U5      (       a  UR!                  SS5      nU R&                  nU(       a  U SU 3$ U(       a  U SU 3$ U$ ! [         a    U R                  SU5      s $ f = f! [         a    ["        R$                  " SU < 35         Nrf = f)aS  Internal method for N3 serialization with more options.

Args:
    use_plain: Whether to use plain literal (shorthand) output
    qname_callback: Function to convert URIs to prefixed names

Example:
    Using plain literal (shorthand) output:

    ```python
    >>> from rdflib.namespace import XSD

    >>> Literal(1)._literal_n3(use_plain=True)
    '1'

    >>> Literal(1.0)._literal_n3(use_plain=True)
    '1e+00'

    >>> Literal(1.0, datatype=XSD.decimal)._literal_n3(use_plain=True)
    '1.0'

    >>> Literal(1.0, datatype=XSD.float)._literal_n3(use_plain=True)
    '"1.0"^^<http://www.w3.org/2001/XMLSchema#float>'

    >>> Literal("foo", datatype=XSD.string)._literal_n3(use_plain=True)
    '"foo"^^<http://www.w3.org/2001/XMLSchema#string>'

    >>> Literal(True)._literal_n3(use_plain=True)
    'true'

    >>> Literal(False)._literal_n3(use_plain=True)
    'false'

    >>> Literal(1.91)._literal_n3(use_plain=True)
    '1.91e+00'

    ```

    Only limited precision available for floats:

    ```python
    >>> Literal(0.123456789)._literal_n3(use_plain=True)
    '1.234568e-01'

    >>> Literal('0.123456789', datatype=XSD.decimal)._literal_n3(use_plain=True)
    '0.123456789'

    ```

    Using callback for datatype QNames:

    ```python
    >>> Literal(1)._literal_n3(qname_callback=lambda uri: "xsd:integer")
    '"1"^^xsd:integer'

    ```
NFz\.?0*eerZ  Ez.0r   r   infINFInfinitynanNaNzSerializing weird numerical @z^^)r(  _PLAIN_LITERAL_TYPESrN   _NUMERIC_INF_NAN_LITERAL_TYPESr}  mathisinfisnanr  r%  _XSD_DOUBLEr   rd  r  r  _quote_encodereplacewarningswarnr&  )	rW   	use_plainr  vrn  encodedr(  	quoted_dtr&  s	            r=   r  Literal._literal_n3C  s   | *>>zz% ==$BBG!$K::a==DJJqMM#'#3#3E>#JJ -: ==K/y#%+aBB]]l2&A!|1AT	H]]l2"V??,,"V$))+==	*84	zO	99KdAzz!}} #*//%"?"G"G&# zz!}}")//%"? ==Yaz**Yb,,Nc & G#//~FFGL " K MM$@"IJKs%   AG> A5H  >HH $IIc                P   SU ;   a\  U R                  SS5      nSU ;   a  UR                  SS5      nUS   S:X  a  US   S:w  a  US S S-   S-   nS	UR                  S
S5      -  $ SU R                  SS5      R                  SS5      R                  SS5      R                  S
S5      -  $ )N
\z\\z"""z\"\"\"r   z"""%s"""z\rz"%s"z\nz\")r  )rW   r  s     r=   r  Literal._quote_encode  s     4<ll40G}!//%=r{c!gbkT&9!#2,-3 e <<<DLLu5==dFKSSUgdE"# #r>   c                   [         R                  U 5      /nU R                  b'  UR                  S[	        U R                  5      -   5        U R
                  b'  UR                  S[	        U R
                  5      -   5        U R                  [        :X  a  SnOU R                  R                  nU SSR                  U5       S3$ )Nzlang=z	datatype=zrdflib.term.Literalr   z, r   )
rL   r   r&  appendreprr(  r   r   r]   join)rW   argsr   s      r=   r   Literal.__repr__  s    T"#==$KK$t}}"556==$KKd4==&99:>>W$+Gnn--G!DIIdO,A..r>   c                8    U R                   b  U R                   $ U $ )zF
Returns an appropriate python datatype derived from this RDF Literal
r   r   s    r=   r   Literal.toPython  s    
 ::!::r>   )r  r  )NNN)r4  r   r5  r   r(  r   r6  r  )r\   r   )r\   r  )r\   r   )r\   r   )r\   r  )r\   zDTuple[Type[Literal], Tuple[str, Union[str, None], Union[str, None]]])r\   z(Tuple[None, Dict[str, Union[str, None]]])rO  zTuple[Any, Dict[str, Any]]r\   None)rg  r   r\   r   )r\   rA   r   )r\   r|  r@   r[   )FN)r  rA   r  z+Optional[Callable[[URIRef], Optional[str]]]r\   rL   r   )'r]   r^   r_   r`   ra   r   rb   ri   r6  r   r7  rN   r&  r(  r   rL  rR  r   ru  rx  r   r  r  r   r   r   r   r   r  r   ro   rr   rw   rY   r  r  r   r   re   rT   r>   r=   r   r     sp   jX KBI
 #"&$(VV V  	V
 "Vp4 
 
      
	M
L'
iDVob7:787072n"`"$"<%N8ttl"F&T  FJxx Dx 
	xt#6
/r>   r   c                    [         R                  R                  R                  SU  S35      nUR	                  5         U$ )Nz<rdflibtoplevelelement>z</rdflibtoplevelelement>)xmldomminidomparseStringr6  )	xmlstringr   s     r=   	_parseXMLr    s:    WW__((
!),DEF Mr>   c                .   [         R                  " [         R                  R                  S5      SS9n UR	                  U 5      nUR                  5         U$ ! [         R
                  R                   a  n[        R                  SU 35        UeSnAff = f)aE  
Parse the lexical form of an HTML literal into a document fragment
using the `dom` from html5rdf tree builder.

Args:
    lexical_form: The lexical form of the HTML literal.

Returns:
    A document fragment representing the HTML literal.

Raises:
    html5rdf.html5parser.ParseError: If the lexical form is not valid HTML.
r  T)treestrictzFailed to parse HTML: N)
html5rdf
HTMLParsertreebuildersgetTreeBuilderparseFragmenthtml5parser
ParseErrorr   infor6  )lexical_formparserresultr  s       r=   _parse_htmlr    s       ""11%8F393G3G3U M	 ** ,QC01s   A B5BBc                0    [         R                  " U SS9nU$ )z
Serialize a document fragment representing an HTML literal into
its lexical form.

Args:
    value: A document fragment representing an HTML literal.

Returns:
    The lexical form of the HTML literal.
r  )r  )r  	serialize)rN   r  s     r=   _write_htmlr    s     E2FMr>   c                   [        U [        R                  R                  R                  5      (       aI  [        R                  R                  R                  5       nU=R                  U R                  -  sl        Un U R                  S5      nUR                  S5      (       a  USS  nUR                  S5      (       a  USS nUS:X  a  SnU$ )	NrH   s&   <?xml version="1.0" encoding="utf-8"?>&   s   <rdflibtoplevelelement>   is   <rdflibtoplevelelement/>r>   )	rI   r  r  r  DocumentFragmentDocument
childNodestoxmlr   )xmlnoderQ  rn  s      r=   	_writeXMLr    s     '377??;;<<GGOO$$&	***gA 	||=>>bcF||.//bI''Hr>   c                b    [        U [        5      (       a  U R                  5       n [        U 5      $ r@   )rI   rL   encoder   r   s    r=   
_unhexlifyr  3  s%    %Ur>   c                    / SQn/ SQnU R                  5       nX1;   a  gX2;  a  [        R                  " SU < S3[        S9  g)   
Boolean is a datatype with value space {true,false},
lexical space {"true", "false","1","0"} and
lexical-to-value mapping {"true"→true, "false"→false, "1"→true, "0"→false}.
)1true   1   true)rY  false   0   falseTzParsing weird boolean, z does not map to True or False)categoryF)r  r  r  UserWarning)rN   true_accepted_valuesfalse_accepted_values	new_values       r=   _parseBooleanr
  :  sK     8:I(-%eY.LM 	
 r>   c                
    USL$ )a6  
This function is used as the fallback for detecting ill-typed/ill-formed
literals and operates on the asumption that if a value (i.e.
`Literal.value`) could be determined for a Literal then it is not
ill-typed/ill-formed.

This function will be called with `Literal.lexical` and `Literal.value` as arguments.
NrT   lexicalrN   s     r=   r,  r,  M  s     r>   c                d    [        U 5      S:  =(       a    [        U[        5      =(       a    US:  $ )z?
xsd:unsignedInteger and xsd:unsignedLong must not be negative
r   )r   rI   r*   r  s     r=   _well_formed_unsignedlongr  Y  s(     w<!K
5) <K!Kr>   c                    U S;   $ )r  )r  r  r  r  r  r   rY  r  rT   r  s     r=   _well_formed_booleanr  `  s     PPPr>   c                    [        U 5      S:  =(       a,    [        U[        5      =(       a    SUs=:*  =(       a    S:*  $ s  $ )z
The value space of xs:int is the set of common single size integers (32 bits),
i.e., the integers between -2147483648 and 2147483647,
its lexical space allows any number of insignificant leading zeros.
r   i   ir   rI   r|  r  s     r=   _well_formed_intr  i  sC     	Gq 	1uc"	1E//Z/ 0r>   c                    [        U 5      S:  =(       a,    [        U[        5      =(       a    SUs=:*  =(       a    S:*  $ s  $ )z?
xsd:unsignedInt has a 32bit value of between 0 and 4294967295
r   l    r  r  s     r=   _well_formed_unsignedintr  v  s7     w<!U
5# 6UA<T<T*<TU<TUr>   c                    [        U 5      S:  =(       a,    [        U[        5      =(       a    SUs=:*  =(       a    S:*  $ s  $ )z
The value space of xs:short is the set of common short integers (16 bits),
i.e., the integers between -32768 and 32767,
its lexical space allows any number of insignificant leading zeros.
r   i i  r  r  s     r=   _well_formed_shortr  }  s7     w<!U
5# 6UFe<T<Tu<TU<TUr>   c                    [        U 5      S:  =(       a,    [        U[        5      =(       a    SUs=:*  =(       a    S:*  $ s  $ )z<
xsd:unsignedShort has a 16bit value of between 0 and 65535
r   i  r  r  s     r=   _well_formed_unsignedshortr    s7     w<!P
5# 6PA<O<O%<OP<OPr>   c                    [        U 5      S:  =(       a,    [        U[        5      =(       a    SUs=:*  =(       a    S:*  $ s  $ )z
The value space of xs:byte is the set of common single byte integers (8 bits),
i.e., the integers between -128 and 127,
its lexical space allows any number of insignificant leading zeros.
r   i   r  r  s     r=   _well_formed_byter    s7     w<!Q
5# 6QDE<P<PS<PQ<PQr>   c                    [        U 5      S:  =(       a,    [        U[        5      =(       a    SUs=:*  =(       a    S:*  $ s  $ )z8
xsd:unsignedByte has a 8bit value of between 0 and 255
r      r  r  s     r=   _well_formed_unsignedbyter     s7     w<!N
5# 6NA<M<M#<MN<MNr>   c                :    [        U[        5      =(       a    US:  $ Nr   rI   r|  r  s     r=   !_well_formed_non_negative_integerr$        eS!0eqj0r>   c                :    [        U[        5      =(       a    US:  $ r"  r#  r  s     r=   _well_formed_positive_integerr'        eS!/eai/r>   c                :    [        U[        5      =(       a    US:*  $ r"  r#  r  s     r=   !_well_formed_non_positive_integerr*    r%  r>   c                :    [        U[        5      =(       a    US:  $ r"  r#  r  s     r=   _well_formed_negative_integerr,    r(  r>   z!http://www.w3.org/2001/XMLSchema#z+http://www.w3.org/1999/02/22-rdf-syntax-ns#
XMLLiteralHTMLstringnormalizedStringtokenr}  doubledecimalintegerbooleandateTimer   r   ri  dayTimeDurationyearMonthDurationz&http://www.w3.org/2002/07/owl#rationalbase64Binary	hexBinarygYear
gYearMonthbyter|  longnegativeIntegernonNegativeIntegernonPositiveIntegerpositiveIntegershortunsignedByteunsignedIntunsignedLongunsignedShortzTuple[URIRef, ...]ra  r  r  _DATE_AND_TIME_TYPESr]  r`  c                j    U R                   S L=(       a    U R                   R                  U 5      S LU 4$ r@   tzinfo	utcoffsetr   s    r=   <lambda>rM    s/    D NU\\%;%;E%B$%Nr>   c                j    U R                   S L=(       a    U R                   R                  S 5      S LU 4$ r@   rJ  r   s    r=   rM  rM  	  s/    D MU\\%;%;D%A%Mr>   c                "    U R                  5       $ r@   )r  r   s    r=   rM  rM    s
    EKKMr>   z%Dict[Type[Any], Callable[[Any], Any]]r  re  _StrT)boundc                0    Ub
  U" U 5      U4$ Ub  X4$ U S 4$ r@   rT   )objpTypecastFuncdTypes       r=   _py2literalrW    s1     }e##		zDyr>   c                    [          H-  u  u  p#n[        X5      (       d  M  X1:X  d  M!  [        XXC5      s  $    [         H&  u  nu  pC[        X5      (       d  M  [        XXC5      s  $    U S4$ )zx
Casts a tuple of a python type and a special datatype URI to a tuple of the lexical value and a
datatype URI (or None)
N)_SpecificPythonToXSDRulesrI   rW  _GenericPythonToXSDRules)rS  r(  rT  rV  rU  s        r=   r-  r-  +  sj     %> c!!e&7s8;; %> %=  c!!s8;; %= 9r>   r  c                4    [        U 5      R                  5       $ r@   )rL   r  is    r=   rM  rM  N  s    c!fllnr>   c                
    U S $ )NrX  rT   r\  s    r=   rM  rM  Q  s
    Aa5r>   c                "    U R                  5       $ r@   	isoformatr\  s    r=   rM  rM  R  s
    !++-r>   c                "    U R                  5       $ r@   r`  r\  s    r=   rM  rM  S  
    akkmr>   c                "    U R                  5       $ r@   r`  r\  s    r=   rM  rM  T  rc  r>   c                    [        U 5      $ r@   r-   r\  s    r=   rM  rM  U  s
    ,Q/r>   c                    [        U 5      $ r@   rf  r\  s    r=   rM  rM  V  s
    -a0r>   zZList[Tuple[Type[Any], Tuple[Optional[Callable[[Any], Union[str, bytes]]], Optional[str]]]]rZ  c                B    U R                  S5      R                  S5      $ )Nz%Y   strftimezfillrg  s    r=   rM  rM  l  s    S\\$%7%=%=a%@r>   c                B    U R                  S5      R                  S5      $ )Nz%Y-%m   rj  rm  s    r=   rM  rM  m  s    #,,w*?*E*Ea*Hr>   zPList[Tuple[Tuple[Type[Any], str], Optional[Callable[[Any], Union[str, bytes]]]]]rY  r&  anyURIz3Dict[Optional[str], Optional[Callable[[str], Any]]]r  r  z6Dict[URIRef, Callable[[Union[str, bytes], Any], bool]]r*  r)  c                    [         R                  5         [         R                  [        5        [        R                  5         [        R                  [        5        [        R                  5         [        R                  [        5        g)z2Reset lexical<->value space binding for `Literal`.N)	r)  clearupdater  rZ  extend _OriginalGenericPythonToXSDRulesrY  !_OriginalSpecificPythonToXSDRulesrT   r>   r=   _reset_bindingsrw    sR    K(""$##$DE##%$$%FGr>   c                     [         U   nUb	   U" U 5      $  [        U 5      $ ! [         a     gf = f! [         a    [        R	                  SU SU 3SS9   gf = f! [         a    [        U S5      s $ f = f)ztMap a lexical form to the value-space for the given datatype.

Returns:
    A python object for the value or `None`
Nz:Failed to convert Literal lexical form to value. Datatype=z, Converter=T)exc_inforH   )r)  KeyErrorr   r   r   rL   r   )r  r(  	conv_funcs      r=   r'  r'    s    $X.	
 	 W%%	)w<-    	NNLXJVbclbmn  
 	 " 	) w((		)s,   	# 3 
A 
00$AAA65A6_AnyTc                    [        U [        5      (       a2  U R                  SS5      R                  SS5      R                  SS5      $ U $ )zxReplaces \t, \n, \r (#x9 (tab), #xA (linefeed), and #xD (carriage return)) with space without any whitespace collapsing.	 r  r  )rI   rL   r  r4  s    r=   r2  r2    sF    "C((  ''c2::4EMMdTWXXr>   c                |    [        U [        5      (       a&  [        R                  " SSU R	                  5       5      $ U $ )Nz +r  )rI   rL   rer   stripr  s    r=   r3  r3    s5    "C(( vvdC!1!7!7!9::r>   c                    U(       a  U c  [        S5      eU [        ;   a  [        R                  SU  S35        Uc  UnU[        U '   U(       a  [        R                  X4U45        g[        R                  XU 445        g)a
  
register a new datatype<->pythontype binding

Args:
    constructor: An optional function for converting lexical forms
        into a Python instances, if not given the pythontype
        is used directly
    lexicalizer: An optional function for converting python objects to
        lexical form, if not given object.__str__ is used
    datatype_specific: Makes the lexicalizer function be accessible
        from the pair (pythontype, datatype) if set to True
        or from the pythontype otherwise. False by default
Nz1No datatype given for a datatype-specific bindingz
datatype 'z' was already bound. Rebinding.)r   r)  r   r   rY  r  rZ  )r(  
pythontypeconstructorlexicalizerdatatype_specifics        r=   r   r     s|    ( X-KLL##H:-LMN !,X!((:*@+)NO ''85L(MNr>   c                  R    \ rS rSrSrSrS
S jrSS jrSS jrSSS jjr	SS	 jr
Srg)r   i!	  zc
A Variable - this is used for querying, or in Formula aware
graphs, where Variables can be stored
rT   c                |    [        U5      S:X  a  [        S5      eUS   S:X  a  USS  n[        R                  X5      $ )Nr   z7Attempted to create variable with empty string as name!?r+   )r   r   rL   ri   rj   s     r=   ri   Variable.__new__)	  s>    u:?UVV8s?!"IE{{3&&r>   c                    U R                   [        L a  SnOU R                   R                  nU S[        R	                  U 5       S3$ )Nzrdflib.term.Variabler   r   )r   r   r]   rL   r   r   s     r=   r   Variable.__repr__0	  s?    >>X%,Gnn--G!CLL./q11r>   c                    SU -   $ Nr  rT   r   s    r=   r   Variable.toPython8	      Tzr>   Nc                    SU -   $ r  rT   rV   s     r=   rY   Variable.n3;	  r  r>   c                &    [         [        U 5      44$ r@   )r   rL   r   s    r=   r   Variable.__reduce__>	  s    3t9,''r>   r   r   r@   r[   )r\   z!Tuple[Type[Variable], Tuple[str]])r]   r^   r_   r`   ra   rb   ri   r   r   rY   r   re   rT   r>   r=   r   r   !	  s'    
 I'2(r>   r   zDict[Type[Node], int]r   
         (   c                
  ^ ^ SSK Jn  U U4S jnT b  Tc  gT R                  TR                  :w  a  gT R                  UR                  UR                  4;   a  U" 5       $ T R                  UR
                  :X  Gav  [        (       aj  [        T [        R                  R                  R                  5      (       d   e[        T[        R                  R                  R                  5      (       d   eT R                  TR                  :X  a  T R                  TR                  :X  d  gT R                  R                  5        Vs/ s H  nUS   S:w  d  M  UPM     nnTR                  R                  5        Vs/ s H  nUS   S:w  d  M  UPM     nn[!        U5      [!        U5      :w  a  gU H<  nXF;   a4  T R#                  US   US   5      TR#                  US   US   5      :X  a  M<    g   U" 5       $ T R                  UR$                  UR&                  UR(                  UR*                  4;   Gac  [        (       Ga>  [        T [        R                  R                  R,                  [        R                  R                  R.                  [        R                  R                  R0                  [        R                  R                  R2                  45      (       d   e[        T[        R                  R                  R,                  [        R                  R                  R.                  [        R                  R                  R0                  [        R                  R                  R2                  45      (       d   eT R4                  TR4                  :H  $ T R                  UR6                  :X  a  [        (       aj  [        T [        R                  R                  R8                  5      (       d   e[        T[        R                  R                  R8                  5      (       d   eT R4                  TR4                  :H  =(       a    T R:                  TR:                  :H  $ T R                  UR<                  :X  a  T R>                  TR>                  :H  $ T R                  UR@                  :X  a  [        (       aj  [        T [        R                  R                  RB                  5      (       d   e[        T[        R                  R                  RB                  5      (       d   eT RD                  TRD                  :H  =(       a    T RF                  TRF                  :H  $ [I        ST R                   35      es  snf s  snf )Nr   )r   c                    > [        TR                  5      [        TR                  5      :w  a  g[        S TR                  TR                  5       H  u  p[        X5      (       a  M    g   g)NFc                    X4$ r@   rT   )xys     r=   rM  2_isEqualXMLNode.<locals>.recurse.<locals>.<lambda>t	  s    vr>   T)r   r  mapr  )ncocnoderq   s     r=   recurse _isEqualXMLNode.<locals>.recursej	  sX     t3u'7'7#88-t@P@PQFB"2** R r>   Fzhttp://www.w3.org/2000/xmlns/r+   z*I dont know how to compare XML Node type: )%xml.dom.minidomr   nodeTypeDOCUMENT_NODEDOCUMENT_FRAGMENT_NODEELEMENT_NODEr   rI   r  r  r  ElementtagNamenamespaceURI
attributeskeysNSr   getAttributeNS	TEXT_NODECOMMENT_NODECDATA_SECTION_NODENOTATION_NODETextCommentCDATASectionNotationdataPROCESSING_INSTRUCTION_NODEProcessingInstructiontargetENTITY_NODE	nodeValueDOCUMENT_TYPE_NODEDocumentTypepublicIdsystemIdr   )r  rq   XMLNoder  kn_keyso_keyss   ``     r=   r  r  J	  s   < 0  |u}}}&}}..0N0NOOy	'..	.=dCGGOO$;$;<<<<eSWW__%<%<==== LLEMM)d.?.?5CUCU.U __++-
-t66 - 	 
 %%,,.
.t66 . 	 

 v;#f+%A''!ad3u7K7KAaDRSTURV7WW  y	""	 
 =GGOO((GGOO++GGOO00GGOO,,	    GGOO((GGOO++GGOO00GGOO,,	    yyEJJ&&	'==	==dCGGOO$I$IJJJJeSWW__%J%JKKKKyyEJJ&F4;;%,,+FF	'--	-~~00	'44	4=dCGGOO$@$@AAAAeSWW__%A%ABBBB}}.R4==ENN3RR DT]]OTUUI


s    U+U+5U0U0)r;   rL   r\   rA   )rD   rL   r\   rA   )rN   Union[str, bytes]r\   rA   r   )r  rL   r\   zxml.dom.minidom.Document)r  rL   r\    xml.dom.minidom.DocumentFragment)rN   r  r\   rJ   )r  zAUnion[xml.dom.minidom.Document, xml.dom.minidom.DocumentFragment]r\   rJ   )rN   zUnion[str, bytes, Literal]r\   rJ   )r  r  rN   r   r\   rA   )
rS  r   rT  r   rU  zOptional[Callable[[Any], Any]]rV  zOptional[_StrT]r\   zTuple[Any, Optional[_StrT]])rS  r   r(  r   r\   zTuple[Any, Optional[str]])r\   r  )r  r  r(  r  r\   r   )r4  r|  r\   r|  )NNF)r(  rL   r  z	Type[Any]r  zOptional[Callable[[str], Any]]r  z,Optional[Callable[[Any], Union[str, bytes]]]r  rA   r\   r  )r    Union[None, xml.dom.minidom.Attr, xml.dom.minidom.Comment, xml.dom.minidom.Document, xml.dom.minidom.DocumentFragment, xml.dom.minidom.DocumentType, xml.dom.minidom.Element, xml.dom.minidom.Entity, xml.dom.minidom.Notation, xml.dom.minidom.ProcessingInstruction, xml.dom.minidom.Text]rq   r  r\   rA   )ra   
__future__r   rc   r  	fractionsr   __all__loggingr  r  r  r  base64r   r   binasciir   r   collectionsr   r   r   r   r   r3  r   r   r   typesr   typingr   r   r   r   r   r    r!   r"   r#   r$   r%   urllib.parser&   r'   r(   uuidr)   r"  rdflib.utilrdflib.compatr*   xsd_datetimer,   r-   r.   r/   r0   r1   	namespacer2   pathsr3   r4   r5   r6   r7   _HAS_HTML5RDFr  ImportErrorr  	getLoggerr]   r   r   r   r8   r   r:   r   rB   rE   rQ   ABCr   rL   r	   r   r
   r   r   r   r   r   r  r  r  r  r  r
  r,  r  r  r  r  r  r  r  r   r$  r'  r*  r,  _XSD_PFX_RDF_PFX_RDF_XMLLITERAL_RDF_HTMLLITERALrf  r0  r1  
_XSD_FLOATr  rd  _XSD_INTEGERr  r[  r\  r^  rs  r  r  _OWL_RATIONAL_XSD_B64BINARY_XSD_HEXBINARY
_XSD_GYEAR_XSD_GYEARMONTHra  r  r  rH  r]  r`  r  r  r  r  re  rP  rW  r-  r}  rA   r|  rZ  r  r  listru  rJ   rY  rv  r  r  r*  r)  rs  rw  r'  r|  r2  r3  r   r   r   r  rT   r>   r=   <module>r     sq  , # 
 	 
     ' ' # 4 4       6 5    #  +PPM 7 			8	$$2 	  #  9:,$S377 Scs cLZ &y=^ y=xF % (
U2N U2p^j ^B'4N
(&	LQ
VVQRO1010
 /8L01(V+, X()+= => Hw&'
Hw&'
X()h*+h*+h*+x*,-8f$%	8f$%	x*,-h)::; +> >? ?@>12;./Hw&'
L01 
8g
8f
8e
8f
8''(
8**+
8**+
8''(
8g
8n$%
8m#$
8n$%
8o%&!. * * , (  8g6  2  , (  ) % 
 0DFW/W , W  
 	 
 GGOO9? ;   
8(()
8g- )  	s#	 - 	
 !	%B 	,
T; 	$l344
|$%!<01'78	#Y/0	#Y/0/?@02FGHWW__	?;<m$%   $  ##		)	)K9I+JK $((@#A  
 J@A
OHI	>G$^g&	>I&^i(   	 %))B$C !!D$!D
8fz!D 8f~!D 8j !>	!D
 8j !#5!D 8''(*<!D 8))*,>!D 8k!"J!D 8h!D 8(()4!D 8g!D 8j !4!D 8i -!D 8i '!D 8i )!D  8**+Y!!D" 8fy#!D$ 8**+Y
8''()
8ec
8n$%y
8''()
8g
8m#$c
8fs
8o%&
8n$%s
8g
8h
8n$%y
8hYA!D@ !F  %0K !+:<L*MO'M&(O 8i "6
8**+-N
8**+-N
8''(*G
8''(*G
8e.
8g 2
8f0
8m#$&>
8n$%'@
8o%&(B
8n$%'@T P  IK E J    $	H%)%)*:%)%)P 	s# 37@D# O O O 0 O >	 O
  O 
 OF(z (J $/s#3	  3 	  %Xr62wC DKVKVKV6 
7KVaG  Hs   ]% %]10]1