HEX
Server: Apache
System: Linux vps.rockyroadprinting.net 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: rockyroadprintin (1011)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/cssselect/parser.pyo
�
ǁaWc@sdZddlZddlZddlZejddkrLeZeZne	Ze
Zd�Zdefd��YZ
de
efd	��YZd
efd��YZdefd
��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZejd�Zejd�Zejd �Zd!�Zd"�Z d#�Z!e"d$�Z#d%�Z$d&�Z%d'�Z&d(e'fd)��YZ(d*e(fd+��YZ)d,dBd-��YZ*d.�Z+e+d/�Z,e+d0�Z-e+d1�Z.e+d2�Z/ie+d3�d46e+d5�d66Z0ejd7�j1Z2eje*j3ej4�j1Z5ejd8�j1Z6e7ed9�r�ej8d:d;�Z9n	d<�Z9d=�Z:d>�Z;d?�Z<d@efdA��YZ=dS(Cs
    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.

i����NiicCs|jd�j�jd�S(s(Lower-case, but only in the ASCII range.tutf8(tencodetlowertdecode(tstring((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytascii_lowerst
SelectorErrorcBseZdZRS(s�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.

    (t__name__t
__module__t__doc__(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR!stSelectorSyntaxErrorcBseZdZRS(s3Parsing a selector that does not match the grammar.(RRR	(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR
*stSelectorcBs,eZdZdd�Zd�Zd�ZRS(s"
    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.

    cCsA||_|dk	r4t|t�r4t|�}n||_dS(N(tparsed_treetNonet
isinstancetFunctionalPseudoElementRtpseudo_element(tselfttreeR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt__init__:s
	
cCs]t|jt�r$t|j�}n|jr=d|j}nd}d|jj|j|fS(Ns::%sts%s[%r%s](RRRtreprt	__class__RR(RR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt__repr__Us	cCs;|jj�\}}}|jr.|d7}n|||fS(s�Return the specificity_ of this selector as a tuple of 3 integers.

        .. _specificity: http://www.w3.org/TR/selectors/#specificity

        i(RtspecificityR(Rtatbtc((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR_s	
N(RRR	R
RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR0s		
tClasscBs)eZdZd�Zd�Zd�ZRS(s(
    Represents selector.class_name
    cCs||_||_dS(N(tselectort
class_name(RRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRos	cCsd|jj|j|jfS(Ns	%s[%r.%s](RRRR(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRsscCs/|jj�\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRws
(RRR	RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRks		RcBs2eZdZd�Zd�Zd�Zd�ZRS(sx
    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.

    cCst|�|_||_dS(N(Rtnamet	arguments(RRR ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�scCs3d|jj|jg|jD]}|j^qfS(Ns%s[::%s(%r)](RRRR tvalue(Rttoken((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�scCsg|jD]}|j^q
S(N(R ttype(RR"((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytargument_types�scCs/|jj�\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s
(RRR	RRR$R(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR}s
			tFunctioncBs2eZdZd�Zd�Zd�Zd�ZRS(s(
    Represents selector:name(expr)
    cCs%||_t|�|_||_dS(N(RRRR (RRRR ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s	cCs9d|jj|j|jg|jD]}|j^q"fS(Ns
%s[%r:%s(%r)](RRRRR R!(RR"((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�scCsg|jD]}|j^q
S(N(R R#(RR"((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR$�scCs/|jj�\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s
(RRR	RRR$R(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR%�s
			tPseudocBs)eZdZd�Zd�Zd�ZRS(s#
    Represents selector:ident
    cCs||_t|�|_dS(N(RRtident(RRR'((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s	cCsd|jj|j|jfS(Ns	%s[%r:%s](RRRR'(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�scCs/|jj�\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s
(RRR	RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR&�s		tNegationcBs)eZdZd�Zd�Zd�ZRS(s.
    Represents selector:not(subselector)
    cCs||_||_dS(N(Rtsubselector(RRR)((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s	cCsd|jj|j|jfS(Ns%s[%r:not(%r)](RRRR)(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�scCsI|jj�\}}}|jj�\}}}||||||fS(N(RRR)(Rta1tb1tc1ta2tb2tc2((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s(RRR	RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR(�s		tAttribcBs)eZdZd�Zd�Zd�ZRS(s>
    Represents selector[namespace|attrib operator value]
    cCs1||_||_||_||_||_dS(N(Rt	namespacetattribtoperatorR!(RRR1R2R3R!((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s
				cCs~|jr"d|j|jf}n	|j}|jdkrTd|jj|j|fSd|jj|j||j|jfSdS(Ns%s|%stexistss
%s[%r[%s]]s%s[%r[%s %s %r]](R1R2R3RRRR!(RR2((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s		cCs/|jj�\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s
(RRR	RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR0�s		
tElementcBs/eZdZddd�Zd�Zd�ZRS(sU
    Represents namespace|element

    `None` is for the universal selector '*'

    cCs||_||_dS(N(R1telement(RR1R6((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs	cCsB|jpd}|jr.d|j|f}nd|jj|fS(Nt*s%s|%ss%s[%s](R6R1RR(RR6((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs	cCs|jr
dSdSdS(Nii(iii(iii(R6(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR
s	N(RRR	R
RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR5�s	tHashcBs)eZdZd�Zd�Zd�ZRS(s 
    Represents selector#id
    cCs||_||_dS(N(Rtid(RRR9((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs	cCsd|jj|j|jfS(Ns	%s[%r#%s](RRRR9(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRscCs/|jj�\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs
(RRR	RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR8s		tCombinedSelectorcBs#eZd�Zd�Zd�ZRS(cCs||_||_||_dS(N(Rt
combinatorR)(RRR;R)((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR$s		cCsA|jdkrd}n	|j}d|jj|j||jfS(Nt s
<followed>s%s[%r %s %r](R;RRRR)(Rtcomb((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR*s
		cCsI|jj�\}}}|jj�\}}}||||||fS(N(RRR)(RR*R+R,R-R.R/((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR2s(RRRRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR:#s		s%^[ \t\r\n\f]*([a-zA-Z]+)[ \t\r\n\f]*$s6^[ \t\r\n\f]*([a-zA-Z]*)#([a-zA-Z0-9_-]+)[ \t\r\n\f]*$s?^[ \t\r\n\f]*([a-zA-Z]*)\.([a-zA-Z][a-zA-Z0-9_-]*)[ \t\r\n\f]*$cCstj|�}|r4ttd|jd���gStj|�}|dk	r�tttd|jd�pmd�|jd���gStj|�}|dk	r�tt	td|jd�p�d�|jd���gSt
t|��}||_t
t|��S(s�Parse a CSS *group of selectors*.

    If you don't care about pseudo-elements or selector specificity,
    you can skip this and use :meth:`~GenericTranslator.css_to_xpath`.

    :param css:
        A *group of selectors* as an Unicode string.
    :raises:
        :class:`SelectorSyntaxError` on invalid selectors.
    :returns:
        A list of parsed :class:`Selector` objects, one for each
        selector in the comma-separated group.

    R6iiN(t_el_retmatchRR5tgroupt_id_reR
R8t	_class_reRtTokenStreamttokenizetsourcetlisttparse_selector_group(tcssR?tstream((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytparseEs!!	ccsP|j�x?tt|��V|j�dkrG|j�|j�q
Pq
WdS(NtDELIMt,(RKRL(tskip_whitespaceRtparse_selectortpeektnext(RI((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRGos


cCs�t|�\}}x�|j�|j�}|d	d
fkrAPn|rZtd|��n|jddd�r�|j�j}|j�nd}t|�\}}t|||�}qW||fS(NtEOFRKRLs4Got pseudo-element ::%s not at the end of a selectort+t>t~R<(RQN(RKRL(	tparse_simple_selectorRMROR
R
tis_delimRPR!R:(RItresultRROR;t
next_selector((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRNys"


cCs�|j�t|j�}|j�}|jdks@|dkr�|jdkra|j�j}n|j�d}|j�dkr�|j�|j�}q�|}d}n
d}}t	||�}d}x�|j�}|jdks|j
ddd	d
�s|r|dkrPn|r/td|��n|jd
krYt||j�j�}q�|d kr�|j�t
||j��}q�|d!kr�|j�t||�}q�|d"krN|j�|j�d#kr'|j�|j�}|j�d$kr�|j�t|t|��}q�q�n|j�}|j�d%krWt|�}q�n|j�d&kr~t||�}q�n|j�|j�|j�dkr3|r�td��nt|dt�\}	}
|j�}|
r�td|
|jf��n|d'kr!td|f��nt||	�}qat||t|��}q�td|f��q�Wt|j�|kr�td|j�f��n||fS((NtIDENTRKR7t|tSRQRLRRRSRTt)s4Got pseudo-element ::%s not at the end of a selectortHASHt.t[t:t(s
first-linesfirst-lettertbeforetaftertnotsGot nested :not()tinside_negations+Got pseudo-element ::%s inside :not() at %ssExpected ')', got %ssExpected selector, got %s(RKR7(RKRZ(R[RQ(RKR\(RKR^(RKR_(RKR`(RKR`(RKRa(s
first-linesfirst-letterRbRc(RKRa(RKR\(RMtlentusedROR#RPR!R
tnext_ident_or_starR5RVR
R8Rt
next_identtparse_attribRtparse_argumentsRt_unicodeR&RUtTruetposR(R%(RIRetselector_startROR1R6RWRR'targumenttargument_pseudo_elementRP((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRU�s�


	
'





		

cCs{g}xn|j�|j�}|jd	ks@|d
dgkrP|j|�q	|dkr`|Std|f��q	WdS(
NRYtSTRINGtNUMBERRKRRt-R\sExpected an argument, got %s(RYRrRs(RKRR(RKRt(RKR\(RMRPR#tappendR
(RIR RP((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRk�s
cCs|j�|j�}|dkrP|j�dkrPtd|j�f��n|j�dkr�|j�|j�dkr�d}|j�d}q�|}|j�}d}n
d}}|dkru|j�|j�}|dkrt|||dd�S|dkrd}qu|jdd	d
ddd�r_|j�dkr_|j	d}|j�qutd
|f��n|j�|j�}|j
dkr�td|f��n|j�|j�}|dkr�td|f��nt|||||j	�S(NRKRZsExpected '|', got %st=s|=t]R4t^t$R7RTt!sOperator expected, got %sRYRrs Expected string or ident, got %ssExpected ']', got %s(RKRZ(RKRZ(RKRv(RKRw(RKRv(RKRv(RYRr(RKRw(RMRhR
ROR
RPRiR0RVR!R#(RRIR2R1topRPR!((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRj�sN


		

	



cCsx,|D]$}|jdkrtd��qqWdjd�|D��j�}|dkr^dS|dkrndS|d
kr~dSd
|kr�d	t|�fS|jd
d�\}}|s�d}n7|dks�|dkr�t|d
�}nt|�}|sd	}nt|�}||fS(sv
    Parses the arguments for :nth-child() and friends.

    :raises: A list of tokens
    :returns: :``(a, b)``

    Rrs$String tokens not allowed in series.Rcss|]}|jVqdS(N(R!(t.0R"((s4/usr/lib/python2.7/site-packages/cssselect/parser.pys	<genexpr>+stoddiitevenitnRtRRt1(ii(ii(ii(R#t
ValueErrortjointstriptinttsplit(ttokensR"tsRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytparse_series s,
		tTokencBsMeZd�Zd�Zd�Zeejd��Zeejd��Z	RS(cCs%tj|||f�}||_|S(N(ttuplet__new__Rn(tclsttype_R!Rntobj((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�Fs	cCsd|j|j|jfS(Ns<%s '%s' at %i>(R#R!Rn(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRKscGs|jdko|j|kS(NRK(R#R!(Rtvalues((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRVNsii(
RRR�RRVtpropertyR3t
itemgetterR#R!(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�Es
			tEOFTokencBseZd�Zd�ZRS(cCstj|dd|�S(NRQ(R�R�R
(R�Rn((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�VscCsd|j|jfS(Ns
<%s at %i>(R#Rn(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRYs(RRR�R(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�Us	tTokenMacroscBsHeZdZedZdeZdZdeefZdeefZRS(s&\\([0-9a-f]{1,6})(?:\r\n|[ \n\r\t\f])?s|\\[^\n\r\f0-9a-f]s\\(?:\n|\r\n|\r|\f)|s
[^\0-\177]s[_a-z0-9-]|%s|%ss[_a-z]|%s|%s(RRtunicode_escapetescapet
string_escapetnonasciitnmchartnmstart(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�`s

cCs tj|tt�tj�jS(N(tretcompiletvarsR�t
IGNORECASER?(tpattern((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt_compilehss[ \t\r\n\f]+s[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)s#(?:%(nmchar)s)+s -?(?:%(nmstart)s)(?:%(nmchar)s)*s!([^\n\r\f\\']|%(string_escape)s)*t's!([^\n\r\f\\"]|%(string_escape)s)*t"s\\(.)s\\(?:\n|\r\n|\r|\f)tmethodcallerR@icCs
|jd�S(Ni(R@(R?((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt_replace_simple}scCs:t|jd�d�}|tjkr0d}nt|�S(Niii��(R�R@tsyst
maxunicodet_unichr(R?t	codepoint((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt_replace_unicode�s	cCs"tt|�}tt|�}|S(N(t_sub_unicode_escapeR�t_sub_simple_escapeR�(R!((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytunescape_ident�sccs�d}t|�}x�||kr�t|d|�}|r\tdd|�V|j�}qnt|d|�}|r�tttt|j	���}td||�V|j�}qnt
|d|�}|rtttt|j	�d��}td||�V|j�}qn||}|tkr�t||d|d�}|j�}||krmtd|��n|||kr�td	|��nttttt
d
|j	����}td||�V|d}qnt|d|�}|r|j	�}td||�V|j�}qn|d
}|||!dkrs|jd|�}|dkrc|}q|d
7}qntd|||�V|d7}qWt|�VdS(NiRnR[R<RYiR]sUnclosed string at %ssInvalid string at %sRRrRsis/*s*/i����RK(Rft_match_whitespaceR�tendt_match_identR�R�R�R�R@t_match_hasht_match_string_by_quoteR
t_sub_newline_escapet
_match_numbertfindR�(R�Rntlen_sR?R!tquotetend_postpos2((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRD�sh


	
RCcBsAeZdd�Zd�Zd�Zd�Zd�Zd�ZRS(cCsmg|_t|�|_||_d|_t|_y|jj|_	Wn t
k
rh|jj|_	nXdS(N(RgtiterR�RER
tpeekedtFalset_peekingRPt
next_tokentAttributeErrort__next__(RR�RE((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR�s				
cCsP|jr,t|_|jj|j�|jS|j�}|jj|�|SdS(N(R�R�RgRuR�R�(RRP((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRP�s		cCs+|js$|j�|_t|_n|jS(N(R�R�R�Rm(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRO�s	cCs8|j�}|jdkr1td|f��n|jS(NRYsExpected ident, got %s(RPR#R
R!(RRP((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRi�scCsI|j�}|jdkr"|jS|dkr2dStd|f��dS(NRYRKR7sExpected ident or '*', got %s(RKR7(RPR#R!R
R
(RRP((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRh�scCs,|j�}|jdkr(|j�ndS(NR[(ROR#RP(RRO((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRM�sN(	RRR
RRPRORiRhRM(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRC�s	
			
((>R	R�R�R3tversion_infotunicodeRltunichrR�tstrtchrRt	ExceptionRtSyntaxErrorR
tobjectRRRR%R&R(R0R5R8R:R�R>RARBRJRGRNR�RURkRjR�R�R�R�R�R�R�R�R�R�R�tsubR�R�tIR�R�thasattrR�R�R�R�RDRC(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt<module>
sj			;#		*	
	S		-	%	
				A