
    4Ysh                         d dl Zej                  rd dlZn
	 d dlZesJ 	 d dlmZ d dlmZ d dl	m
Z
mZmZ d dlmZmZmZ d dlmZmZ d ZdZd	 Zd
 Zd Zy# e$ r d dlZY Bw xY w)    N)sep)normpath)urljoinurlsplit
urlunsplit)create_input_sourcePythonInputSourceStringInputSource)
TextIOBaseTextIOWrapperc                    t        | t              r| j                  S t        | t              r#t	        j
                  | j                               S t        | d      } | j                         }	 t        |t              r|}nt        |d      }t	        j
                  |      |j                          S # |j                          w xY w)Nzjson-ld)formatzutf-8)encoding)
isinstancer	   datar
   jsonloadgetCharacterStreamr   getByteStreamr   r   close)sourcestream
use_streams      /var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/shared/jsonld/util.pysource_to_jsonr      s    &+,{{&+,yy22455 !	:F!!#Ffj)J&v@Jyy$s   .4B3 3C)#/:c                 p    t         D ]*  }| j                  |      }|dkD  s| d |dz    | |dz   d  fc S  | d fS )N   )VOCAB_DELIMSrfind)iridelimats      r   	split_irir'   3   sQ     0YYu7xa=#b1fh-//0 9    c                    d|v r|S t        t        | |            }t        |d         }t        dk7  r$dj	                  |j                  t                    }|d   j                  d      r|j                  d      s|dz  }t        |dd |fz   |dd z         }|j                  d      r|j                  d      s|dz  }|S )a  
    >>> norm_url('http://example.org/', '/one')
    'http://example.org/one'
    >>> norm_url('http://example.org/', '/one#')
    'http://example.org/one#'
    >>> norm_url('http://example.org/one', 'two')
    'http://example.org/two'
    >>> norm_url('http://example.org/one/', 'two')
    'http://example.org/one/two'
    >>> norm_url('http://example.org/', 'http://example.net/one')
    'http://example.net/one'
    >>> norm_url('http://example.org/', 'http://example.org//one')
    'http://example.org//one'
    z://   r   r      Nr   )r   r   r   r   joinsplitendswithr   )baseurlpartspathresults        r   norm_urlr4   ;   s     |
WT3'(EE!HD
czxx

3(QxdmmC&8a
dW,uQRy89F
||C!5#Mr(   c                 (   | j                   dk(  rt	 | j                  j                  d      }|D ]R  }d|v s|j	                  d      |j	                  d      }}|dkD  s0|dkD  s6t        | j                  ||dz   |       c S  y y # t        $ r Y y w xY w)Nzapplication/jsonLinkz+ rel="http://www.w3.org/ns/json-ld#context"<>r    r!   )content_typeresponse_infogetallmatchingheadersAttributeErrorindexr   r0   )r   linkslinkijs        r   context_from_urlinputsourcerB   X   s    00	((>>vFE  	@D<Dzz#

31r6a"f"6::tAEA??		@ 1  		s   B 	BB)typingtTYPE_CHECKINGr   ImportError
simplejson	posixpathr   r   urllib.parser   r   r   rdflib.parserr   r	   r
   ior   r   r   r"   r'   r4   rB    r(   r   <module>rM      sk    ??"t   6 6 S S (. :@Y  "!"s   A 	A#"A#