
    4Ysh7                         d Z ddlZddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ d
ZdZ	 	 ddZd Zd Zd Zd Zedk(  r e        yy)zq
A commandline tool for parsing RDF in different formats and serializing the
resulting graph to a chosen format.
    N)OptionParser)plugin)Store)ConjunctiveGraph)Parser)
Serializer)guess_formatxmln3c                 F   |r< t        j                  |t                     }|j                  |       t	        |      }	nd }t	               }	|j                         D ]#  \  }
}|	j                  j                  |
|d       % | D ]R  }t        |      \  }}|dk(  rt        j                  }n|s|rt        |      xs t        } |	j                  |fd|i| T |r5t        |      \  }}|j                  dd         |	j                  d||d| |r|j!                          y y )NF)override-formatbase)destinationr    )r   getr   openr   itemsnamespace_managerbind_format_and_kwssysstdinr	   DEFAULT_INPUT_FORMATparse
setdefault	serializerollback)input_filesinput_formatguessoutfileoutput_formatns_bindings
store_conn
store_typestoregraphprefixurifpath
use_formatkwss                  t/var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/tools/rdfpipe.pyparse_and_serializer0      s     -

:u-/

: ' ""((* B$$VS5$AB  5),7
CC<IIE%%e,D0DJE4*445 ,];svt$IGMISI     c                 "   | i }} | rd| v r| j                  dd      \  } }|j                  d      D ]Y  }d|v r|j                  d      \  }}|||<   !|j                  d      r	d||dd <   ;|j                  d      r	d	||dd <   Ud	||<   [ | |fS )
a}  
    >>> _format_and_kws("fmt")
    ('fmt', {})
    >>> _format_and_kws("fmt:+a")
    ('fmt', {'a': True})
    >>> _format_and_kws("fmt:a")
    ('fmt', {'a': True})
    >>> _format_and_kws("fmt:+a,-b") #doctest: +SKIP
    ('fmt', {'a': True, 'b': False})
    >>> _format_and_kws("fmt:c=d")
    ('fmt', {'c': 'd'})
    >>> _format_and_kws("fmt:a=b:c")
    ('fmt', {'a': 'b:c'})
    :   ,=r   FN+T)split
startswith)fmtr.   kwreprkwkvs         r/   r   r   A   s     BC
scziiQ'V,,s# 		Bbyxx}1As##BqrFs#"BqrFB		 8Or1   c            	         t        t              } t        t              }d}t        dt        j                         dz   ddt        j                  z  z         }|j                  ddt        d	| z  d
z   dz   d|z  z   d       |j                  ddt        t        d|z  dz   d|z  z   d       |j                  ddt        dd       |j                  ddddd        |j                  d!d"d#d$%       |j                  d&d'd"d#d(%       |S ))NzFORMAT:(+)KW1,-KW2,KW3=VALUEzP%prog [-h] [-i INPUT_FORMAT] [-o OUTPUT_FORMAT] [--ns=PFX=NS ...] [-] [FILE ...]za Reads file system paths, URLs or from stdin if '-' is given. The result is serialized to stdout.z%prog z(using rdflib %s))descriptionversionz-iz--input-formatzAFormat of the input document(s). Available input formats are: %s.z# If no format is given, it will be z%guessed from the file name extension.z7 Keywords to parser can be given after format like: %s.INPUT_FORMAT)typehelpmetavarz-oz--output-formatzDFormat of the graph serialization. Available output formats are: %s.z Default format is: '%default'.z; Keywords to serializer can be given after format like: %s.OUTPUT_FORMAT)rC   defaultrD   rE   z--nsappendz[Register a namespace binding (QName prefix to a base URI). This can be used more than once.zPREFIX=NAMESPACE)actionrC   rD   rE   z
--no-guessr"   store_falseTz(Don't guess format based on file suffix.)destrI   rG   rD   z--no-out
store_trueFzIDon't output the resulting graph (useful for checking validity of input).)rI   rG   rD   z-wz--warnz<Output warnings to stderr (by default only critical errors).)_get_plugin_namesr   r   r   __doc__striprdflib__version__
add_optionstrDEFAULT_OUTPUT_FORMAT)parser_namesserializer_names
kw_exampleoparsers       r/   make_option_parserrY   `   s   $V,L(4/J	-MMO3

 .1C1CCC	G ,.:;
/0 22 Dj
P	Q
   
 %-/?@
+, H*
TU    
 +"   7   5	   K   Nr1   c                 Z    dj                  d t        j                  |       D              S )Nz, c              3   4   K   | ]  }|j                     y w)N)name).0ps     r/   	<genexpr>z$_get_plugin_names.<locals>.<genexpr>   s     ?QVV?s   kind)joinr   pluginsr`   s    r/   rM   rM      s     99?V^^%>???r1   c                  <   t               } | j                         \  }}t        |      dk  r | j                          | j	                          |j
                  rt        j                  }nt        j                  }t        j                  |       i }|j                  r*|j                  D ]  }|j                  d      \  }}|||<    t        j                  j                  }|j                  rd }t!        ||j"                  |j$                  ||j&                  |       y )Nr4   )levelr6   )rY   
parse_argslenprint_usageexitwarnloggingWARNINGCRITICALbasicConfignsr8   r   stdoutbufferno_outr0   r!   r"   r$   )	rX   optsargsloglevelr%   ns_kwpfxr+   r#   s	            r/   mainrx      s     "G##%JD$
4y1}yy??##h'KwwWW 	#E{{3'HC"K	# jjG{{dWd6H6H+r1   __main__) N)rN   r   optparser   rk   rP   r   rdflib.storer   rdflib.graphr   rdflib.parserr   rdflib.serializerr   rdflib.utilr	   r   rT   r0   r   rY   rM   rx   __name__r   r1   r/   <module>r      sq   
  !     )   ( $    $N>IX@: zF r1   