Viewing File: /usr/lib64/python2.7/site-packages/lxml/html/formfill.pyc

ó
ÄqPc	@sÿddlmZmZddlmZmZmZddlmZmZm	Z	m
Z
ddlmZddlZye
Wnek
r‘eZ
nXdddd	d
dgZdefd„ƒYZed
died6ƒZedjgd+D]Zde^qéƒdied6ƒZeddied6ƒZedƒZddd„Zddd„Zd„Zd„Zd„Zd„Zd „Z d!„Z!ddd"„Z"d#„Z#de$fd$„ƒYZ%e%ƒZ&ddd%e&d&„Z'd'„Z(d(„Z)d)„Z*d*„Z+dS(,iÿÿÿÿ(tXPathtElementBase(t
fromstringttostringtXHTML_NAMESPACE(t_forms_xpatht_options_xpatht_nonst_transform_result(tdefsNtFormNotFoundt	fill_formtfill_form_htmlt
insert_errorstinsert_errors_htmltDefaultErrorCreatorcBseZdZRS(s*
    Raised when no form can be found
    (t__name__t
__module__t__doc__(((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR
ssKdescendant-or-self::form[name=$name]|descendant-or-self::x:form[name=$name]t
namespacestxt|tinputtselectttextareasx:inputsx:selects
x:textareasdescendant-or-self::s-//label[@for=$for_id]|//x:label[@for=$for_id]s"descendant-or-self::*[@name=$name]cCs)t|d|d|ƒ}t||ƒdS(Ntform_idt
form_index(t
_find_formt
_fill_form(teltvaluesRR((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRscCs_t|ƒ}t|tƒr*t|ƒ}ntj|ƒ}t||d|d|ƒt||ƒS(NRR(ttypet
isinstancet
basestringRtcopytdeepcopyRR(thtmlRRRtresult_typetdoc((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR&scCsGi}t|dƒr$|jƒ}nt|ƒ}x|D]}|jdƒ}|sXq7nt|ƒr§|j|gƒ}t|ttfƒs—|g}nt||ƒq7||kr¹q7q7|j|dƒ}|d||<||}t|ttfƒr y||}Wq2t	k
rq7q2Xn|dkr2q7nt
||ƒq7WdS(Ntmixedtnameii(thasattrR't_input_xpathtgett_takes_multipleR tlistttuplet_fill_multiplet
IndexErrort_fill_single(RRtcountstinputsRR(tvaluetindex((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR/s4



cCsTt|jƒdkr(|jdƒr(tS|jddƒjƒ}|dkrPtStS(NRtmultipleRttradiotcheckbox(R8R9(RttagR+tTruetlowertFalse(RR((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR,Ms$cCs@|jddƒjƒ}|dkrœ|jdƒ}|dkr†|sNt}n(|d}t|tƒrv|dk}nt||ƒq<t|||kƒn |dkrÍ|jdƒ}t|||kƒnot|jƒdksèt	‚xQt
|ƒD]C}|jdƒ}|dkr%|jƒ}nt|||kƒqõWdS(	NRR7R9R4itonR8R(
R+R<tNoneR=R R!t_checkRR:tAssertionErrorRttext_contentt_select(RR4Rtvtresulttoption((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR/Vs(	
cCs9|r|jddƒnd|jkr5|jd=ndS(NtcheckedR7(tsettattrib(Rtcheck((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR@rscCs9|r|jddƒnd|jkr5|jd=ndS(NtselectedR7(RHRI(RR((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRCyscCs?t|jƒdkr+|jƒ||_n|jd|ƒdS(NRR4(RR:tclearttextRH(RR4((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR1€s
cCs|dkrE|dkrEt|ƒ}x|D]}|SWtdƒ‚n|dk	r¸|j|ƒ}|dk	rp|St|d|ƒ}|r|dStdtdjt|ƒƒfƒ‚n|dk	rt|ƒ}y||SWqtk
rtd|t	|ƒfƒ‚qXndS(NsNo forms in pageR(is-No form with the name or id of %r (forms: %s)s, s3There is no form with the index %r (%i forms found)(
R?RR
tget_element_by_idt_form_name_xpathtidtjoint_find_form_idsR0tlen(RRRtformstform((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR‡s0
"
ccs¸t|ƒ}|sdVdSx–t|ƒD]ˆ\}}|jdƒr‡|jdƒrvd|jdƒ|jdƒfVq°|jdƒVq(|jdƒr§|jdƒVq(d|Vq(WdS(Ns
(no forms)RPR(s%s or %ss(unnamed form %s)(Rt	enumerateR+(RRTR5RU((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRR¢scBs>eZeZeZdZdZdZdZd„Z	d„Z
RS(tdivs
error-messageserror-blocktInvalidcKsSxL|jƒD]>\}}t||ƒs;td|ƒ‚nt|||ƒq
WdS(NsUnexpected keyword argument: %s(titemsR)t	TypeErrortsetattr(tselftkwR(R4((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyt__init__¿s
cCs’|j|jƒ}|jr1|jd|jƒn|rj|jrj|jd|jddƒd|jƒn|dks‚|dkrŽ|j}nt|t	ƒr­|j
|ƒn1t|tƒsÌtd|ƒ‚|pØ|j|_
|r.|jr.|jr|j
|_d|_
|jd|ƒqŽ|j
|ƒn`|jƒ}|j|ƒ}|jre|j||ƒn)|j|_d|_|j|d|ƒdS(NtclassR7t s.Bad message; should be a string or element: %rii(tmakeelementterror_container_tagterror_message_classRHterror_block_classR+R?tdefault_messageR RtappendR!RARMtblock_insidet
insert_beforettailtinsertt	getparentR5(R\Rtis_blocktmessageterror_eltparenttpos((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyt__call__Æs2	*
				(RRR;RhRgRbRcRdReR^Rq(((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR·s	terrorc
Cs¯t|d|d|ƒ}x|jƒD]‚\}}|dkrCq%nxat|||ƒD]M\}}	t|	ttdƒtfƒstd|	ƒ‚t	||	||ƒqVWq%WdS(NRRsBad message: %r(
RRYR?t_find_elements_for_nameR R!RRRAt
_insert_error(
RterrorsRRterror_classt
error_creatorR(RrRnRm((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyR
ès!
cKsVt|ƒ}t|tƒr*t|ƒ}ntj|ƒ}t|||t||ƒS(N(RR R!RR"R#R
R(R$RR]R%R&((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRùscCsÏt|jƒtjks-t|jƒdkr6t}nt}t|jƒdkrg|rgt||ƒn|jdƒr»t|d|jdƒƒ}|r»x|D]}t||ƒqžWq»n||||ƒdS(NRRURPtfor_id(	RR:R	t
empty_tagsR=R;t
_add_classR+t_label_for_xpath(RRrRvRwRltlabelstlabel((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRts-	
cCsG|jdƒr3|jd|jdƒd|ƒn|jd|ƒdS(NR_R`(R+RH(Rt
class_name((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRzs$ccsà|dkr||fVdS|jdƒr[|j|dƒ}|dk	rW||fVndSt|d|ƒ}|swdSt|ttfƒsŸ|d|fVdSx:t||ƒD])\}}|dkrÍq¯n||fVq¯WdS(Nt#iR(i(R?t
startswithRNt_name_xpathR R-R.tzip(RUR(RrRtelsterr((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyRss$(sinputsselectstextareasx:inputsx:selects
x:textarea(,t
lxml.etreeRRt	lxml.htmlRRRRRRRR	R"R!t	NameErrortstrt__all__tLookupErrorR
RORQt_tagR*R{RR?RRRR,R/R@RCR1RRRtobjectRtdefault_error_creatorR
RRtRzRs(((s8/usr/lib64/python2.7/site-packages/lxml/html/formfill.pyt<module>sN"

		)										.					
Back to Directory File Manager