HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/site-packages/bs4/__pycache__/diagnose.cpython-311.pyc
�

��nc���F�dZdZddlZddlmZddlmZddlZddlmZm	Z	ddl
mZddlZddl
Z
ddlZddlZddlZddlZddlZddlZd�Zdd
�ZGd�de��Zd
�ZdZdZdd�Zdd�Zdd�Zdd�Zd d�Zedkr$eej� ����dSdS)!z=Diagnostic functions, mainly for use when doing tech support.�MIT�N)�BytesIO)�
HTMLParser)�
BeautifulSoup�__version__)�builder_registryc	���tdtz��tdtjz��gd�}|D]C}tjD]
}||jvrn(�|�|��td|z���Dd|vr�|�d��	ddl	m
}td	d
�tt|j����z��n&#t$r}td��Yd}~nd}~wwxYwd
|vrC	ddl}td|jz��n&#t$r}td��Yd}~nd}~wwxYwt#|d��r|���}n�|�d��s|�d��r#td|z��td��dS	t(j�|��rMtd|z��t/|��5}|���}ddd��n#1swxYwYn#t0$rYnwxYwtd��|D]�}td|z��d}		t3||���}
d}	n<#t4$r/}td|z��t7j��Yd}~nd}~wwxYw|	r3td|z��t|
�����td����dS)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.NrzFound html5lib version %sz2html5lib is not installed or couldn't be imported.�readzhttp: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.z7"%s" looks like a filename. Reading data from the file.�z#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�
startswith�os�path�exists�open�
ValueErrorr�	Exception�	traceback�	print_exc�prettify)�data�
basic_parsers�name�builderr�er�fp�parser�success�soups           �.D:\Python311\Lib\site-packages\bs4/diagnose.py�diagnoser4s/��
�4�{�B�D�D�D�	����,�.�.�.�7�7�7�M�����'�0�	�	�G��w�'�'�
���
�
� � ��&�&�&��M���
�
�
�����B����Z�(�(�(�	B�"�"�"�"�"�"��*�S�X�X�c�#�e�>P�6Q�6Q�-R�-R�R�T�T�T�T���	B�	B�	B��@�
B�
B�
B�
B�
B�
B�
B�
B�����	B����
�]�"�F�	F��O�O�O��.��1E�E�G�G�G�G���	F�	F�	F��D�
F�
F�
F�
F�
F�
F�
F�
F�����	F�����t�V�����y�y�{�{���	
����	!�	!��T�_�_�X�%>�%>��
�M�PT�T�V�V�V�
�A�	B�	B�	B���	��w�~�~�d�#�#�
%��P�SW�W�Y�Y�Y��$�Z�Z�%�2��7�7�9�9�D�%�%�%�%�%�%�%�%�%�%�%����%�%�%�%����	�	�	�
�D�	����	�b�	�	�	��
�
��
�4�v�=�?�?�?���	"� ���7�7�7�D��G�G���	"�	"�	"��3�f�<�>�>�>���!�!�!�!�!�!�!�!�����	"�����	%��8�6�A�C�C�C��4�=�=�?�?�$�$�$�
�x�����
�
s��AC�
C?�&C:�:C?�D#�#
E�-E�E�<AH)�<H�H)�H!�!H)�$H!�%H)�)
H6�5H6�!I5�5
J.�?%J)�)J.Tc�"�ddlm}|�dd��}t|t��r|�d��}t
|��}|j|f||d�|��D]'\}}t|�d|j	d�d|j
�����(d	S)
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.
    rr
�recoverT�utf8)�htmlr6z, z>4N)rr�pop�
isinstancer�encoder�	iterparser�tag�text)r*r8�kwargsrr6�reader�event�elements        r3�
lxml_tracerC]s����������j�j��D�)�)�G��$����#��{�{�6�"�"��
�T�]�]�F�)�%�/����7���.4���D�D���w�	����w�{�{�{�{�G�L�L�A�C�C�C�C�D�D�c�N�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
dS)
�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�$�t|��dS)N)r)�self�ss  r3�_pzAnnouncingParser._p{s��
�a�����rDc�6�|�d|z��dS)Nz%s START�rJ)rHr,�attrss   r3�handle_starttagz AnnouncingParser.handle_starttag~s�����
�T�!�"�"�"�"�"rDc�6�|�d|z��dS)Nz%s ENDrL�rHr,s  r3�
handle_endtagzAnnouncingParser.handle_endtag�s������4�� � � � � rDc�6�|�d|z��dS)Nz%s DATArL�rHr*s  r3�handle_datazAnnouncingParser.handle_data�������	�D� �!�!�!�!�!rDc�6�|�d|z��dS)Nz
%s CHARREFrLrPs  r3�handle_charrefzAnnouncingParser.handle_charref��������t�#�$�$�$�$�$rDc�6�|�d|z��dS)Nz%s ENTITYREFrLrPs  r3�handle_entityrefz!AnnouncingParser.handle_entityref�s�������%�&�&�&�&�&rDc�6�|�d|z��dS)Nz
%s COMMENTrLrSs  r3�handle_commentzAnnouncingParser.handle_comment�rXrDc�6�|�d|z��dS)Nz%s DECLrLrSs  r3�handle_declzAnnouncingParser.handle_decl�rUrDc�6�|�d|z��dS)Nz%s UNKNOWN-DECLrLrSs  r3�unknown_declzAnnouncingParser.unknown_decl�s �����!�D�(�)�)�)�)�)rDc�6�|�d|z��dS)Nz%s PIrLrSs  r3�	handle_pizAnnouncingParser.handle_pi�s������$������rDN)�__name__�
__module__�__qualname__�__doc__rJrNrQrTrWrZr\r^r`rb�rDr3rFrFss������������#�#�#�!�!�!�"�"�"�%�%�%�'�'�'�%�%�%�"�"�"�*�*�*� � � � � rDrFc�L�t��}|�|��dS)z�Print out the HTMLParser events that occur during parsing.

    This lets you see how HTMLParser parses a document when no
    Beautiful Soup code is running.

    :param data: Some markup.
    N)rF�feed)r*r0s  r3�htmlparser_tracerj�s'���
�
�F�
�K�K������rD�aeiou�bcdfghjklmnpqrstvwxyz�c��d}t|��D]1}|dzdkrt}nt}|tj|��z
}�2|S)z#Generate a random word-like string.r�r)�range�_consonants�_vowels�random�choice)�lengthrI�i�ts    r3�rwordrx�sS��
�A�
�6�]�]�����q�5�A�:�	��A�A��A�	�V�]�1�
�
�����HrD�c�Z�d�d�t|��D����S)z'Generate a random sentence-like string.� c3�ZK�|]&}ttjdd����V��'dS)ry�	N)rxrs�randint)�.0rvs  r3�	<genexpr>zrsentence.<locals>.<genexpr>�s6����F�F�1�E�&�.��1�-�-�.�.�F�F�F�F�F�FrD)rrp)rus r3�	rsentencer��s)���8�8�F�F��f�
�
�F�F�F�F�F�FrD��c	���gd�}g}t|��D]�}tjdd��}|dkr-tj|��}|�d|z���J|dkr6|�ttjdd��������|dkr,tj|��}|�d|z����d	d
�|��zdzS)z+Randomly generate an invalid HTML document.)�p�div�spanrv�b�script�tabler�z<%s>�ryroz</%s>z<html>�
z</html>)rprsr~rtrr�r)�num_elements�	tag_names�elementsrvrt�tag_names      r3�rdocr��s���A�A�A�I��H�
�<�
 �
 �0�0�����!�$�$���Q�;�		0��}�Y�/�/�H��O�O�F�X�-�.�.�.�.�
�q�[�	0��O�O�I�f�n�Q�q�&9�&9�:�:�;�;�;�;�
�q�[�	0��}�Y�/�/�H��O�O�G�h�.�/�/�/���d�i�i��)�)�)�I�5�5rD順c�D�tdtz��t|��}tdt|��z��dddgddfD]�}d}	t	j��}t||��}t	j��}d}n<#t$r/}td	|z��tj��Yd
}~nd
}~wwxYw|rtd|||z
fz����dd
l	m
}t	j��}|�|��t	j��}td||z
z��dd
l}	|	�
��}t	j��}|�|��t	j��}td||z
z��d
S)z.Very basic head-to-head performance benchmark.z1Comparative parser benchmark on Beautiful Soup %sz3Generated a large invalid HTML document (%d bytes).rr8rr
FTrNz"BS4+%s parsed the markup in %.2fs.rr
z$Raw lxml parsed the markup in %.2fs.z(Raw html5lib parsed the markup in %.2fs.)rrr��len�timerr&r'r(rr�HTMLrr�parse)
r�r*r0r1�ar2r�r.rrs
          r3�benchmark_parsersr��s���	�>��L�N�N�N�����D�	�@�3�t�9�9�L�N�N�N��F�F�+�Z��G�J�J����	"��	���A� ��v�.�.�D��	���A��G�G���	"�	"�	"��3�f�<�>�>�>���!�!�!�!�!�!�!�!�����	"�����	J��7�6�1�Q�3�-�G�I�I�I���������	���A�	�J�J�t�����	���A�	�1�Q�q�S�9�;�;�;��O�O�O�
�
 �
 �
"�
"�F��	���A�
�L�L������	���A�	�5��1��=�?�?�?�?�?s�8B�
C�%C�Crc�2�tj��}|j}t|��}t	t
||���}t
jd|||��tj	|��}|�
d��|�dd��dS)z7Use Python's profiler on a randomly generated document.)�bs4r*r0zbs4.BeautifulSoup(data, parser)�
cumulativez
_html5lib|bs4�2N)�tempfile�NamedTemporaryFiler,r��dictr��cProfile�runctx�pstats�Stats�
sort_stats�print_stats)r�r0�
filehandle�filenamer*�vars�statss       r3�profiler��s����,�.�.�J���H�����D��C�d�6�2�2�2�D��O�5��d�H�M�M�M��L��"�"�E�	���\�"�"�"�	���o�r�*�*�*�*�*rD�__main__)T)rm)ry)r�)r�)r�r)!rf�__license__r��ior�html.parserrr�rr�bs4.builderrr!r�rsr�r�r'rr4rCrFrjrrrqrxr�r�r�r�rc�stdinrrgrDr3�<module>r�s���C�C�������������"�"�"�"�"�"�
�
�
�
�*�*�*�*�*�*�*�*�(�(�(�(�(�(�	�	�	�	�
�
�
�
�
�
�
�
�������������
�
�
�
�����E�E�E�ND�D�D�D�,$ �$ �$ �$ �$ �z�$ �$ �$ �L	�	�	���%��	
�	
�	
�	
�G�G�G�G�6�6�6�6�$@�@�@�@�@+�+�+�+��z����H�S�Y�^�^�
�
�������rD