/usr/lib/python3/dist-packages/bs4/__pycache__
NameSizeModeActions
dammit.cpython-310.pyc1655490644editdlrm
diagnose.cpython-310.pyc82980644editdlrm
element.cpython-310.pyc648580644editdlrm
formatter.cpython-310.pyc60810644editdlrm
testing.cpython-310.pyc435140644editdlrm
__init__.cpython-310.pyc231550644editdlrm
Edit: /usr/lib/python3/dist-packages/bs4/__pycache__/diagnose.cpython-310.pyc (8298B)
o 7aK@sdZdZddlZddlmZddlmZddlZddlmZm Z ddl m Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZdd Zd#d d ZGd ddeZddZdZdZd$ddZd%ddZd&ddZd'ddZd(d d!Zed"kreej dSdS))z=Diagnostic functions, mainly for use when doing tech support.MITN)StringIO) HTMLParser) BeautifulSoup __version__)builder_registryc CsRtdttdtjgd}|D]}tjD] }||jvr!n q||td|qd|vrc|dzddl m }td d t t |jWntyb}z td WYd }~nd }~wwd |vrz dd l}td|jWnty}z tdWYd }~nd }~wwt|dr|}nJ|ds|drtd|tdd Sz&tj|rtd|t| }|}Wd n1swYWn tyYnwtd|D]E}td|d} z t||d} d} Wnty}ztd|tWYd }~nd }~ww| r"td|t| tdqd S)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-xmlretreezFound 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--------------------------------------------------------------------------------)printrsysversionrbuildersrremoveappendr r joinmapstr LXML_VERSION ImportErrorr hasattrr startswithospathexistsopen ValueErrorr Exception traceback print_excprettify) data basic_parsersnamebuilderr er fpparsersuccesssoupr1./usr/lib/python3/dist-packages/bs4/diagnose.pydiagnoses                    r3TcKsJddlm}|jt|fd|i|D]\}}td||j|jfqdS)aPrint 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 htmlz %s, %4s, %sN)r r iterparserrtagtext)r(r4kwargsr eventelementr1r1r2 lxml_trace]s "r;c@s`eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ 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`. cCs t|dS)N)r)selfsr1r1r2_pus zAnnouncingParser._pcC|d|dS)Nz%s STARTr?)r=r*attrsr1r1r2handle_starttagxz AnnouncingParser.handle_starttagcCr@)Nz%s ENDrAr=r*r1r1r2 handle_endtag{rDzAnnouncingParser.handle_endtagcCr@)Nz%s DATArAr=r(r1r1r2 handle_data~rDzAnnouncingParser.handle_datacCr@)Nz %s CHARREFrArEr1r1r2handle_charrefrDzAnnouncingParser.handle_charrefcCr@)Nz %s ENTITYREFrArEr1r1r2handle_entityrefrDz!AnnouncingParser.handle_entityrefcCr@)Nz %s COMMENTrArGr1r1r2handle_commentrDzAnnouncingParser.handle_commentcCr@)Nz%s DECLrArGr1r1r2 handle_declrDzAnnouncingParser.handle_declcCr@)Nz%s UNKNOWN-DECLrArGr1r1r2 unknown_declrDzAnnouncingParser.unknown_declcCr@)Nz%s PIrArGr1r1r2 handle_pirDzAnnouncingParser.handle_piN)__name__ __module__ __qualname____doc__r?rCrFrHrIrJrKrLrMrNr1r1r1r2r<ms r<cCst}||dS)zPrint 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)r<feed)r(r.r1r1r2htmlparser_tracesrTaeioubcdfghjklmnpqrstvwxyzcCs:d}t|D]}|ddkrt}nt}|t|7}q|S)z#Generate a random word-like string.rr)range _consonants_vowelsrandomchoice)lengthr>itr1r1r2rwords  racCsdddt|DS)z'Generate a random sentence-like string. css |] }ttddVqdS)rb N)rar\randint).0r_r1r1r2 szrsentence..)rrY)r^r1r1r2 rsentencesrhcCsgd}g}t|D]9}tdd}|dkr#t|}|d|q |dkr3|ttddq |dkrCt|}|d|q d d |d S) z+Randomly generate an invalid HTML document.)pdivspanr_bscripttablerz<%s>rbrXzz z)rYr\rer]rrhr) num_elements tag_nameselementsr_r]tag_namer1r1r2rdocs    rw順c Cs&tdtt|}tdt|dddgddfD]>}d}zt}t||}t}d}WntyK}ztd |tWYd }~nd }~ww|rXtd |||fqd d l m }t}| |t}td||d d l } | }t}||t}td||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 r4r rFTrNz"BS4+%s parsed the markup in %.2fs.rr z$Raw lxml parsed the markup in %.2fs.z(Raw html5lib parsed the markup in %.2fs.)rrrwlentimerr$r%r&r r HTMLr rparse) rsr(r.r/ar0rmr,r r r1r1r2benchmark_parserss:      r~r cCsXt}|j}t|}tt||d}td|||t |}| d| dddS)z7Use Python's profiler on a randomly generated document.)bs4r(r.zbs4.BeautifulSoup(data, parser) cumulativez _html5lib|bs42N) tempfileNamedTemporaryFiler*rwdictrcProfilerunctxpstatsStats sort_stats print_stats)rsr. filehandlefilenamer(varsstatsr1r1r2profiles  r__main__)T)rW)rb)ri)rx)rxr )!rR __license__rior html.parserrrrr bs4.builderrrrr\rrzr%rr3r;r<rTr[rZrarhrwr~rrOstdinrr1r1r1r2s<    G&