U e5d4@sfdddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZmZmZddlmZdZdZdZdZdZedZedZddZddZd6d!dZd"dZd#d$Zd7d&dZ d8d'dZ!d9d(dZ"d)d Z#d*d Z$d+dZ%d,dZ&d:d-dZ'ed.ej(Z)d/dZ*d;d2dZ+d@,:;".]z[\\"]cCs*z|WdStk r$YdSXdS)NFT)encodeUnicodeEncodeError)sr#/usr/lib64/python3.8/email/utils.py_has_surrogates3s rcCs|dd}|ddS)Nutf-8surrogateescapereplace)rdecode)stringZoriginal_bytesrrr _sanitize@s r"rcCs|\}}|d|rz|dWn<tk r`t|trFt|}||}d||fYSXd}t|rtd}t d|}d||||fS|S)Nasciiz%s <%s>r"z\\\g<0>z %s%s%s <%s>) rr isinstancestrrZ header_encode specialsresearch escapesresub)ZpaircharsetnameZaddressZ encoded_nameZquotesrrrrLs      cCst|}t|}|jS)N) COMMASPACEjoin _AddressList addresslist)Z fieldvaluesallarrrrns cCsfddddddddg|d |d d d d dddddddddg |dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrr) timetuplezonerrr_format_timetuple_and_zoneus&  r;FcCsR|dkrt}|s|r,tj|tjj}n tj|}|rH|}d}t||S)NF)timedatetimeZ fromtimestamptimezoneutcZutcfromtimestamp astimezoner)timeval localtimeusegmtdtrrrr~s cCsV|}|r2|jdks$|jtjjkr,tdd}n|jdkrBd}n |d}t||S)Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)r9tzinfor=r>r? ValueErrorstrftimer;)rDrCnowr:rrrrs  cCs^ttd}t}td}|dkr0d}nd|}|dkrHt}d|||||f}|S)Nd@r.z<%d.%d.%d%s@%s>)intr<osgetpidrandomZ getrandbitssocketZgetfqdn)ZidstringZdomainrApidZrandintZmsgidrrrr s  cCsNt|^}}|dkr(tj|ddStj|dddttj|diS)Nr3rEseconds)rr=r> timedelta)dataZdtupletzrrrrs cCst|j}|sdS|dS)N)rrr)r/r0)ZaddrZaddrsrrrr s cCs`t|dkr\|dr<|dr<|ddddddS|dr\|dr\|ddS|S) Nr5r$z\\\z\"<>)len startswithendswithr)r&rrrrs   cCs&|td}t|dkr"dd|fS|S)Nr4)splitTICKr[)rpartsrrrrs   cCsDtjj|d|pdd}|dkr*|dkr*|S|dkr6d}d|||fS)Nrr#)Zsafeencodingz%s'%s'%s)urllibparser)rr+languagerrrrs z&^(?P\w+)\*((?P[0-9]+)\*?)?$c Csl|dd}g}i}|d\}}|||f|r|d\}}|drRd}nd}t|}t|}|r|dd\}}|dk rt|}||g|||fq0||dt |fq0|rh| D]\}}g}d} | |D].\}} }|r t j j| dd } d} || qt t|}| rTt|\} } }||| | d|ffq||d|fq|S) Nr*TFr,numz"%s"zlatin-1)ra)popappendr]rrfc2231_continuationmatchgrouprL setdefaultritemssortrbrc EMPTYSTRINGr.r) ZparamsZ new_paramsZrfc2231_paramsr,valueZencodedZmorfZ continuationsZextendedrr+rdrrrrsD    rus-asciicCsnt|trt|dkrt|S|\}}}|dkr4|}t|d}zt|||WStk rht|YSXdS)Nr6zraw-unicode-escape)r%tupler[rbytesr& LookupError)rperrorsZfallback_charsetr+rdtextZrawbytesrrrr9s  rWc Cs|dkrtjtjjS|jdk r.|S|dd|f}t|}t |}z tj |j d}t||j }Wnt k r|tjt|dd}tjo|jdk}|rtjntj }|tj |dkrt|tj|}n t|}YnX|j|dS)NrWrRr3r)rE)r=rHr>r?r@rEr9r<mktimerBrT tm_gmtofftm_zoneAttributeErrorgmtimedaylighttm_isdstaltzonetznamer) rDZisdstZtmrSZlocaltmZdeltarVZdstZgmtoffrrrrBSs$   rB)r)NFF)F)NN)NN)rrq)NrW)-__all__rMrer<rOrPr=Z urllib.parserbZemail._parseaddrrrr/r r r rZ email.charsetrr-roZ UEMPTYSTRINGZCRLFr_compiler'r)rr"rrr;rrr rr rrrASCIIrirrrBrrrrsn        "     8