Sindbad~EG File Manager
3
�h>`C�@s�ddddgZddlZddlZejdkrLddlZddlZddlZddlmZnddl Z ddlmZddl
ZddlZddl
TGd d
�d
ej�Zejdkr�Gdd�dejj�ZnGd
d�de j�Zdd�Zdd�Zddd�Zdd�ZdS)�escape_html�
unescape_html�html_to_text�
html_document�N�)�StringIO)�*c@s6eZdZddd�Zdd�Zdd �Zd
d�Zdd
�ZdS)�
TextWriterN�P�cCs(tjj|||�d|_||_|j�dS)Nr)� Formatter�
DumbWriter�__init__�indent_level�indent_width�_set_indent)�self�file�maxcolr�r�/usr/lib/python3.6/html_util.pyr0szTextWriter.__init__cCs|j|j|_d|j|_dS)N� )rr�
indent_col�indent)rrrrr6szTextWriter._set_indentcCs||_|j�dS)N)rr)rZmargin�levelrrr�
new_margin:szTextWriter.new_margincCsF|d}t|�|jkr"|j|�n |jt|�}|jd||�dS)Nr)�lenrZsend_literal_data)r�data�offsetrrr�send_label_data>s
zTextWriter.send_label_datacCs�|sdS|jp|dtjk}|j}|j}|jj}|j}|dkrN||j�|j}xb|j �D]V}|r�|t
|�|kr�|d|j�|j}n|d�|d}||�|t
|�}d}qXW||_|dtjk|_dS)Nr�
r����)�atbreak�stringZ
whitespace�colrr�writerr�splitr)rrr#r%rr&Zwordrrr�send_flowing_dataFs,
zTextWriter.send_flowing_data)Nr
r)�__name__�
__module__�__qualname__rrrrr(rrrrr .s
r cs6eZdZd
�fdd� Zdd�Zdd�Zdd �Z�ZS)�HTMLParserAnchorFcstt|�j�||_d|_dS)N)�superr,r� formatter�anchor_href)rr.�strictZconvert_charrefs)� __class__rrrbszHTMLParserAnchor.__init__cCs,|dkr(x|D]\}}|dkr||_qWdS)N�a�href)r/)r�tagZattrs�key�valuerrr�handle_starttaggsz HTMLParserAnchor.handle_starttagcCs4|dkr0|jdkr*|jjjd|jd�d|_dS)Nr2�(�))r/r.�writerr()rr4rrr�
handle_endtagms
zHTMLParserAnchor.handle_endtagcCs|jjj|�dS)N)r.r:r()rrrrr�handle_datasszHTMLParserAnchor.handle_data)FF)r)r*r+rr7r;r<�
__classcell__rr)r1rr,`sr,c@s&eZdZd dd�Zdd�Zdd�ZdS)
r,rcCstjj|||�dS)N)�htmllib�
HTMLParserr)rr.�verboserrrryszHTMLParserAnchor.__init__cCs
||_dS)N)�anchor)rr3�name�typerrr�
anchor_bgn|szHTMLParserAnchor.anchor_bgncCs |jr|jd|j�d|_dS)Nz (%s) )rAr<)rrrr�
anchor_endszHTMLParserAnchor.anchor_endN)r)r)r*r+rrDrErrrrr,ws
c Cs^|dkrdSy@|jdd�}|jdd�}|jdd�}|jdd�}|jd d
�}WnYnX|S)N�&z&�<z<�>z>�'z'�"z")�replace)�srrrr�scCsX|dkrdSd|kr|S|jdd�}|jdd�}|jdd�}|jdd �}|jd
d�}|S)NrFz<rGz>rHz'rIz"rJz&)rK)rLrrrr�sr
cCs|yDt�}tjt||��}t|�}|j|�|j�|j�}|j�|Stk
rv}zt j t j
d|�dSd}~XnXdS)Nzcannot convert html to text: %s)rrZAbstractFormatterr r,Zfeed�close�getvalue� Exception�syslogZLOG_ERR)�htmlr�bufferr.�parser�text�errrr�s
cGs�d}d}|}x�|D]�}t|tj�r,||7}qt|ttf�rRx\|D]}||7}q@Wqt|�r�|�}t|ttf�r�x|D]}||7}qtWq�||7}q||7}qW||7}|S)a&Wrap the body components in a HTML document structure with a valid header.
Accepts a variable number of arguments of of which canb be:
* string
* a sequences of strings (tuple or list).
* a callable object taking no parameters and returning a string or sequence of strings.
zl<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
z
</body>
</html>)�
isinstanceZsixZstring_types�tuple�list�callable)Zbody_components�head�tail�docZbody_component�item�resultrrrr�s$
)r)r)r
)�__all__rP�sys�version_inforQZhtml.parserZ
html.entities�iorr>r.rr$�typesr
r rSr?r,rrrrrrrr�<module>s.
1
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists