ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ ǁaWc@sdZddlZddlZddlZejddkrLeZeZn e Ze ZdZ de fdYZ de efd YZd efd YZd efd YZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZejdZejdZejd 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+d0Z-e+d1Z.e+d2Z/ie+d3d46e+d5d66Z0ejd7j1Z2eje*j3ej4j1Z5ejd8j1Z6e7ed9rej8d:d;Z9n d<Z9d=Z:d>Z;d?Z<d@efdAYZ=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. iNiicCs|jdjjdS(s(Lower-case, but only in the ASCII range.tutf8(tencodetlowertdecode(tstring((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt ascii_lowerst SelectorErrorcBseZdZRS(sCommon 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,eZdZddZdZdZRS(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(t parsed_treetNonet isinstancetFunctionalPseudoElementRtpseudo_element(tselfttreeR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt__init__:s   cCs]t|jtr$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(sReturn the specificity_ of this selector as a tuple of 3 integers. .. _specificity: http://www.w3.org/TR/selectors/#specificity i(R t specificityR(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.pyR 0s   tClasscBs)eZdZdZdZdZRS(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  RcBs2eZdZdZdZdZdZRS(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.pyRscCs3d|jj|jg|jD]}|j^qfS(Ns %s[::%s(%r)](RRRR tvalue(Rttoken((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRscCsg|jD]}|j^q S(N(R ttype(RR"((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytargument_typesscCs/|jj\}}}|d7}|||fS(Ni(RR(RRRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs (RRR RRR$R(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR}s    tFunctioncBs2eZdZdZdZdZdZRS(s( Represents selector:name(expr) cCs%||_t||_||_dS(N(RRRR (RRRR ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs 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.pyRscCsg|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.pyRs (RRR RRR$R(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR%s    tPseudocBs)eZdZdZdZdZRS(s# Represents selector:ident cCs||_t||_dS(N(RRtident(RRR'((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs cCsd|jj|j|jfS(Ns %s[%r:%s](RRRR'(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.pyR&s  tNegationcBs)eZdZdZdZdZRS(s. Represents selector:not(subselector) cCs||_||_dS(N(Rt subselector(RRR)((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs cCsd|jj|j|jfS(Ns%s[%r:not(%r)](RRRR)(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRscCsI|jj\}}}|jj\}}}||||||fS(N(RRR)(Rta1tb1tc1ta2tb2tc2((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs(RRR RRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR(s  tAttribcBs)eZdZdZdZdZRS(s> Represents selector[namespace|attrib operator value] cCs1||_||_||_||_||_dS(N(Rt namespacetattribtoperatorR!(RRR1R2R3R!((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs     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.pyRs  cCs/|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.pyR0s  tElementcBs/eZdZdddZdZdZRS(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.pyR5s tHashcBs)eZdZdZdZdZRS(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#eZdZdZdZRS(cCs1|dk st||_||_||_dS(N(R tAssertionErrorRt combinatorR)(RRR<R)((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyR$s  cCsA|jdkrd}n |j}d|jj|j||jfS(Nt s 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|jdgStj|}|dk rtttd|jdpmd|jdgStj|}|dk rtt td|jdpd|jdgSt t |}||_ t t|S(sParse 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_retmatchR R5tgroupt_id_reR R8t _class_reRt TokenStreamttokenizetsourcetlisttparse_selector_group(tcssR@tstream((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytparseEs ! ! ccsP|jx?tt|V|jdkrG|j|jq Pq WdS(NtDELIMt,(RLRM(tskip_whitespaceR tparse_selectortpeektnext(RJ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRHos   cCst|\}}x|j|j}|d d fkrAPn|rZtd|n|jdddr|jj}|jnd}t|\}}t|||}qW||fS( NtEOFRLRMs4Got pseudo-element ::%s not at the end of a selectort+t>t~R=(RRN(RLRM( tparse_simple_selectorRNRPR R tis_delimRQR!R:(RJtresultRRPR<t next_selector((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyROys"    c Cs|jt|j}|j}|jdks@|dkr|jdkra|jj}n|jd}|jdkr|j|j}q|}d}n d}}t ||}d}x|j}|jdks|j ddd d s|r|dkrPn|r/t d |n|jd krYt ||jj}q|d kr|jt ||j}q|d!kr|jt||}q|d"krN|j|jd#kr'|j|j}|jd$kr|jt|t|}qqn|j}|jd%krWt|}qn|jd&kr~t||}qn|j|j|jdkr3|rt dnt|dt\} } |j} | rt d| | jfn| d'kr!t d| fnt|| }qat||t|}qt d|fqWt|j|krt d|jfn||fS((NtIDENTRLR7t|tSRRRMRSRTRUt)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(RLR7(RLR[(R\RR(RLR](RLR_(RLR`(RLRa(RLRa(RLRb(s first-lines first-letterRcRd(RLRb(RLR](RNtlentusedRPR#RQR!R tnext_ident_or_starR5RWR R8Rt next_identt parse_attribRtparse_argumentsRt_unicodeR&RVtTruetposR(R%( RJRftselector_startRPR1R6RXRR'targumenttargument_pseudo_elementRQ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRVs       '                  cCs{g}xn|j|j}|jd ks@|d d gkrP|j|q |d kr`|Std|fq WdS( NRZtSTRINGtNUMBERRLRSt-R]sExpected an argument, got %s(RZRsRt(RLRS(RLRu(RLR](RNRQR#tappendR (RJR RQ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRls   cCs|j|j}|dkrP|jdkrPtd|jfn|jdkr|j|jdkrd}|jd}q|}|j}d}n d}}|dkru|j|j}|dkrt|||ddS|dkrd}qu|jdd d d dd r_|jdkr_|j d}|jqutd |fn|j|j}|j dkrtd|fn|j|j}|dkrtd|fnt|||||j S(NRLR[sExpected '|', got %st=s|=t]R4t^t$R7RUt!sOperator expected, got %sRZRss Expected string or ident, got %ssExpected ']', got %s(RLR[(RLR[(RLRw(RLRx(RLRw(RLRw(RZRs(RLRx( RNRiR RPR RQRjR0RWR!R#(RRJR2R1topRQR!((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRksN                     cCsx,|D]$}|jdkrtdqqWdjd|Dj}|dkr^dS|dkrndS|d kr~dSd |krd t|fS|jd d\}}|sd}n7|d ks|d krt|d }n t|}|sd }n t|}||fS(sv Parses the arguments for :nth-child() and friends. :raises: A list of tokens :returns: :``(a, b)`` Rss$String tokens not allowed in series.Rcss|]}|jVqdS(N(R!(t.0R"((s4/usr/lib/python2.7/site-packages/cssselect/parser.pys +stoddiitevenitnRuRSt1(ii(ii(ii(R#t ValueErrortjointstriptinttsplit(ttokensR"tsRR((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt parse_series s,         tTokencBsMeZdZdZdZeejdZeejdZ RS(cCs%tj|||f}||_|S(N(ttuplet__new__Ro(tclsttype_R!Rotobj((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRFs cCsd|j|j|jfS(Ns<%s '%s' at %i>(R#R!Ro(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRKscGs|jdko|j|kS(NRL(R#R!(Rtvalues((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRWNsii( RRRRRWtpropertyR3t itemgetterR#R!(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyREs    tEOFTokencBseZdZdZRS(cCstj|dd|S(NRR(RRR (RRo((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRVscCsd|j|jfS(Ns <%s at %i>(R#Ro(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRYs(RRRR(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRUs t TokenMacroscBsHeZdZedZdeZdZdeefZdeefZRS(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|tttjjS(N(tretcompiletvarsRt 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 methodcallerRAicCs |jdS(Ni(RA(R@((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt_replace_simple}scCs:t|jdd}|tjkr0d}nt|S(Niii(RRAtsyst maxunicodet_unichr(R@t codepoint((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt_replace_unicodes cCs"tt|}tt|}|S(N(t_sub_unicode_escapeRt_sub_simple_escapeR(R!((s4/usr/lib/python2.7/site-packages/cssselect/parser.pytunescape_identsccsd}t|}x||krt|d|}|r\tdd|V|j}qnt|d|}|rtttt|j }td||V|j}qnt |d|}|rtttt|j d}td||V|j}qn||}|t krt ||d|d}|sTt d|j}||krt d |n|||krt d |ntttttd |j }td ||V|d}qnt|d|}|r1|j }td ||V|j}qn|d}|||!dkr|jd|}|dkru|}q|d7}qntd|||V|d7}qW||kst t|VdS(NiRoR\R=RZiR^s)Should have found at least an empty matchsUnclosed string at %ssInvalid string at %sRRsRtis/*s*/iRL(Rgt_match_whitespaceRtendt _match_identRRRRRAt _match_hasht_match_string_by_quoteR;R t_sub_newline_escapet _match_numbertfindR(RRotlen_sR@R!tquotetend_postpos2((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyREsl               RDcBsAeZddZdZdZdZdZdZRS(cCsmg|_t||_||_d|_t|_y|jj|_ Wn t k rh|jj |_ nXdS(N( RhtiterRRFR tpeekedtFalset_peekingRQt next_tokentAttributeErrort__next__(RRRF((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRs     cCsP|jr,t|_|jj|j|jS|j}|jj||SdS(N(RRRhRvRR(RRQ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRQs   cCs+|js$|j|_t|_n|jS(N(RRRRn(R((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRPs  cCs8|j}|jdkr1td|fn|jS(NRZsExpected ident, got %s(RQR#R R!(RRQ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRjs cCsI|j}|jdkr"|jS|dkr2dStd|fdS(NRZRLR7sExpected ident or '*', got %s(RLR7(RQR#R!R R (RRQ((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRis  cCs,|j}|jdkr(|jndS(NR\(RPR#RQ(RRP((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRNs N( RRR RRQRPRjRiRN(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyRDs    ((>R RRR3t version_infotunicodeRmtunichrRtstrtchrRt ExceptionRt SyntaxErrorR tobjectR RRR%R&R(R0R5R8R:RR?RBRCRKRHRORRVRlRkRRRRRRRRRRRtsubRRtIRRthasattrRRRRRERD(((s4/usr/lib/python2.7/site-packages/cssselect/parser.pyt sj      ;#  *  S  - %           A