f]'|dZddlZ ddlZGddeZy#e$rZdZej dYdZ[*dZ[wwxYw)zFIntegration code for CSS selectors using Soup Sieve (pypi: soupsieve).NzEThe soupsieve package is not installed. CSS selectors cannot be used.cdeZdZdZefdZdZdZdZddZ ddZ dd Z dd Z dd Z dd Zdd Zy)CSSaA proxy object against the soupsieve library, to simplify its CSS selector API. Acquire this object through the .css attribute on the BeautifulSoup object, or on the Tag you want to use as the starting point for a CSS selector. The main advantage of doing this is that the tag to be selected against doesn't need to be explicitly specified in the function calls, since it's already scoped to a tag. c:| td||_||_y)aConstructor. You don't need to instantiate this class yourself; instead, access the .css attribute on the BeautifulSoup object, or on the Tag you want to use as the starting point for your CSS selector. :param tag: All CSS selectors will use this as their starting point. :param api: A plug-in replacement for the soupsieve module, designed mainly for use in tests. NzLCannot execute CSS selectors because the soupsieve package is not installed.)NotImplementedErrorapitag)selfrrs P/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/bs4/css.py__init__z CSS.__init__s) ;%^ cZt td|jj|S)zEscape a CSS identifier. This is a simple wrapper around soupselect.escape(). See the documentation for that function for more information. zMCannot escape CSS identifiers because the soupsieve package is not installed.) soupsieverrescape)r idents r rz CSS.escape/s/  %_ xxu%%r cvt||jjs||jj}|S)z%Normalize a dictionary of namespaces.) isinstancer SoupSiever _namespaces)r nsselects r _nszCSS._ns;s0&$(("4"45"*%%B r c ddlm}|d|S)aNormalize a list of results to a Resultset. A ResultSet is more consistent with the rest of Beautiful Soup's API, and ResultSet.__getattr__ has a helpful error message if you try to treat a list of results as a single result (a common mistake). r) ResultSetN) bs4.elementr)r resultsrs r _rszCSS._rsDs *w''r Nc `|jj||j|||fi|S)a~Pre-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 SoupSieve's soupsieve.compile() method. :return: A precompiled selector object. :rtype: soupsieve.SoupSieve )rcompilerr r namespacesflagskwargss r rz CSS.compilePs7& txx DHHZ0% ;A  r c v|jj||j|j|||fi|S)aKPerform a CSS selection operation on the current Tag and return the first result. 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 SoupSieve's soupsieve.select_one() method. :return: A Tag, or None if the selector has no match. :rtype: bs4.element.Tag )r select_onerrrs r r$zCSS.select_onegs=2#txx"" DHHdhhz6:E EK  r c |d}|j|jj||j|j ||||fi|S)awPerform a CSS selection operation on the current Tag. This uses the Soup Sieve library. For more information, see that library's documentation for the soupsieve.select() 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 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 SoupSieve's soupsieve.select() method. :return: A ResultSet of Tag objects. :rtype: bs4.element.ResultSet r)rrrrrr rr limitr!r"s r rz CSS.selectsS4 =Exx DHHOO$((:v">u    r c x|jj||j|j||||fi|S)aPerform a CSS selection operation on the current 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 SoupSieve's soupsieve.iselect() method. :return: A generator :rtype: types.GeneratorType )riselectrrr&s r r)z CSS.iselects?4 txx DHHdhhz6:E5 LR  r c v|jj||j|j|||fi|S)a6Find the 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 SoupSieve's soupsieve.closest() method. :return: A Tag, or None if there is no match. :rtype: bs4.Tag )rclosestrrrs r r+z CSS.closests=0 txx DHHdhhz6:E EK  r c v|jj||j|j|||fi|S)aCheck whether this 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. :return: True if this Tag matches the selector; False otherwise. :rtype: bool )rmatchrrrs r r-z CSS.matchs;.txx~~ DHHdhhz6:E EK  r c |j|jj||j|j |||fi|S)aWFilter this Tag's direct children based on the given CSS selector. This uses the Soup Sieve library. It works the same way as passing this Tag into that library's soupsieve.filter() method. More information, 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. :return: A ResultSet of Tag objects. :rtype: bs4.element.ResultSet )rrfilterrrrs r r/z CSS.filtersG.xx DHHOO$((:v"> IO   r )Nr)Nrr)__name__ __module__ __qualname____doc__rr rrrrr$rr)r+r-r/r r rr sD !** & ( . :" H < 8 6 r r)r3warningsr ImportErrorewarnobjectrr4r r r:sNLK &K IHMMOs;6;