| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/cssselect/__pycache__/ |
Upload File : |
�
E�Zc�� �
�F � d Z ddlZddlZddlZddlZddlmZmZmZmZm Z m
Z
mZ dedefd�Z
G d� de� Z G d � d
ee� Zed Zedef Z G d
� d� Z G d� d� Z G d� d� Z G d� d� Z G d� d� Z G d� d� Z G d� d� Z G d� d� Z G d� d� Z G d� d� Z G d � d!� Z G d"� d#� Z G d$� d%� Z ejB d&� Z" ejB d'� Z# ejB d(� Z$d)edee fd*�Z%d+d,dee fd-�Z&d+d,de
eee f fd.�Z' dUd+d,d/e(de
eee f fd0�Z)d+d,ded1 fd2�Z*d+d,de
d1ef fd3�Z+d+d,dee fd4�Z,d5ed+d,defd6�Z-d7ed1 de
e.e.f fd8�Z/ G d9� d1e
eee f � Z0 G d:� d;e0� Z1 G d<� d=� Z2ejf r G d>� d?ejh � Z5d@edd?fdA�Z6 e6dB� Z7 e6dC� Z8 e6dD� Z9 e6dE� Z: e6dF� e6dG� dH�Z; ejB dI� jx Z= ejB e2j| ej~ � jx Z@ ejB dJ� jx ZA ej� dKdL� ZCdMdNdefdO�ZDdPedefdQ�ZEdRedee0 fdS�ZF G dT� d,� ZGy)Va
cssselect.parser
================
Tokenizer, parser and parsed objects for CSS selectors.
:copyright: (c) 2007-2012 Ian Bicking and contributors.
See AUTHORS for more details.
:license: BSD, see LICENSE for more details.
� N)�Iterable�Iterator�List�Optional�Sequence�Tuple�Union�string�returnc �^ � | j d� j � j d� S )z(Lower-case, but only in the ASCII range.�utf8)�encode�lower�decode)r
s �2/usr/lib/python3/dist-packages/cssselect/parser.py�ascii_lowerr s% � ��=�=�� �&�&�(�/�/��7�7� c � � e Zd ZdZy)�
SelectorErrorz�Common parent for :class:`SelectorSyntaxError` and
:class:`ExpressionError`.
You can just use ``except SelectorError:`` when calling
:meth:`~GenericTranslator.css_to_xpath` and handle both exceptions types.
N��__name__�
__module__�__qualname__�__doc__� r r r r s � �r r c � � e Zd ZdZy)�SelectorSyntaxErrorz3Parsing a selector that does not match the grammar.Nr r r r r r % s � �=r r )�Element�Hash�Class�Function�Pseudo�Attrib�Negation�Relation�Matching�SpecificityAdjustment�CombinedSelector�FunctionalPseudoElementc �\ � e Zd ZdZd
dedee ddfd�Zdefd�Z defd�Z
deeeef fd �Z
y)�Selectoru"
Represents a parsed selector.
:meth:`~GenericTranslator.selector_to_xpath` accepts this object,
but ignores :attr:`pseudo_element`. It is the user’s responsibility
to account for pseudo-elements and reject selectors with unknown
or unsupported pseudo-elements.
N�tree�pseudo_elementr c �Z � || _ |�t |t � st |� }|| _ y �N)�parsed_tree�
isinstancer) r r- )�selfr, r- s r �__init__zSelector.__init__F s. � �����%�j��I`�.a�(��8�N�* -��r c �� � t | j t � rt | j � }n| j rd| j z }nd}| j j
�d| j �|�d�S )N�::%s� �[�])r1 r- r) �repr� __class__r r0 )r2 r- s r �__repr__zSelector.__repr__` s^ � ��d�)�)�+B�C�!�$�"5�"5�6�N�
�
�
�#�d�&9�&9�9�N��N�!�^�^�4�4�d�6F�6F��W�Wr c �, � t | j t � rd| j j � z }n| j rd| j z }nd}| j j � �|��}t |� dkD r|j
d� }|S )z8Return a CSS representation for this selector (a string)r5 r6 � �*)r1 r- r) � canonicalr0 �len�lstrip)r2 r- �ress r r? zSelector.canonicali s� � ��d�)�)�+B�C�#�d�&9�&9�&C�&C�&E�E�N�
�
�
�#�d�&9�&9�9�N��N��(�(�2�2�4�n�E���s�8�a�<��*�*�S�/�C��
r c �j � | j j � \ }}}| j r|dz
}|||fS )z�Return the specificity_ of this selector as a tuple of 3 integers.
.. _specificity: http://www.w3.org/TR/selectors/#specificity
r= )r0 �specificityr- �r2 �a�b�cs r rD zSelector.specificityv s; � � �"�"�.�.�0���1�a����
��F�A��!�Q�w�r r/ )r r r r �Treer �
PseudoElementr3 �strr; r? r �intrD r r r r+ r+ ; sX � ��-�T� -�8�M�3J� -�VZ� -�4X�#� X��3� � �U�3��S�=�1� r r+ c �T � e Zd ZdZdededdfd�Zdefd�Zdefd�Zde e
e
e
f fd �Zy)
r z(
Represents selector.class_name
�selector�
class_namer Nc � � || _ || _ y r/ )rN rO )r2 rN rO s r r3 zClass.__init__� s � � ��
�$��r c �h � | j j �d| j �d| j �d�S )Nr7 �.r8 )r: r rN rO �r2 s r r; zClass.__repr__� s! � �"�n�n�5�5�t�}�}�d�o�o�V�Vr c �T � | j j � �d| j ��S )NrR )rN r? rO rS s r r? zClass.canonical� s � ��-�-�1�1�3�T�_�_�E�Er c �R � | j j � \ }}}|dz
}|||fS �Nr= �rN rD rE s r rD zClass.specificity� �. � ��-�-�+�+�-���1�a� �Q����!�Q�w�r �r r r r rI rK r3 r; r? r rL rD r r r r r � sT � ��%�� %�3� %�4� %�W�#� W�F�3� F��U�3��S�=�1� r r c �P � e Zd ZdZdeded fd�Zdefd�Zdee fd�Z defd �Z
y
)r) ax
Represents selector::name(arguments)
.. attribute:: name
The name (identifier) of the pseudo-element, as a string.
.. attribute:: arguments
The arguments of the pseudo-element, as a list of tokens.
**Note:** tokens are not part of the public API,
and may change between cssselect versions.
Use at your own risks.
�name� arguments�Tokenc �2 � t |� | _ || _ y r/ )r r[ r\ )r2 r[ r\ s r r3 z FunctionalPseudoElement.__init__� s � ���%�� �"��r r c � � | j j �d| j �d| j D �cg c] }|j �� c}�d�S c c}w )Nz[::�(�)])r: r r[ r\ �value�r2 �tokens r r; z FunctionalPseudoElement.__repr__� s; � ��N�N�#�#��I�I�&*�n�n�5�U�U�[�[�5�
�
��
6s �Ac �T � | j D �cg c] }|j �� c}S c c}w r/ �r\ �typerc s r �argument_typesz&FunctionalPseudoElement.argument_types� � � �(,���7�u��
�
�7�7��7� �%c �j � dj d� | j D � � }| j �d|�d�S )Nr6 c 3 �<