
    4Ysh                     x    d dl mZmZmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ dee   fdZ G d d	e	      Zy
)    )IOListOptional)URIRefBNodeLiteral)ResultSerializer)NamespaceManager)Variablenamespace_managerc                    | y|rnt        | t              r|j                  |       S t        | t              r| j	                         S t        | t
              r| j                  |j                        S y | j	                         S )N-)qname_callback)
isinstancer   normalizeUrir   n3r   _literal_n3)tr   s     /var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/plugins/sparql/results/txtresults.py_termStringr      sq    ya $11!445!446M7#==0A0N0N=OO $ ttv    c                   .    e Zd ZdZ	 ddededee   fdZy)TXTResultSerializerzC
    A write only QueryResult serializer for text/ascii tables
    Nstreamencodingr   c                 z   d }| j                   j                  dk7  rt        d      | j                   sy| j                   j                  }dgt	        |      z  }| j                   D cg c]  }|D cg c]  }t        ||   |       c}! }	}}|	D ]9  }t        t	        |            D ]   }
t        ||
   t	        ||
               ||
<   " ; |j                  dj                  t        |      D 
cg c]  \  }
} ||||
          c}}
      dz          |j                  dt	        |      t        |      z   z  dz          t        |	      D ]T  }|j                  dj                  t        ||      D 
cg c]  \  }
}|d	|
t	        |      z
  z  z    c}}
      dz          V y
c c}w c c}}w c c}}
w c c}}
w )z6
        return a text table of query results
        c                 \    |t        |       z  }|dz  x}}|dz  r|dz  }d|z  | z   d|z  z   S )z>
            center the string s in w wide string
                   )len)swh1h2s       r   cz(TXTResultSerializer.serialize.<locals>.c&   sF     QKA1fB1ua8a<#(**r   SELECTz%Can only pretty print SELECT results!z(no results)
r   |
r   r    N)resulttype	Exceptionvarsr!   r   rangemaxwritejoin	enumeratesumsortedzip)selfr   r   r   r&   keysmaxlenrkbir   s               r   	serializezTXTResultSerializer.serialize   s   	+ ;;x'CDD{{# $(;;#3#3DS3t9_F  @DD!QqT#45DA   :s4y) :A #F1Is1Q4y 9F1I:: LLy"Otq!1Qq	?"OPSWWXLLFc&k 9:TABAY HHVQPAa#SV"44PQTXX E #P Qs$   )	F+2F&F+2F16F7&F+)N)	__name__
__module____qualname____doc__r   strr   r
   r=    r   r   r   r      s3     9=	** * $$45	*r   r   N)typingr   r   r   rdflibr   r   r   rdflib.queryr	   rdflib.namespacer
   rdflib.termr   r   r   rC   r   r   <module>rI      s9    % % ) ) ) -  h/?&@ 0* 0r   