[L i1UdZddlmZddlmZddlmZmZmZm Z m Z m Z m Z ddl Z ddlmZe rddlmZddlmZdd lmZmZd ed < ddlZGd deZy#e$rdZe j2d Y'wxYw)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.c*eZdZdZdddZddZ ddZddZ d ddZ d ddZ d dd Z d dd Z d dd Z d dd Z d dd Zy)CSSaA 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. NcJ|t}| td||_||_y)NzLCannot execute CSS selectors because the soupsieve package is not installed.)rNotImplementedErrorapitag)selfrrs M/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/bs4/css.py__init__z CSS.__init__;s1 ;C ;%^ cvt tdtt|jj |S)zEscape a CSS identifier. This is a simple wrapper around `soupsieve.escape() `_. See the documentation for that function for more information. zMCannot escape CSS identifiers because the soupsieve package is not installed.)rrrstrrescape)ridents rrz CSS.escapeEs6  %_ C/00rcvt||jjs||jj}|S)z%Normalize a dictionary of namespaces.) isinstancerr r _namespaces)rnsselects r_nszCSS._nsQs2&$(("4"45"*%%B rc 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)rresultsrs r_rszCSS._rs\s "w''rc `|jj||j|||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% namespacesflagskwargss rr,z CSS.compileis/2 txxV(DeVvVVrc v|jj||j|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&r-s rr2zCSS.select_ones=4#txx"" DHHdhhz6:E EK  rc |d}|j|jj||j|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. r)r*rr%rr&rr%r.limitr/r0s rr%z CSS.selectsS8 =Exx DHHOO$((:v">u PV   rc x|jj||j|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&r4s rr7z CSS.iselects?> txx DHHdhhz6:E5 LR  rc v|jj||j|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&r-s rr9z CSS.closests=8 txx DHHdhhz6:E EK  rc tt|jj||j|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. )rboolrmatchrr&r-s rr<z CSS.match sF>  DHHNN$((:v"> IO   rc |j|jj||j|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&r-s rr>z CSS.filter0sG>xx DHHOO$((:v"> IO   r)N)rz element.Tagrr)r rreturnr)r$Optional[_NamespaceMapping]r%rr?r@)r)zMutableSequence[Tag]r?zResultSet[Tag])Nr) r%rr.r@r/intr0rr?r ) r%rr.r@r/rAr0rr?zelement.Tag | None)Nrr) r%rr.r@r5rAr/rAr0rr?ResultSet[element.Tag]) r%rr.r@r5rAr/rAr0rr?zIterator[element.Tag]) r%rr.r@r/rAr0rr?zOptional[element.Tag]) r%rr.r@r/rAr0rr?r;) r%rr.r@r/rAr0rr?rB)__name__ __module__ __qualname____doc__rrr&r*r,r2r%r7r9r<r>rrrr-s  1 - 7:  $  ( 37 WW0W W  W  W<37   0       B37 # # 0#  #  #  #  # P37 ! ! 0!  !  !  !  ! L37   0       F37 $ $ 0$  $  $  $ R37 # # 0#  #  # # rr)rF __future__rtypesrtypingrrrrr r r warnings bs4._typingr rr r(r bs4.elementrr__annotations__ ImportErrorwarnobjectrrGrrrRsx #)#* f &f IHMMOsAA43A4