/usr/lib/python3/dist-packages/bs4/__pycache__
Edit: /usr/lib/python3/dist-packages/bs4/__pycache__/diagnose.cpython-310.pyc (8298B)
o
7aK @ s d Z dZddlZddlmZ ddlmZ ddlZddlmZm Z ddl
mZ ddlZddl
Z
ddlZddlZddlZddlZddlZddlZdd Zd#ddZG d
d deZdd ZdZdZd$ddZd%ddZd&ddZd'ddZd(d d!Zed"kreej dS dS ))z=Diagnostic functions, mainly for use when doing tech support.MIT N)StringIO)
HTMLParser)
BeautifulSoup__version__)builder_registryc C sR 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 rz
ddl}t d|j W n ty } z
t d W Y d}~nd}~ww t| dr| } nJ| ds| drt d| t d dS z&tj| rt d| t| }| } W d n1 sw Y W n ty Y nw t d |D ]E}t d| d} z
t| |d}
d} W n ty } zt d| t W Y d}~nd}~ww | r"t d| t |
t d qdS )zDiagnostic 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.parserhtml5liblxmlz;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.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 sysversionr buildersr removeappendr
r joinmapstrLXML_VERSIONImportErrorr hasattrr
startswithospathexistsopen
ValueErrorr Exception traceback print_excprettify)data
basic_parsersnamebuilderr er fpparsersuccesssoup r1 ./usr/lib/python3/dist-packages/bs4/diagnose.pydiagnose s
r3 Tc K sJ ddl m} |jt| fd|i|D ]\}}td||j|jf qdS )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 htmlz%s, %4s, %sN)r
r iterparser r tagtext)r( r4 kwargsr eventelementr1 r1 r2
lxml_trace] s "r; c @ s` e Zd ZdZdd Zdd Zdd Zdd Zd
d Zdd
Z dd Z
dd Zdd Zdd Z
dS )AnnouncingParserzSubclass 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 )selfsr1 r1 r2 _pu s zAnnouncingParser._pc C | d| d S )Nz%s STARTr? )r= r* attrsr1 r1 r2 handle_starttagx z AnnouncingParser.handle_starttagc C r@ )Nz%s ENDrA r= r* r1 r1 r2
handle_endtag{ rD zAnnouncingParser.handle_endtagc C r@ )Nz%s DATArA r= r( r1 r1 r2 handle_data~ rD zAnnouncingParser.handle_datac C r@ )Nz
%s CHARREFrA rE r1 r1 r2 handle_charref rD zAnnouncingParser.handle_charrefc C r@ )Nz%s ENTITYREFrA rE r1 r1 r2 handle_entityref rD z!AnnouncingParser.handle_entityrefc C r@ )Nz
%s COMMENTrA rG r1 r1 r2 handle_comment rD zAnnouncingParser.handle_commentc C r@ )Nz%s DECLrA rG r1 r1 r2 handle_decl rD zAnnouncingParser.handle_declc C r@ )Nz%s UNKNOWN-DECLrA rG r1 r1 r2 unknown_decl rD zAnnouncingParser.unknown_declc C r@ )Nz%s PIrA rG r1 r1 r2 handle_pi rD zAnnouncingParser.handle_piN)__name__
__module____qualname____doc__r? rC rF rH rI rJ rK rL rM rN r1 r1 r1 r2 r<