9,j1UdZddlmZddlmZddlmZmZmZm Z m Z m Z m Z ddl Z ddlmZe rddlmZddlmZdd lmZmZd ed < ddlZn#e$rdZe jd YnwxYwGd deZdS)a,Integration code for CSS selectors using `Soup Sieve `_ (pypi: ``soupsieve``). Acquire a `CSS` object through the `element.Tag.css` attribute of the starting point of your CSS selector, or (if you want to run a selector against the entire document) of the `BeautifulSoup` object itself. The main advantage of doing this instead of using ``soupsieve`` functions is that you don't need to keep passing the `element.Tag` to be selected against, since the `CSS` object is permanently scoped to that `element.Tag`. ) annotations) ModuleType)AnycastIterableIteratorMutableSequenceOptional TYPE_CHECKINGN)_NamespaceMapping) SoupSieve)element) ResultSetTagOptional[ModuleType] soupsievezEThe soupsieve package is not installed. CSS selectors cannot be used.ceZdZdZd(d)dZd*d Zd+dZd,dZ d-d.dZ d-d/dZ d0d1d Z d0d2d"Z d-d3d$Z d-d4d&Z d-d5d'ZdS)6CSSaA proxy object against the ``soupsieve`` library, to simplify its CSS selector API. You don't need to instantiate this class yourself; instead, use `element.Tag.css`. :param tag: All CSS selectors run by this object will use this as their starting point. :param api: An optional drop-in replacement for the ``soupsieve`` module, intended for use in unit tests. Ntag element.TagapircV|t}|td||_||_dS)NzLCannot execute CSS selectors because the soupsieve package is not installed.)rNotImplementedErrorrr)selfrrs 7C:\PYTHON\GemmaClient\venv\Lib\site-packages\bs4/css.py__init__z CSS.__init__;s: ;C ;%^ identstrreturncttdtt|j|S)zEscape a CSS identifier. This is a simple wrapper around `soupsieve.escape() `_. See the documentation for that function for more information. NzMCannot escape CSS identifiers because the soupsieve package is not installed.)rrrrrescape)rrs rr"z CSS.escapeEs?  %_ C//000rnsOptional[_NamespaceMapping]selectcVt||jjs| |jj}|S)z%Normalize a dictionary of namespaces.) isinstancerr r _namespaces)rr#r%s r_nszCSS._nsQs0&$("455 &"*%B rresultsMutableSequence[Tag]ResultSet[Tag]c&ddlm}|d|S)a?Normalize a list of results to a py:class:`ResultSet`. A py:class:`ResultSet` is more consistent with the rest of Beautiful Soup's API, and :py:meth:`ResultSet.__getattr__` has a helpful error message if you try to treat a list of results as a single result (a common mistake). r)rN)bs4r)rr*rs r_rszCSS._rs\s( "!!!!!yw'''rr namespacesflagsintkwargsrr c T|jj|||||fi|S)aPre-compile a selector and return the compiled object. :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 flags: Flags to be passed into Soup Sieve's `soupsieve.compile() `_ method. :param kwargs: Keyword arguments to be passed into Soup Sieve's `soupsieve.compile() `_ method. :return: A precompiled selector object. :rtype: soupsieve.SoupSieve )rcompiler)rr%r0r1r3s rr5z CSS.compileis32 txV(D(DeVVvVVVrelement.Tag | Nonec `|jj||j||||fi|S)aPerform a CSS selection operation on the current Tag and return the first result, if any. This uses the Soup Sieve library. For more information, see that library's documentation for the `soupsieve.select_one() `_ method. :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 flags: Flags to be passed into Soup Sieve's `soupsieve.select_one() `_ method. :param kwargs: Keyword arguments to be passed into Soup Sieve's `soupsieve.select_one() `_ method. )r select_onerr)r6s rr9zCSS.select_onesC4#tx" DHdhhz6::E  EK   rlimitResultSet[element.Tag]c |d}||jj||j|||||fi|S)aPerform a CSS selection operation on the current `element.Tag`. This uses the Soup Sieve library. For more information, see that library's documentation for the `soupsieve.select() `_ method. :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 pass in the prefixes it encountered while parsing the document. :param limit: After finding this number of results, stop looking. :param flags: Flags to be passed into Soup Sieve's `soupsieve.select() `_ method. :param kwargs: Keyword arguments to be passed into Soup Sieve's `soupsieve.select() `_ method. Nr)r/rr%rr)rr%r0r:r1r3s rr%z CSS.selects_8 =Exx DHO$((:v">">u  PV     rIterator[element.Tag]c b|jj||j|||||fi|S)aUPerform a CSS selection operation on the current `element.Tag`. This uses the Soup Sieve library. For more information, see that library's documentation for the `soupsieve.iselect() `_ method. It is the same as select(), but it returns a generator instead of a list. :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 pass in the prefixes it encountered while parsing the document. :param limit: After finding this number of results, stop looking. :param flags: Flags to be passed into Soup Sieve's `soupsieve.iselect() `_ method. :param kwargs: Keyword arguments to be passed into Soup Sieve's `soupsieve.iselect() `_ method. )riselectrr)r=s rr@z CSS.iselectsE> tx DHdhhz6::E5  LR   rOptional[element.Tag]c `|jj||j||||fi|S)aFind the `element.Tag` closest to this one that matches the given selector. This uses the Soup Sieve library. For more information, see that library's documentation for the `soupsieve.closest() `_ method. :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 pass in the prefixes it encountered while parsing the document. :param flags: Flags to be passed into Soup Sieve's `soupsieve.closest() `_ method. :param kwargs: Keyword arguments to be passed into Soup Sieve's `soupsieve.closest() `_ method. )rclosestrr)r6s rrCz CSS.closestsC8 tx DHdhhz6::E  EK   rboolc tt|jj||j||||fi|S)aCheck whether or not this `element.Tag` matches the given CSS selector. This uses the Soup Sieve library. For more information, see that library's documentation for the `soupsieve.match() `_ method. :param: a CSS selector. :param namespaces: A dictionary mapping namespace prefixes used in the CSS selector to namespace URIs. By default, Beautiful Soup will pass in the prefixes it encountered while parsing the document. :param flags: Flags to be passed into Soup Sieve's `soupsieve.match() `_ method. :param kwargs: Keyword arguments to be passed into SoupSieve's `soupsieve.match() `_ method. )rrDrmatchrr)r6s rrFz CSS.match sR>  DHN$((:v">">  IO     rc ||jj||j||||fi|S)aNFilter this `element.Tag`'s direct children based on the given CSS selector. This uses the Soup Sieve library. It works the same way as passing a `element.Tag` into that library's `soupsieve.filter() `_ method. For more information, see the documentation for `soupsieve.filter() `_. :param namespaces: A dictionary mapping namespace prefixes used in the CSS selector to namespace URIs. By default, Beautiful Soup will pass in the prefixes it encountered while parsing the document. :param flags: Flags to be passed into Soup Sieve's `soupsieve.filter() `_ method. :param kwargs: Keyword arguments to be passed into SoupSieve's `soupsieve.filter() `_ method. )r/rfilterrr)r6s rrHz CSS.filter0sS>xx DHO$((:v">">  IO     r)N)rrrr)rrr r)r#r$r%rr r$)r*r+r r,)Nr) r%rr0r$r1r2r3rr r ) r%rr0r$r1r2r3rr r7)Nrr) r%rr0r$r:r2r1r2r3rr r;) r%rr0r$r:r2r1r2r3rr r>) r%rr0r$r1r2r3rr rA) r%rr0r$r1r2r3rr rD) r%rr0r$r1r2r3rr r;)__name__ __module__ __qualname____doc__rr"r)r/r5r9r%r@rCrFrHrrrr-sj   1 1 1 1     ( ( ( ( 37 WWWWW<37      B37 # # # # # P37 ! ! ! ! ! L37      F37 $ $ $ $ $ R37 # # # # # # # rr)rL __future__rtypesrtypingrrrrr r r warnings bs4._typingr rr r.r bs4.elementrr__annotations__ ImportErrorwarnobjectrrMrrrXs   #"""""))))))+######********IHMOf f f f f &f f f f f sA A'&A'