File: //opt/alt/python37/lib/python3.7/site-packages/bs4/__pycache__/diagnose.cpython-37.pyc
B
�.�`� � @ s d Z dZddlZddlmZ ddlmZ ddlZddlmZm Z ddl
mZ ddlZddl
Z
ddlZddlZddlZddlZddlZddlZdd � Zd#dd�ZG d
d� de�Zdd� ZdZdZd$dd�Zd%dd�Zd&dd�Zd'dd�Zd(d d!�Zed"k�reej� � � dS ))z=Diagnostic functions, mainly for use when doing tech support.�MIT� N)�StringIO)�
HTMLParser)�
BeautifulSoup�__version__)�builder_registryc C s< t dt � t dtj � dddg}x>|D ]6}x0tjD ]}||jkr6P q6W |�|� t d| � q*W d|kr�|�ddg� y*dd l m
} t d
d�tt
|j�� � W n* tk
r� } zt d� W d
d
}~X Y nX d|k�r"ydd
l}t d|j � W n, tk
�r } zt d� W d
d
}~X Y nX t| d��r8| �� } nhtj�| ��rpt d| � t| ��}|�� } W d
Q R X n0| �d��s�| �d��r�t d| � t d� d
S t � x�|D ]�}t d| � d} yt| |�}
d} W n8 tk
�r
} zt d| � t�� W d
d
}~X Y nX | �r*t d| � t |
�� � t d� �q�W d
S )z/Diagnostic suite for isolating common problems.z'Diagnostic running on Beautiful Soup %szPython version %szhtml.parser�html5lib�lxmlz;I noticed that %s is not installed. Installing it may help.�xmlr )�etreezFound lxml version %s�.z.lxml is not installed or couldn't be imported.NzFound html5lib version %sz2html5lib is not installed or couldn't be imported.�readz7"%s" looks like a filename. Reading data from the file.zhttp:zhttps:z<"%s" looks like a URL. Beautiful Soup is not an HTTP client.zpYou need to use some other library to get the document behind the URL, and feed that document to Beautiful Soup.z#Trying to parse your markup with %sFTz%s could not parse the markup.z#Here's what %s did with the markup:zP--------------------------------------------------------------------------------)�printr �sys�versionr Zbuilders�features�remove�appendr r �join�map�strZLXML_VERSION�ImportErrorr �hasattrr
�os�path�exists�open�
startswithr � Exception� traceback� print_excZprettify)�dataZ
basic_parsers�nameZbuilderr �er �fp�parser�success�soup� r( �=/opt/alt/python37/lib/python3.7/site-packages/bs4/diagnose.py�diagnose sd
r* Tc K sN ddl m} x<|jt| �fd|i|��D ]\}}td||j|jf � q(W dS )z�Print out the lxml events that occur during parsing.
This lets you see how lxml parses a document when no Beautiful
Soup code is running.
r )r �htmlz%s, %4s, %sN)r r Z iterparser r �tag�text)r! r+ �kwargsr �event�elementr( r( r) �
lxml_traceT s $r1 c @ s` e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dS )�AnnouncingParserz?Announces HTMLParser parse events, without doing anything else.c C s t |� d S )N)r )�self�sr( r( r) �_pa s zAnnouncingParser._pc C s | � d| � d S )Nz%s START)r5 )r3 r"