File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/bs4/__pycache__/diagnose.cpython-310.pyc
Back
o �h � @ 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"kr�eej� � � dS dS ))z=Diagnostic functions, mainly for use when doing tech support.�MIT� N)�BytesIO)� HTMLParser)� BeautifulSoup�__version__)�builder_registryc C s� t dt � t dtj � g d�}|D ]}tjD ] }||jv r! nq|�|� t d| � qd|v rc|�d� zddl m } t d d �tt |j�� � W n tyb } z t d� W Y d}~nd}~ww d |v r�z ddl}t d|j � W n ty� } z t d� W Y d}~nd}~ww t| d�r�| �� } |D ]C}t d| � d}z t| |d�} d}W n ty� } zt d| � t�� W Y d}~nd}~ww |r�t d| � t | �� � t d� q�dS )z�Diagnostic suite for isolating common problems. :param data: A string containing markup that needs to be explained. :return: None; diagnostics are printed to standard output. z'Diagnostic running on Beautiful Soup %szPython version %s)�html.parser�html5lib�lxmlz;I noticed that %s is not installed. Installing it may help.r zlxml-xmlr ��etreezFound lxml version %s�.z.lxml is not installed or couldn't be imported.Nr zFound html5lib version %sz2html5lib is not installed or couldn't be imported.�readz#Trying to parse your markup with %sF)�featuresT�%s could not parse the markup.z#Here's what %s did with the markup:zP--------------------------------------------------------------------------------)�printr �sys�versionr �buildersr �remove�appendr r �join�map�str�LXML_VERSION�ImportErrorr �hasattrr r � Exception� traceback� print_exc�prettify) �data� basic_parsers�name�builderr �er �parser�success�soup� r) �?/usr/local/CyberCP/lib/python3.10/site-packages/bs4/diagnose.py�diagnose sl � ��� ������ �� �r+ Tc K sp ddl m} |�dd�}t| t�r| �d�} t| �}|j|f||d�|��D ]\}}td||j |j f � q&dS ) a� 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. You can use this to determine whether an lxml-specific problem is in Beautiful Soup's lxml tree builders or in lxml itself. :param data: Some markup. :param html: If True, markup will be parsed with lxml's HTML parser. if False, lxml's XML parser will be used. r r �recoverT�utf8)�htmlr, z%s, %4s, %sN)r r �pop� isinstancer �encoder � iterparser �tag�text)r! r. �kwargsr r, �reader�event�elementr) r) r* � lxml_traceN s ����r9 c @ s` e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z dS )�AnnouncingParserz�Subclass of HTMLParser that announces parse events, without doing anything else. You can use this to get a picture of how html.parser sees a given document. The easiest way to do this is to call `htmlparser_trace`. c C s t |� d S )N)r )�self�sr) r) r* �_pl s zAnnouncingParser._pc C � | � d| � d S )Nz%s START�r= )r; r# �attrsr) r) r* �handle_starttago � z AnnouncingParser.handle_starttagc C r>