fjdZ ddlmZddlZddlZddlZddl m Z ddl m Z m Z mZdZej dZej dZd Zegd ZGd d eZGd deZGddeZGddeZGddeZGddeeZGddeZGddeZGddeZ Gdde Z!Gdd eZ"Gd!d"eZ#Gd#d$eZ$Gd%d&eZ%Gd'd(eZ&Gd)d*eZ'Gd+d,eZ(Gd-d.eZ)Gd/d0eZ*Gd1d2eZ+Gd3d4e,Z-y#e$rZddlmZYdZ[IdZ[wwxYw)5MIT)CallableNCSS) Formatter HTMLFormatter XMLFormatterzutf-8z\S+z\s+cLtfd}|jfd}|S)z>Alias one attribute name to another for backward compatibilityct|SNgetattrselfattrs T/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/bs4/element.pyaliasz_alias..aliastT""ct|Sr )setattrrs rrz_alias..alias!rr)propertysetter)rrs` r_aliasrs2 ## \\## Lr) idnambcsoempalmospunycoderaw_unicode_escape undefinedunicode_escapezraw-unicode-escapeunicode-escapez string-escape string_escapeceZdZdZddZy)NamespacedAttributezA namespaced string (e.g. 'xml:lang') that remembers the namespace ('xml') and the name ('lang') that were used to create it. Nc|sd}|stj||}n5|stj||}ntj||dz|z}||_||_||_|S)N:)str__new__prefixname namespace)clsr+r,r-objs rr*zNamespacedAttribute.__new__IseD++c6*C++c4(C++c6C<$#67C !  rNN)__name__ __module__ __qualname____doc__r*rrr&r&Ds rr&ceZdZdZy)%AttributeValueWithCharsetSubstitutionz=A stand-in object for a character encoding specified in HTML.Nr1r2r3r4r5rrr7r7[sGrr7ceZdZdZdZdZy)CharsetMetaAttributeValuezA generic stand-in for the value of a meta tag's 'charset' attribute. When Beautiful Soup parses the markup '', the value of the 'charset' attribute will be one of these objects. c@tj||}||_|Sr )r)r*original_value)r.r<r/s rr*z!CharsetMetaAttributeValue.__new__eskk#~.+ rc|tvry|S)zWhen an HTML document is being encoded to a given encoding, the value of a meta tag's 'charset' is the name of the encoding. )PYTHON_SPECIFIC_ENCODINGSrencodings rencodez CharsetMetaAttributeValue.encodejs 0 0rN)r1r2r3r4r*rBr5rrr:r:^s  rr:cVeZdZdZej dej ZdZdZ y)ContentMetaAttributeValueaA generic stand-in for the value of a meta tag's 'content' attribute. When Beautiful Soup parses the markup: The value of the 'content' attribute will be one of these objects. z((^|;)\s*charset=)([^;]*)c|jj|}|tjt|Stj||}||_|Sr ) CHARSET_REsearchr)r*r<)r.r<matchr/s rr*z!ContentMetaAttributeValue.__new__~sI%%n5 =;;sN3 3kk#~.+ rcltvryfd}|jj||jS)Nr>c,|jdzS)N)group)rHrAs rrewritez1ContentMetaAttributeValue.encode..rewrites;;q>H, ,r)r?rFsubr<)rrArMs ` rrBz ContentMetaAttributeValue.encodes1 0 0 -""7D,?,?@@rN) r1r2r3r4recompileMrFr*rBr5rrrDrDss+8"$$?JArrDcleZdZdZdZ d1dZdZdZedZ e dZ e dZ e Zd efd Zed Zd d efd ZeZeeZdZeZdZeZeZdZd2dZd3dZeZdZdZdZdZ dZ!didfdZ"e"Z#diddfdZ$e$Z%didfdZ&e&Z'diddfdZ(e(Z)e(Z*didfdZ+e+Z,diddfdZ-e-Z.e-Z/didfdZ0e0Z1diddfdZ2e2Z3e2Z4difd Z5e5Z6didfd!Z7e7Z8e7Z9ed"Z:ed#Z;d$Zed'Z?ed(Z@ed)ZAed*ZBed+ZCd,ZDd-ZEd.ZFd/ZGd0ZHy)4 PageElementzContains the navigational information for some part of the page: that is, its current location in the parse tree. NavigableString, Tag, etc. are all subclasses of PageElement. Nc||_||_|||j_||_|j||j_||_|j||j_|;|j/|jj r|jj d}||_|||j_yy)aJSets up the initial relations between this element and other elements. :param parent: The parent of this element. :param previous_element: The element parsed immediately before this one. :param next_element: The element parsed immediately before this one. :param previous_sibling: The most recently encountered element on the same level of the parse tree as this one. :param previous_sibling: The next element to be encountered on the same level of the parse tree as this one. N)parentprevious_element next_element next_siblingprevious_siblingcontents)rrVrWrXrZrYs rsetupzPageElement.setups& 0  '15D ! ! .(    (15D   .(    (15D   .  $ 'DKK,@,@#{{33B7  0  '15D ! ! . (rcr||St|ts|j|}|j|}|S)zFormat the given string using the given formatter. :param s: A string. :param formatter: A Formatter object, or a string naming one of the standard formatters. ) isinstancerformatter_for_name substitute)rs formatteroutputs r format_stringzPageElement.format_strings>  H)Y/// :I%%a( rct|tr|S|jrt}nt}t|t r ||S|j |S)a|Look up or create a Formatter for the given identifier, if necessary. :param formatter: Can be a Formatter object (used as-is), a function (used as the entity substitution hook for an XMLFormatter or HTMLFormatter), or a string (used to look up an XMLFormatter or HTMLFormatter in the appropriate registry. )entity_substitution)r^r_is_xmlr rrREGISTRY)rrbcs rr_zPageElement.formatter_for_namesI i +  <<AA i *3 3zz)$$rc|j |jS|j t|ddS|jjS)aIs this element part of an XML tree or an HTML tree? This is used in formatter_for_name, when deciding whether an XMLFormatter or HTMLFormatter is more appropriate. It can be inefficient, but it should be called very rarely. is_xmlF) known_xmlrVrrgrs rrgzPageElement._is_xmlsG >> %>> ! ;; 451 1{{"""rrYrZFct)zYield all strings of certain classes, possibly stripping them. This is implemented differently in Tag and NavigableString. )NotImplementedError)rstriptypess r _all_stringszPageElement._all_stringss "##rc#@K|jdD]}|yw)zvYield all strings in this PageElement, stripping them first. :yield: A sequence of stripped strings. TN)rrrstrings rstripped_stringszPageElement.stripped_stringss" ''-FL.r>cl|j|j||Dcgc]}|c}Scc}w)aGet all child strings of this PageElement, concatenated using the given separator. :param separator: Strings will be concatenated using this separator. :param strip: If True, strings will be stripped before being concatenated. :param types: A tuple of NavigableString subclasses. Any strings of a subclass not found in this list will be ignored. Although there are exceptions, the default behavior in most cases is to consider only NavigableString and CData objects. That means no comments, processing instructions, etc. :return: A string. )rq)joinrr)r separatorrprqras rget_textzPageElement.get_texts@&~~$*;*;+<+()Qq)* *)s 1c`j tdt|dk(r|durytfd|Dr tdj}jj }j |t ||D]\}}|j||S) zReplace this PageElement with one or more PageElements, keeping the rest of the tree the same. :param args: One or more PageElements. :return: `self`, no longer part of the tree. Nz^Cannot replace one element with another when the element to be replaced is not part of a tree.rKrc3:K|]}|juywr rV.0xrs r z+PageElement.replace_with..6s.AqDKK.sz%Cannot replace a Tag with its parent. _self_index)start)rV ValueErrorlenanyindexextract enumerateinsert)rargs old_parentmy_indexidx replace_withs` rrzPageElement.replace_with)s ;; @A A t9>d1go  .. .DE E[[ ;;$$T*  *!*4x!@ C   c< 0"A rc|j}|j td|jj|}|j|t |j ddD]}|j |||S)zjReplace this PageElement with its contents. :return: `self`, no longer part of the tree. NzSCannot replace an element with its contents when thatelement is not part of a tree.r)rVrrrreversedr[r)r my_parentrchilds runwrapzPageElement.unwrap@sz KK ;; 12 2;;$$T*  *dmmA./E   Xu -0 rcJ|j|}|j||S)zWrap this PageElement inside another one. :param wrap_inside: A PageElement. :return: `wrap_inside`, occupying the position in the tree that used to be occupied by `self`, and with `self` inside it. )rappend)r wrap_insidemes rwrapzPageElement.wrapRs(  { +2rc|j4||jj|}|jj|=|j}|j}|j |j |ur||j _|||j ur|j |_d|_d|_d|_|j 3|j |jur|j|j _|j3|j|j ur|j |j_dx|_|_|S)aDestructively rips this element out of the tree. :param _self_index: The location of this element in its parent's .contents, if known. Passing this in allows for a performance optimization. :return: `self`, no longer part of the tree. N)rVrr[_last_descendantrXrWrZrY)rr last_childrXs rrzPageElement.extract]s2 ;; """kk//5  $$[1 **, !..  ! ! -  ! ! 51=D ! ! .  # D->>151B1BD ! ! .    )!!)>)>>151F1FD   .488 1 rc|r#|j|jj}nJ|}t|tr8|jr,|jd}t|tr |jr,|s||urd}|S)zFinds the last element beneath this object to be parsed. :param is_initialized: Has `setup` been called on this PageElement yet? :param accept_self: Is `self` an acceptable answer to the question? NrU)rYrWr^Tagr[)ris_initialized accept_selfrs rrzPageElement._last_descendantss d//;**;;JJZ-*2E2E'004 Z-*2E2EzT1Jrc| td||ur tdt|trt|ts t|}ddlm}t||r2t |jD]}|j|||dz }yt|t|j}t|drE|j9|j|ur|j|}||kr|dz}|j||_ d}|dk(rd|_||_n@|j|dz }||_||j_|j%d|_|j ||j _|j%d}|t|jk\rAd|_|}d} | "| |j"} |j}| n| | | | |_nBd|_n:|j|} | |_|j"||j"_| |_|j&||j&_|jj||y) a&Insert a new PageElement in the list of this PageElement's children. This works the same way as `list.insert`. :param position: The numeric position that should be occupied in `self.children` by the new PageElement. :param new_child: A PageElement. NzCannot insert None into a tag.z Cannot insert a tag into itself.r) BeautifulSouprKrVF)rr^r)NavigableStringbs4rlistr[rminrhasattrrVrrrZrWrYrrX) rposition new_childrsubchild current_indexprevious_childnew_childs_last_elementrVparents_next_sibling next_childs rrzPageElement.insertsW  => >  ?@ @ y# &y/:' 2I% i /!!3!34 Hh/A 5 xT]]!34 9h 'I,<,<,H4' $ 9 5  8+ MH      q=)-I &)-I &!]]8a<8N)7I &6?I & & 3)7)H)H)OI &  % % 16?I & & 3"+"<". 'QqDy'z&Can't insert an element before itself.rVrrr^rSrrr)rrrV predecessorrs` r insert_beforezPageElement.insert_befores} >DF F '$' ' !IJJK+{3##%LL&E MM% -  rc$j}| tdtfd|Dr tdd}|D]P}t|tr|j |j }|j|dz|z||dz }Ry)zMakes the given element(s) the immediate successor of this one. The elements will have the same parent, and the given elements will be immediately after this one. :param args: One or more PageElements. Nz1Element has no parent, so 'after' has no meaning.c3&K|]}|u ywr r5rs rrz+PageElement.insert_after.."rrz%Can't insert an element after itself.rrKr)rrrVoffset successorrs` r insert_afterzPageElement.insert_afters >CE E '$' 'DE EI)[1!!#LL&E MM%'&.) 4 aKFrc B|j|j|||fi|S)aUFind the first PageElement that matches the given criteria and appears later in the document than this PageElement. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString ) _find_one find_all_nextrr,attrsrukwargss r find_nextzPageElement.find_next/s&t~~d00$vPPPrc r|jdd}|j|||||jfd|dzi|S)aiFind all PageElements that match the given criteria and appear later in the document than this PageElement. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A ResultSet containing PageElements. _stacklevelrK)pop _find_all next_elementsrr,rrulimitrrs rrzPageElement.find_all_next@sOjj2 t~~dE65$:L:LC*5a-C;AC Crc B|j|j|||fi|S)aQFind the closest sibling to this PageElement that matches the given criteria and appears later in the document. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString )rfind_next_siblingsrs rfind_next_siblingzPageElement.find_next_siblingTs-t~~d55tUF'%' 'rc r|jdd}|j|||||jfd|dzi|S)aFind all siblings of this PageElement that match the given criteria and appear later in the document. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A ResultSet of PageElements. :rtype: bs4.element.ResultSet rrrK)rr next_siblingsrs rrzPageElement.find_next_siblingsfsM jj2 t~~ %    ,7M =C  rc B|j|j|||fi|S)aVLook backwards in the document from this PageElement and find the first PageElement that matches the given criteria. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString )rfind_all_previousrs r find_previouszPageElement.find_previous~s1t~~  " "D%C;AC Crc r|jdd}|j|||||jfd|dzi|S)aLook backwards in the document from this PageElement and find all PageElements that match the given criteria. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A ResultSet of PageElements. :rtype: bs4.element.ResultSet rrrK)rrprevious_elementsrs rrzPageElement.find_all_previoussL jj2 t~~ %(>(> #A  )/  rc B|j|j|||fi|S)aVReturns the closest sibling to this PageElement that matches the given criteria and appears earlier in the document. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString )rfind_previous_siblingsrs rfind_previous_siblingz!PageElement.find_previous_siblings-t~~d994'%' 'rc r|jdd}|j|||||jfd|dzi|S)aReturns all siblings to this PageElement that match the given criteria and appear earlier in the document. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A ResultSet of PageElements. :rtype: bs4.element.ResultSet rrrK)rrprevious_siblingsrs rrz"PageElement.find_previous_siblingssM jj2 t~~ %  " " 0;A  AG  rc Fd}|j||dfddi|}|r|d}|S)aFind the closest parent of this PageElement that matches the given criteria. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString NrKrr) find_parents)rr,rrrls r find_parentzPageElement.find_parents:  D  dE1 F! Fv F !Arc r|jdd}|j||d||jfd|dzi|S)aFind all parents of this PageElement that match the given criteria. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString rrNrK)rrparents)rr,rrrrs rrzPageElement.find_parentssMjj2 t~~dE4 C*5a-C;AC Crc|jS)zThe PageElement, if any, that was parsed just after this one. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString rXrms rnextzPageElement.nexts   rc|jS)zThe PageElement, if any, that was parsed just before this one. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString rWrms rpreviouszPageElement.previouss$$$rc 4d}||||dfddi|}|r|d}|S)NrKrrr5)rmethodr,rrurrrs rrzPageElement._find_ones2  4 Cq CF C !Arc  |jdd}|1d|vr-|jd}tjdt|t t r}nt ||fi|}|x|sv|st|srdusd|D} t || St trGjd d k(rjd d \ nd fd |D} t || St |} t|} | r7|j| } | r$| j| |rt| |k\r | SF#t$rY| SwxYw) z8Iterates over a generator looking for things that match.rrNtextzOThe 'text' argument to find()-type methods is deprecated. Use 'string' instead. stacklevelTc3@K|]}t|tr|ywr )r^r)relements rrz(PageElement._find_all..+s!7g'5"7rwr(rKc3K|]E}t|tr|jk(s |jk(r|jk(r|Gywr )r^rr,r+)rr local_namer,r+s rrz(PageElement._find_all..8sJg'5%lld2%llj8#)>W^^v5M "sA A)rwarningswarnDeprecationWarningr^ SoupStrainer ResultSetr)countsplitr StopIterationrGrr)rr,rrur generatorrrstrainerresultresultsifoundrr+s ` @@rrzPageElement._find_allsajj2 >f.ZZ'F MMa"{  dL )H#D%B6BH >%ft|t|77 622D#&::c?a'*.C);&FJ!F!%J!622H% O *NN5)W!6!  s1 D66 EEc#PK|j}|||j}|yyw)zgAll PageElements that were parsed after this one. :yield: A sequence of PageElements. Nrrrs rrzPageElement.next_elementsRs-   mGAm!&&c#PK|j}|||j}|yyw)zAll PageElements that are siblings of this one but were parsed later. :yield: A sequence of PageElements. N)rYr s rrzPageElement.next_siblings]s-   mGAmr c#PK|j}|||j}|yyw)zhAll PageElements that were parsed before this one. :yield: A sequence of PageElements. Nrr s rrzPageElement.previous_elementsis/  ! !mG""Amr c#PK|j}|||j}|yyw)zAll PageElements that are siblings of this one but were parsed earlier. :yield: A sequence of PageElements. N)rZr s rrzPageElement.previous_siblingsts/  ! !mG""Amr c#PK|j}|||j}|yyw)zlAll PageElements that are parents of this PageElement. :yield: A sequence of PageElements. Nr~r s rrzPageElement.parentss+ KKmGAmr c$t|ddxsdS)zOCheck whether a PageElement has been decomposed. :rtype: bool _decomposedFr rms r decomposedzPageElement.decomposeds t]E2;e;rc|jSr )rrms r nextGeneratorzPageElement.nextGenerator!!!rc|jSr )rrms rnextSiblingGeneratorz PageElement.nextSiblingGeneratorrrc|jSr )rrms rpreviousGeneratorzPageElement.previousGenerator%%%rc|jSr )rrms rpreviousSiblingGeneratorz$PageElement.previousSiblingGeneratorrrc|jSr )rrms rparentGeneratorzPageElement.parentGenerators ||r)NNNNNr )TT)Ir1r2r3r4rlr\rdr_rrgr nextSiblingpreviousSiblingobjectdefaultrrrvr{getTextrr replaceWithrreplace_with_childrenreplaceWithChildrenrrr_lastRecursiveChildrrrrrrfindNextr findAllNextrfindNextSiblingrfindNextSiblingsfetchNextSiblingsr findPreviousrfindAllPrevious fetchPreviousrfindPreviousSiblingrfindPreviousSiblingsfetchPreviousSiblingsr findParentr findParents fetchParentsrrrrrrrrrrrrrrrr5rrrSrSsIEI26'6R %(##,(K/0OhG!&g$"$5**G H D*K#  $L"+P2d- .,4"DQH!%RDC$ K%)D' (O&*"T ***!%RC !L%)D *(O%M)-R' 0*.b%) *22#2*J $BdC"KL !!%%6t  ## # #<<""&&rrSceZdZdZdZdZdZddZdZdZ dZ dd Z e d Z e jd Z dej fd Ze eZy )rzA Python Unicode string that is part of a parse tree. When Beautiful Soup parses the markup penguin, it will create a NavigableString for the string "penguin". r>ct|trtj||}ntj||t}|j |S)a-Create a new NavigableString. When unpickling a NavigableString, this method is called with the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be passed in to the superclass's __new__ or the superclass won't know how to handle non-ASCII characters. )r^r)r*DEFAULT_OUTPUT_ENCODINGr\)r.valueus rr*zNavigableString.__new__s? eS ! C'A C(?@A  rFc$t||S)a>A copy of a NavigableString has the same contents and class as the original, but it is not connected to the parse tree. :param recursive: This parameter is ignored; it's only defined so that NavigableString.__deepcopy__ implements the same signature as Tag.__deepcopy__. )type)rmemo recursives r __deepcopy__zNavigableString.__deepcopy__stDz$rc$|jiS)zA copy of a NavigableString can only be a deep copy, because only one PageElement can occupy a given place in a parse tree. r>rms r__copy__zNavigableString.__copy__  $$rct|fSr )r)rms r__getnewargs__zNavigableString.__getnewargs__sD |rc\|dk(r|Std|jjd|d)ztext.string gives you text. This is for backwards compatibility for Navigable*String, but for CData* it lets you get the string without the CData wrapper.ru'' object has no attribute ')AttributeError __class__r1rs r __getattr__zNavigableString.__getattr__s2 8 K NN++T34 4rc^|j||}|j|z|jzS)zRun the string through the provided formatter. :param formatter: A Formatter object, or a string naming one of the standard formatters. rdPREFIXSUFFIX)rrbrcs r output_readyzNavigableString.output_readys. ##D)4{{V#dkk11rcy)zSince a NavigableString is not a Tag, it has no .name. This property is implemented so that code like this doesn't crash when run on a mixture of Tag and NavigableString objects: [x.name for x in tag.children] Nr5rms rr,zNavigableString.namesrctd)z1Prevent NavigableString.name from ever being set.z)A NavigableString cannot be given a name.rH)rr,s rr,zNavigableString.namesHIIrc#K||jurtj}t|}|t |tr||ury||vry|}|r|j }t |dkDr|yyw)aYield all strings of certain classes, possibly stripping them. This makes it easy for NavigableString to implement methods like get_text() as conveniences, creating a consistent text-extraction API across all PageElements. :param strip: If True, all strings will be stripped before being yielded. :param types: A tuple of NavigableString subclasses. If this NavigableString isn't one of those subclasses, the sequence will be empty. By default, the subclasses considered are NavigableString and CData objects. That means no comments, processing instructions, etc. :yield: A sequence that either contains this string, or is empty. Nr)r!r DEFAULT_INTERESTING_STRING_TYPESr;r^rpr)rrprqmy_typer8s rrrzNavigableString._all_stringssz& DLL 88Et*  %&%'% KKME u:>K sA.A0NF)minimal)r1r2r3r4rMrNr*r>rArDrJrOrr,rrSr!rrstringsr5rrrrs~ F F  %  42 [[JJ"'k.A.A-\|$Grrc eZdZdZdZdZddZy)PreformattedStringzA NavigableString not subject to the normal formatting rules. This is an abstract class used for special kinds of strings such as comments (the Comment class) and CDATA blocks (the CData class). r>Ncb||j||}|j|z|jzS)aMake this string ready for output by adding any subclass-specific prefix or suffix. :param formatter: A Formatter object, or a string naming one of the standard formatters. The string will be passed into the Formatter, but only to trigger any side effects: the return value is ignored. :return: The string, with any subclass-specific prefix and suffix added on. rL)rrbignores rrOzPreformattedString.output_ready.s4  ''i8F{{T!DKK//rr )r1r2r3r4rMrNrOr5rrrZrZ#sF F0rrZceZdZdZdZdZy)CDatazA CDATA block.z Nr1r2r3r4rMrNr5rrr^r^>s F Frr^ceZdZdZdZdZy)ProcessingInstructionzA SGML processing instruction.Nr_r5rrraraCs( F FrraceZdZdZdZdZy)XMLProcessingInstructionzAn XML processing instruction.rb?>Nr_r5rrrereIs( F FrreceZdZdZdZdZy)CommentzAn HTML or XML comment.zNr_r5rrrhrhNs! F FrrhceZdZdZdZdZy) DeclarationzAn XML declaration.rbrfNr_r5rrrjrjTs F Frrjc(eZdZdZedZdZdZy)DoctypezA document type declaration.cv|xsd}||d|zz }||d|zz }t|S||d|zz }t|S)aGenerate an appropriate document type declaration for a given public ID and system ID. :param name: The name of the document's root element, e.g. 'html'. :param pub_id: The Formal Public Identifier for this document type, e.g. '-//W3C//DTD XHTML 1.1//EN' :param system_id: The system identifier for this document type, e.g. 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' :return: A Doctype. r>z PUBLIC "%s"z "%s"z SYSTEM "%s")rl)r.r,pub_id system_idr8s rfor_name_and_idszDoctype.for_name_and_ids\sd    ^f, ,E$9,,u~ " ^i/ /Eu~rz N)r1r2r3r4 classmethodrprMrNr5rrrlrlZs#&,F FrrlceZdZdZy) StylesheetzA NavigableString representing an stylesheet (probably CSS). Used to distinguish embedded stylesheets from textual content. Nr8r5rrrsrsw   rrsceZdZdZy)ScriptzA NavigableString representing an executable script (probably Javascript). Used to distinguish executable code from textual content. Nr8r5rrrvrvrtrrvceZdZdZy)TemplateStringzA NavigableString representing a string found inside an HTML template embedded in a larger document. Used to distinguish such strings from the main body of the document. Nr8r5rrrxrxrtrrxceZdZdZy)RubyTextStringzA NavigableString representing the contents of the HTML element. https://dev.w3.org/html5/spec-LC/text-level-semantics.html#the-rt-element Can be used to distinguish such strings from the strings they're annotating. Nr8r5rrrzrzs  rrzceZdZdZy)RubyParenthesisStringzA NavigableString representing the contents of the HTML element. https://dev.w3.org/html5/spec-LC/text-level-semantics.html#the-rp-element Nr8r5rrr|r|rtrr|ceZdZdZ d;dZedZddZd>dZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'd Z(d?d!Z)d"Z*e*xZ+Z)e,dd#d$fd%Z-de,d#dfd&Z.e/Z0e/Z1e/Z2e/Z3d>d'Z4d(Z5d)Z6d@d*Z7dAd+Z8de,d#fd,Z9de,d#fd-Z:e,d d.fd/Z;diddfd0Ze>Z?e>Z@e d2ZAe d3ZBe d4ZCd>d5ZDdBd6ZEe d7ZFd8ZGd9ZHd:ZIy)CrzRepresents an HTML or XML tag that is part of a parse tree, along with its attributes and contents. When Beautiful Soup parses the markup penguin, it will create a Tag object representing the tag. NcJ|d|_n|j|_| td||_||_|xsi|_||_|r |jr| | | |_| |_ |i}nD|r7|)|jr|j|j|}nt|}n t|}|r|j|_n| |_||_g|_|j#||d|_|| |_| |_ ||_||_y|j-||j'||_|j|_ |j(|_|j|j.vr|j.|j|_y|j0|_y)aMBasic constructor. :param parser: A BeautifulSoup object. :param builder: A TreeBuilder. :param name: The name of the tag. :param namespace: The URI of this Tag's XML namespace, if any. :param prefix: The prefix for this Tag's XML namespace, if any. :param attrs: A dictionary of this Tag's attribute values. :param parent: The PageElement to use as this Tag's parent. :param previous: The PageElement that was parsed immediately before this tag. :param is_xml: If True, this is an XML tag. Otherwise, this is an HTML tag. :param sourceline: The line number where this tag was found in its source document. :param sourcepos: The character position within `sourceline` where this tag was found. :param can_be_empty_element: If True, this tag should be represented as . If False, this tag should be represented as . :param cdata_list_attributes: A list of attributes whose values should be treated as CDATA if they ever show up on this tag. :param preserve_whitespace_tags: A list of tag names whose contents should have their whitespace preserved. :param interesting_string_types: This is a NavigableString subclass or a tuple of them. When iterating over this Tag's strings in methods like Tag.strings or Tag.get_text, these are the types of strings that are interesting enough to be considered. The default is to consider NavigableString and CData the only interesting string subtypes. :param namespaces: A dictionary mapping currently active namespace prefixes to URIs. This can be used later to construct CSS selectors. Nz%No value provided for new tag's name.F) parser_classrIrr,r- _namespacesr+store_line_numbers sourceline sourceposcdata_list_attributes$_replace_cdata_list_attribute_valuesdictrkrlrr[r\hiddencan_be_empty_elementpreserve_whitespace_tagsinteresting_string_typesset_up_substitutionsstring_containersrT)rparserbuilderr,r-r+rrVrrkrrrrrr namespacess r__init__z Tag.__init__sV > $D !' 0 0D  <DE E "%+ G66'9+@(DO&DN =E "w'D'DDDIIu&U KE $^^DN#DN   68$ ?)=D %)>D &,DD ),DD )  ( ( .)0(D(DT(JD %*1)F)FD &-4,L,LD )yyG555180I0I$))0T-040U0U-rrTcR|j}|r|g}|j|jD]s\}}|tjur|j )|j |d}|dj||tjusc|j|u|S)zA deepcopy of a Tag is a new Tag, unconnected to the parse tree. Its contents are a copy of the old Tag's contents. F)r=rU) _clone _event_stream descendantsrEND_ELEMENT_EVENTrr>rSTART_ELEMENT_EVENT)rr<r=clone tag_stackeventrdescendant_clones rr>zTag.__deepcopy__&s  I"&"4"4T5E5E"FwC111MMO'.';';(<($bM(()9: 7 77"(()9:#G  rc$|jiS)zyA copy of a Tag must always be a deep copy, because a Tag's children can only have one parent at a time. r@rms rrAz Tag.__copy__BrBrcZt|dd|j|j|j|j|j |j |j|j|j|j|j }dD]}t||t|||S)zCreate a new Tag just like this one, but with no contents and unattached to any parse tree. This is the first step in the deepcopy process. N)rkrrrrrr)rr)r;r,r-r+rrgrrrrrrrr)rrrs rrz Tag._cloneHs T $ 4>> KKDLL$..!%!:!:"&"<"<%)%B%B%)%B%B 7D E4t!4 57 rcNt|jdk(xr |jS)a7Is this tag an empty-element tag? (aka a self-closing tag) A tag that has contents is never an empty-element tag. A tag that has no contents may or may not be an empty-element tag. It depends on the builder used to create the tag. If the builder has a designated list of empty-element tags, then only a tag whose name shows up in that list is considered an empty-element tag. If the builder has no designated list of empty-element tags, then any tag with no contents is an empty-element tag. r)rr[rrms ris_empty_elementzTag.is_empty_element[s#4==!Q&D4+D+DDrct|jdk7ry|jd}t|tr|S|jS)aConvenience property to get the single string within this PageElement. TODO It might make sense to have NavigableString.string return itself. :return: If this element has a single string child, return value is that string. If this element has one child tag, return value is the 'string' attribute of the child tag, recursively. If this element is itself a string, has no children, or has more than one child, return value is None. rKNr)rr[r^rru)rrs rruz Tag.stringms? t}}  " a  e_ -L||rcd|j|j|j|y)z2Replace this PageElement's contents with `string`.N)clearrrIrts rruz Tag.strings$  F$$V,-rFc# K||jur |j}|jD]a}|t|tst |}t|t r||ur6|||vr=|r|j }t|dk(r^|cyw)a|Yield all strings of certain classes, possibly stripping them. :param strip: If True, all strings will be stripped before being yielded. :param types: A tuple of NavigableString subclasses. Any strings of a subclass not found in this list will be ignored. By default, the subclasses considered are the ones found in self.interesting_string_types. If that's not specified, only NavigableString and CData objects will be considered. That means no comments, processing instructions, etc. :yield: A sequence of strings. Nr)r!rrr^rr;rpr)rrprq descendantdescendant_types rrrzTag._all_stringss" DLL 11E**J j_&M":.O%&"%/"e'C'--/ z?a' +sB Bc|j|}|:|j}|jjg|_d|_|}|9yy)aRecursively destroys this PageElement and its children. This element will be removed from the tree and wiped out; so will everything beneath it. The behavior of a decomposed PageElement is undefined and you should never use one for anything, but if you need to _check_ whether an element has been decomposed, you can use the `decomposed` property. NT)rrX__dict__rr[r)rrns r decomposez Tag.decomposesJ  mA JJ   AJ AMA mrc|rF|jddD]3}t|tr|j$|j 5y|jddD]}|j y)zWipe out all children of this PageElement by calling extract() on them. :param decompose: If this is True, decompose() (a more destructive method) will be called instead of extract(). N)r[r^rrr)rrrs rrz Tag.clearsY ==+gs+%%'OO% ,  ==+!,rcHg}t|jD]\}}t|tr|j |t |jdz k(rB|j|dz}t|t set|t svt|trt|tr|j|t|D]R}|j|}|j|dz}|jt ||z}|j|Ty)zSmooth out this element's children by consolidating consecutive strings. This makes pretty-printed output look more natural following a lot of operations that modified the tree. rKN) rr[r^rsmoothrrrZrrrr)rmarkedrabrs rrz Tag.smoothsdmm,DAq!S! C &q(( ac"A1o.q/2"1&89"1&89 a -&&!A a A ac"A IIK!$A NN1  "rcbt|jD] \}}||us |cStd)zFind the index of a child by identity, not value. Avoids issues with tag.contents.index(element) getting the index of equal elements. :param element: Look for this PageElement in `self.contents`. zTag.index: element not in tag)rr[r)rrrrs rrz Tag.indexs6"$--0HAu1899rc:|jj||S)zReturns the value of the 'key' attribute for the tag, or the value given for 'default' if it doesn't have that attribute.)rget)rkeyr!s rrzTag.getszz~~c7++rcP|j||}t|ts|g}|S)a&The same as get(), but always returns a list. :param key: The attribute to look for. :param default: Use this value if the attribute is not present on this PageElement. :return: A list of values, probably containing only a single value. )rr^r)rrr!r8s rget_attribute_listzTag.get_attribute_list s*g&%&GE rc||jvS)z !37>>3 GI IrcL||uryt|drat|drUt|drI|j|jk7s0|j|jk7st|t|k7ryt |j D]\}}||j |k7syy)zyReturns true iff this Tag has the same name, the same attributes, and the same contents (recursively) as `other`.Tr,rr[F)rr,rrrr[)rotherrmy_childs r__eq__z Tag.__eq__Xs 5=v&w'z* II # JJ%++ % IU #$T]]3KAx5>>!,,4rc||k( S)zTReturns true iff this Tag is not identical to `other`, as defined in __eq__.r5)rrs r__ne__z Tag.__ne__is5=  rc"|jS)zRenders this PageElement as a string. :param encoding: The encoding to use (Python 2 only). TODO: This is now ignored and a warning should be issued if a value is provided. :return: A (Unicode) string. decoder@s r__repr__z Tag.__repr__ns{{}rc"|jS)z-Renders this PageElement as a Unicode string.rrms r __unicode__zTag.__unicode__ys{{}rrWxmlcharrefreplacecL|j|||}|j||S)aRender a bytestring representation of this PageElement and its contents. :param encoding: The destination encoding. :param indent_level: Each line of the rendering will be indented this many levels. (The formatter decides what a 'level' means in terms of spaces or other characters output.) Used internally in recursive calls while pretty-printing. :param formatter: A Formatter object, or a string naming one of the standard formatters. :param errors: An error handling strategy such as 'xmlcharrefreplace'. This value is passed along into encode() and its value should be one of the constants defined by Python. :return: A bytestring. rrB)rrA indent_levelrberrorsr9s rrBz Tag.encodes'. KK h :xx&))rc g}t|ts|j|}|durd}d}|j|D]4\}}|tj tj fvr|j||d} n?|tjur|j||d} ||dz}n|j|} |rdx} } ndx} } |tj ur|s|jsd} d} |}n|tjur ||urd} d} d}|S| s| r7t|tr| j} | r|j| ||| | } |tj k(r|dz }|j| 7dj|S)NTr)openingFrKr>)r^rr_rrrEMPTY_ELEMENT_EVENT _format_tagrrO_should_pretty_printrrp_indent_stringrry) rreventual_encodingrbiteratorpiecesstring_literal_tagrrpiece indent_before indent_afters rrz Tag.decodes)Y/// :I 4 L""00:NE700#2I2IJJ++%y$,#///++%y%, + A%L,,Y7"/44 /33 000*446 %)M#(L)0&3000!33!& # %)"'!\!'?; %  $ 3 3!<)<!C333 A%L MM% ;@wwvrc#Kg}|xs |j}|D]}|rK|j|dk7r9|j}tj|f|r|j|dk7r9t |trG|j rtj|ftj|f|j|tj|f|r(|j}tj|f|r'yyw)a]Yield a sequence of events that can be used to reconstruct the DOM for this element. This lets us recreate the nested structure of this element (e.g. when formatting it as a string) without using recursive method calls. This is similar in concept to the SAX API, but it's a simpler interface designed for internal use. The events are different from SAX and the arguments associated with the events are Tags and other Beautiful Soup objects. :param iterator: An alternate iterator to use when traversing the tree. rUN) self_and_descendantsrVrrrr^rrrrSTRING_ELEMENT_EVENT)rrrrinow_closed_tags rrzTag._event_streams  8t88AIbM 9!*++^;;IbM 9!S!%%1114411144$$Q'..11!$&]]_N''7 7sA$C?'BC?=C?cHd}|r|r|j|z}d}|rd}||z|zS)aAdd indentation whitespace before and/or after a string. :param s: The string to amend with whitespace. :param indent_level: The indentation level; affects how much whitespace goes before the string. :param indent_before: Whether or not to add whitespace before the string. :param indent_after: Whether or not to add whitespace (a newline) after the string. r> )indent)rrarrbrr space_before space_afters rrzTag._indent_string!s; \%,,|;L Ka+--rc|jryd}|sd}d}|jr|jdz}d}|r|j|}g}|D]\} } | | } nt| tst| t rdj | } n?t| ts t| } n#t| tr|| j|} |j| } t| dz|j| z} |j| |rddj |z}d} |jr|jxsd} d|z|z|jz|z| zdzS)Nr>/r( = in HTML documents) should not. N)rr,)rrs rrzTag._should_pretty_printms:  $ 111B99D$A$AA  rcT||jd|S|j|d|S)a~Pretty-print this PageElement as a string. :param encoding: The eventual encoding of the string. If this is None, a Unicode string will be returned. :param formatter: A Formatter object, or a string naming one of the standard formatters. :return: A Unicode string (if encoding==None) or a bytestring (otherwise). T)rbr)rrArbs rprettifyz Tag.prettify{s2  ;;ty;9 9;;x;C Crc@|j||||jS)a,Renders the contents of this tag as a Unicode string. :param indent_level: Each line of the rendering will be indented this many levels. (The formatter decides what a 'level' means in terms of spaces or other characters output.) Used internally in recursive calls while pretty-printing. :param eventual_encoding: The tag is destined to be encoded into this encoding. decode_contents() is _not_ responsible for performing that encoding. This information is passed in so that it can be substituted in if the document contains a tag that mentions the document's encoding. :param formatter: A Formatter object, or a string naming one of the standard Formatters. )r)rr)rrrrbs rdecode_contentszTag.decode_contentss*,{{<):I$($4$46 6rcJ|j|||}|j|S)a:Renders the contents of this PageElement as a bytestring. :param indent_level: Each line of the rendering will be indented this many levels. (The formatter decides what a 'level' means in terms of spaces or other characters output.) Used internally in recursive calls while pretty-printing. :param eventual_encoding: The bytestring will be in this encoding. :param formatter: A Formatter object, or a string naming one of the standard Formatters. :return: A bytestring. )rrB)rrrArbr[s rencode_contentszTag.encode_contentss'$'' h Jx((rrc0|sd}|j||S)z(Deprecated method for BS3 compatibility.N)rrA)r)rrA prettyPrint indentLevels rrenderContentszTag.renderContentss)K##$x$9 9rc Jd}|j||||dfddi|}|r|d}|S)aLook in the children of this PageElement and find the first PageElement that matches the given criteria. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param recursive: If this is True, find() will perform a recursive search of this PageElement's children. Otherwise, only the direct children will be considered. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A PageElement. :rtype: bs4.element.Tag | bs4.element.NavigableString NrKrrrr)rr,rr=rurrrs rrzTag.findsC$  DMM$y&! $ $" $ !Arc |j}|s |j}|jdd}|j|||||fd|dzi|S)aLook in the children of this PageElement and find all PageElements that match the given criteria. All find_* methods take a common set of arguments. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param recursive: If this is True, find_all() will perform a recursive search of this PageElement's children. Otherwise, only the direct children will be considered. :param limit: Stop looking after finding this many results. :kwargs: A dictionary of filters on attribute values. :return: A ResultSet of PageElements. :rtype: bs4.element.ResultSet rrrK)rchildrenrr) rr,rr=rurrrrs rrz Tag.find_alls`$$$  Ijj2 t~~dE65)C*5a-C;AC Crc,t|jS)zkIterate over all direct children of this PageElement. :yield: A sequence of PageElements. rrms rrz Tag.childrensDMM""rc#VK|js||jD]}|yw)zIterate over this PageElement and its children in a breadth-first sequence. :yield: A sequence of PageElements. N)rrr s rrzTag.self_and_descendantss){{J!!AG"s')c#Kt|jsy|jj}|jd}||ur||j}||uryyw)zIterate over all children of this PageElement in a breadth-first sequence. :yield: A sequence of PageElements. Nr)rr[rrX)rstopNodecurrents rrzTag.descendantss[4==! ((*77--"X%M**GX%s AAAc >|jj||fi|S)aPerform a CSS selection operation on the current element. :param selector: A CSS selector. :param namespaces: A dictionary mapping namespace prefixes used in the CSS selector to namespace URIs. By default, Beautiful Soup will use the prefixes it encountered while parsing the document. :param kwargs: Keyword arguments to be passed into Soup Sieve's soupsieve.select() method. :return: A Tag. :rtype: bs4.element.Tag )css select_one)rselectorrrs rr!zTag.select_ones" #txx""8ZB6BBrc @|jj|||fi|S)aPerform a CSS selection operation on the current element. This uses the SoupSieve library. :param selector: A string containing a CSS selector. :param namespaces: A dictionary mapping namespace prefixes used in the CSS selector to namespace URIs. By default, Beautiful Soup will use the prefixes it encountered while parsing the document. :param limit: After finding this number of results, stop looking. :param kwargs: Keyword arguments to be passed into SoupSieve's soupsieve.select() method. :return: A ResultSet of Tags. :rtype: bs4.element.ResultSet )r select)rr"rrrs rr$z Tag.select0s"(txxxUEfEErct|S)z,Return an interface to the CSS selector API.rrms rr zTag.cssFs4yrc|jSzDeprecated generator.)rrms rchildGeneratorzTag.childGeneratorLs }}rc|jSr')rrms rrecursiveChildGeneratorzTag.recursiveChildGeneratorPsrc\tjdtd|j|S)zDeprecated method. This was kind of misleading because has_key() (attributes) was different from __in__ (contents). has_key() is gone in Python 3, anyway. z1has_key is deprecated. Use has_attr(key) instead.rr)rrrrrs rhas_keyz Tag.has_keyTs)  ? 1 }}S!!r)NNNNNNNNNNNNNNNN)TrVr )r#)rK)NrWr0)Jr1r2r3r4rr parserClassr>rArrr isSelfClosingrurrr^rTrSr!rrrXrrrrrrrrrrrrrrrrrJrrrr__str__r7rBrr rrrrrrrrrrrrr findChildrfindAll findChildrenrrrr!r$r r(r*r,r5rrrrs^HL@D9=BF*.*. sVj(K8% &EE%M ( ]].. )8'?$!&k.A.A#H|$G(""$L :, !$ #"" ". I&"! %$Gh5 I)*4#'!8"Vr!( (!8(8T.,4nl   D,0)@!*64 *A),'>#(a9B$t0I d4C0GL##   + +C$F,   "rrcHeZdZdZdidfdZdZdZdifdZeZdZ d dZ y) ra&Encapsulates a number of ways of matching a markup element (tag or string). This is primarily used to underpin the find_* methods, but you can create one yourself and pass it in as `parse_only` to the `BeautifulSoup` constructor, to parse a subset of a large document. Nc |1d|vr-|jd}tjdtd|j ||_t |ts||d<d}d|vr |d|d<|d=|r&|r"|j}|j|n|}i}t|jD]\}}|j |||<||_ |j ||_ |j|_y)aConstructor. The SoupStrainer constructor takes the same arguments passed into the find_* methods. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: A dictionary of filters on attribute values. NrzXThe 'text' argument to the SoupStrainer constructor is deprecated. Use 'string' instead.rrclassclass_)rrrr_normalize_search_valuer,r^rcopyupdateritemsrrur)rr,rrurnormalized_attrsrr8s rrzSoupStrainer.__init__ks >f.ZZ'F MMj"q  006 %&$F7OE v %X.F7Ox   V$u{{}-JC$($@$@$G S !.& 226: KK rct|ts.t|tst|dst|ts||St|t r|j dSt|drig}|D]`}t|dr2t|t s"t|ts|j|A|j|j|b|Stt|S)NrHutf8r) r^r)rrboolbytesrrr7)rr8 new_valuevs rr7z$SoupStrainer._normalize_search_values uc "j&AWUT[E\%&%-L eU #<<' ' 5* %IAz*:a3G&q#.$$Q'$$T%A%A!%DE  3u:rch|jr |jS|jd|jS)z5A human-readable representation of this SoupStrainer.|)rur,rrms rr/zSoupStrainer.__str__s& ;;;; "ii4 4rc@d}d}t|tr|}|}t|jtr(|r&|js|j|jk7ryt|jt xrt|t }|jr>|s<|r|j ||js|s|j ||jr|r|j||}nxd}d}t|jjD]N\}} |s t|dr|}ni}|D] \} } | || < |j|} |j | | rLd}n|r|r|}n|}|r4|jr(|j |j|jsd}|S)aCheck whether a Tag with the given name and attributes would match this SoupStrainer. Used prospectively to decide whether to even bother creating a Tag object. :param markup_name: A tag name as found in some markup. :param markup_attrs: A dictionary of attributes as found in some markup. :return: True if the prospective tag would match this SoupStrainer; False otherwise. NFTr) r^rr,r)r+r_matchesrrr:rrru) r markup_name markup_attrsrmarkupcall_function_with_tag_datarHmarkup_attr_mapr match_againstkrA attr_values r search_tagzSoupStrainer.search_tagsv k3 ' F!L dii %fmm V[[0H tyy( + 1{C00 $*4==;t}}[$))D* +|<"&+/ 0@0@0B+C'D-*"<7.:O.0O(4156 2)5!0!4!4T!:J==]C %,D"E'E T[[u||T[[)QE rcd}t|drFt|ttfs0|D])}t|ts|j |s&|}|S|St|tr7|j r|js |jr|j|}|St|tst|tr8|js*|js|j||j r|}|Std|jz)zFind all items in `markup` that match this SoupStrainer. Used by the core _find_all() method, which is ultimately called by all find_* methods. :param markup: A PageElement or a list of them. Nrz&I don't know how to match against a %s) rr^rr)rrGrur,rrNrE ExceptionrI)rrHrrs rrGzSoupStrainer.searchs 6: &z&3*/M!g7;;w/#E %"$  $;;$))tzz/  0FC(99TZZDMM&$++4V 86;K;KKM Mrc\d}t|tst|tr>|D]}|j||sy|jdj ||ryy|dur|duSt|t r||S|}t|t r |j}|j|}|| St|drit|tsY|s t}|D]G}|jr|}n t|}||vr"|j||j|||sGyyd}|st|tr||k(}|st|dr|j|S|sHt|t r8|j r,|j|j dz|jz|S|S)NFTrrrGr()r^rrrEryrrr,r7rr)setridaddrGr+) rrHrK already_triedritemoriginal_markuprrHs rrEzSoupStrainer._matches s fd #z&%'@==}5 }}SXXf-}= D % % mX . ( (! fc "[[F--f5 >$$ $ M: .}c2! # %==CT(C-'!%%c*}}_dMJ#&M37m+E9 ''/ /?C0&&==&&,/C/CC]  rr ) r1r2r3r4rr7r/rN searchTagrGrEr5rrrras@!4. `<5&*:zIBPrrc*eZdZdZdfd ZdZxZS)rzTA ResultSet is just a list that keeps track of the SoupStrainer that created it.c:tt| |||_y)zlConstructor. :param source: A SoupStrainer. :param result: A list of PageElements. N)superrrsource)rr\rrIs rrzResultSet.__init__v s i'/ rctd|z)z7Raise a helpful exception to explain a common code fix.zResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?rRrs rrJzResultSet.__getattr__ s" psv v  r)r5)r1r2r3r4rrJ __classcell__)rIs@rrrs s rr). __license__collections.abcr ImportErrore collectionsrOsysrbs4.cssr bs4.formatterrrr r7rPnonwhitespace_re whitespace_rerrRr?r)r&r7r:rDr rSrrZr^rarerhrjrlrsrvrxrzr|rrrrr5rrris %(  "2::f% 6"  2 !  #.HCH E*A EA:R &R j|%c;|%|006  . 4   $  :   _  _   _   O w"+w"tO6Od  [K%$$%sEEEE