U e5dKQ@svddlmZddlmZddlmZddlmZGdddZGdddZGd d d e Z d d Z Gd ddZ Gddde Z GdddZGdddeZGdddZGdddeZGdddeZGdddeZGdddZGdd d ZGd!d"d"eZGd#d$d$eZGd%d&d&ZGd'd(d(Ze eeeeeeeeeeeeeeeeeeed)ZGd*d+d+Zd,S)-)MappingProxyType)utils)errors)_header_value_parserc@s^eZdZdddZeddZeddZed d Zed d Zd dZ ddZ ddZ dS)AddressNcCsdtd||||f}d|ks(d|kr0td|dk r|s@|rHtdt|\}}|rjtd|||jrz|jd|j}|j }||_ ||_ ||_ dS)Nr  z8invalid arguments; address parts cannot contain CR or LFz=addrspec specified when username and/or domain also specifiedz6Invalid addr_spec; only '{}' could be parsed from '{}'r) joinfilter ValueError TypeErrorparserZ get_addr_specformat all_defects local_partdomain _display_name _username_domain)self display_nameusernamer addr_specZinputsZa_srestr,/usr/lib64/python3.8/email/headerregistry.py__init__s& zAddress.__init__cCs|jSNrrrrrr<szAddress.display_namecCs|jSr)rr rrrr@szAddress.usernamecCs|jSr)rr rrrrDszAddress.domaincCsTt|j}t|t|tjkr.t|j}n|j}|jrH|d|jS|sPdS|S)N@<>)setrlenrZ DOT_ATOM_ENDS quote_stringr)rnamesetZlprrrrHs zAddress.addr_speccCsd|jj|j|j|jS)Nz1{}(display_name={!r}, username={!r}, domain={!r}))r __class____name__rrrr rrr__repr__Xs zAddress.__repr__cCs^t|j}t|t|tjkr.t|j}n|j}|rX|jdkrFdn|j}d||S|jS)Nr"rz{} <{}>)r#rr$rSPECIALSr%rr)rr&disprrrr__str__]s  zAddress.__str__cCs8t|t|krdS|j|jko6|j|jko6|j|jkSNF)typerrrrotherrrr__eq__hs   zAddress.__eq__)rrrN) r( __module__ __qualname__rpropertyrrrrr)r,r1rrrrrs *     rc@sFeZdZdddZeddZeddZdd Zd d Zd d Z dS)GroupNcCs||_|rt|nt|_dSr)rtuple _addresses)rr addressesrrrrrszGroup.__init__cCs|jSrrr rrrrszGroup.display_namecCs|jSr)r7r rrrr8szGroup.addressescCsd|jj|j|jS)Nz${}(display_name={!r}, addresses={!r})rr'r(rr8r rrrr)s zGroup.__repr__cCs|jdkr&t|jdkr&t|jdS|j}|dk r\t|}t|t|tjkr\t|}ddd|jD}|r~d|n|}d ||S)Nr, css|]}t|VqdSrstr).0xrrr sz Group.__str__.. z{}:{};) rr$r8r<r#rr*r%r r)rr+r&Zadrstrrrrr,s z Group.__str__cCs,t|t|krdS|j|jko*|j|jkSr-)r.rr8r/rrrr1s   z Group.__eq__)NN) r(r2r3rr4rr8r)r,r1rrrrr5ps    r5c@sPeZdZddZddZeddZeddZd d Ze d d Z d dZ dS) BaseHeadercCs\dgi}|||t|dr4t|d|d<t||d}|d=|j|f||S)Ndefectsdecoded)parserZ_has_surrogates _sanitizer<__new__init)clsnamevaluekwdsrrrrrFs zBaseHeader.__new__cCs||_||_||_dSr)_name _parse_tree_defects)rrI parse_treerBrrrrGszBaseHeader.initcCs|jSr)rLr rrrrIszBaseHeader.namecCs t|jSr)r6rNr rrrrBszBaseHeader.defectscCst|jj|jjt|f|jfSr)_reconstruct_headerr'r( __bases__r<__dict__r rrr __reduce__szBaseHeader.__reduce__cCs t||Sr)r<rF)rHrJrrr _reconstructszBaseHeader._reconstructc Cs`ttt|jdtddgg}|jrH|ttddg||j|j |dS)Nz header-name:z header-sepr@Zfws)policy) rZHeaderZ HeaderLabelZ ValueTerminalrIrMappendZCFWSListZWhiteSpaceTerminalfold)rrVheaderrrrrXs   zBaseHeader.foldN) r(r2r3rFrGr4rIrBrS classmethodrTrXrrrrrAs"     rAcCst||i|Sr)r.rT)Zcls_namebasesrJrrrrP srPc@s&eZdZdZeejZeddZ dS)UnstructuredHeaderNcCs"|||d<t|d|d<dS)NrOrC) value_parserr<rHrJrKrrrrDszUnstructuredHeader.parse) r(r2r3 max_count staticmethodrget_unstructuredr]rZrDrrrrr\s r\c@seZdZdZdS)UniqueUnstructuredHeaderr9Nr(r2r3r_rrrrrbsrbcsBeZdZdZeejZeddZ fddZ e ddZ Z S) DateHeaderNcCsz|s6|dtd|d<d|d<t|d<dSt|trJt|}||d<t |d|d<| |d|d<dS)NrBdatetimerrCrO) rWrZHeaderMissingRequiredValuerZ TokenList isinstancer<rZparsedate_to_datetimeZformat_datetimer]r^rrrrD.s   zDateHeader.parsecs|d|_tj||dS)Nre)pop _datetimesuperrGrargskwr'rrrG<s zDateHeader.initcCs|jSr)rhr rrrre@szDateHeader.datetime)r(r2r3r_r`rrar]rZrDrGr4re __classcell__rrrmrrds   rdc@seZdZdZdS)UniqueDateHeaderr9NrcrrrrroEsrocsPeZdZdZeddZeddZfddZe dd Z e d d Z Z S) AddressHeaderNcCst|\}}|Sr)rZget_address_list)rJ address_listrrrr]NszAddressHeader.value_parsercCst|trV|||d<}g}|jD]"}|t|jdd|jDq&t|j }n"t |dsf|g}dd|D}g}||d<||d<d d d|D|d <d|kr||d |d<dS) NrOcSs*g|]"}t|jpd|jpd|jp"dqS)r)rrrr)r=Zmbrrr ]s  z'AddressHeader.parse..__iter__cSs&g|]}t|dstd|gn|qS)r8N)hasattrr5r=itemrrrrrfsgroupsrBr:cSsg|] }t|qSrr;rurrrrrlsrC) rfr<r]r8rWr5rZ all_mailboxeslistrrtr )rHrJrKrqrwZaddrrBrrrrDTs*     zAddressHeader.parsecs(t|d|_d|_tj||dS)Nrw)r6rg_groupsr7rirGrjrmrrrGpszAddressHeader.initcCs|jSr)ryr rrrrwuszAddressHeader.groupscCs&|jdkr tdd|jD|_|jS)Ncss|]}|jD] }|Vq qdSr)r8)r=groupaddressrrrr?|sz*AddressHeader.addresses..)r7r6ryr rrrr8ys zAddressHeader.addresses) r(r2r3r_r`r]rZrDrGr4rwr8rnrrrmrrpJs    rpc@seZdZdZdS)UniqueAddressHeaderr9Nrcrrrrr|sr|c@seZdZeddZdS)SingleAddressHeadercCs(t|jdkrtd|j|jdS)Nr9z9value of single address header {} is not a single addressr)r$r8r rrIr rrrr{s zSingleAddressHeader.addressN)r(r2r3r4r{rrrrr}sr}c@seZdZdZdS)UniqueSingleAddressHeaderr9Nrcrrrrr~sr~csZeZdZdZeejZeddZ fddZ e ddZ e dd Z e d d ZZS) MIMEVersionHeaderr9cCs|||d<}t||d<|d|j|jdkrs z1ParameterizedMIMEHeader.parse..)r]r<rrrrrrrrDs   zParameterizedMIMEHeader.parsecs|d|_tj||dS)Nr)rg_paramsrirGrjrmrrrGs zParameterizedMIMEHeader.initcCs t|jSr)rrr rrrrszParameterizedMIMEHeader.params) r(r2r3r_rZrDrGr4rrnrrrmrrs  rcsJeZdZeejZfddZeddZ eddZ eddZ Z S) ContentTypeHeadercs2tj||t|jj|_t|jj|_dSr) rirGrrErMmaintype _maintypesubtype_subtyperjrmrrrGszContentTypeHeader.initcCs|jSr)rr rrrrszContentTypeHeader.maintypecCs|jSr)rr rrrrszContentTypeHeader.subtypecCs|jd|jS)N/)rrr rrr content_typeszContentTypeHeader.content_type) r(r2r3r`rZparse_content_type_headerr]rGr4rrrrnrrrmrrs    rcs2eZdZeejZfddZeddZ Z S)ContentDispositionHeadercs2tj|||jj}|dkr"|nt||_dSr)rirGrMcontent_dispositionrrE_content_disposition)rrkrlZcdrmrrrGszContentDispositionHeader.initcCs|jSr)rr rrrrsz,ContentDispositionHeader.content_disposition) r(r2r3r`rZ parse_content_disposition_headerr]rGr4rrnrrrmrrs  rcsBeZdZdZeejZeddZ fddZ e ddZ Z S)ContentTransferEncodingHeaderr9cCs2|||d<}t||d<|d|jdSNrOrCrBr]r<rrrrrrrDs z#ContentTransferEncodingHeader.parsecs"tj||t|jj|_dSr)rirGrrErMcte_cterjrmrrrGsz"ContentTransferEncodingHeader.initcCs|jSr)rr rrrr sz!ContentTransferEncodingHeader.cte)r(r2r3r_r`rZ&parse_content_transfer_encoding_headerr]rZrDrGr4rrnrrrmrrs   rc@s&eZdZdZeejZeddZ dS)MessageIDHeaderr9cCs2|||d<}t||d<|d|jdSrrrrrrrDs zMessageIDHeader.parseN) r(r2r3r_r`rZparse_message_idr]rZrDrrrrrs r)Zsubjectdatez resent-datez orig-dateZsenderz resent-sendertoz resent-toZccz resent-ccZbccz resent-bccfromz resent-fromzreply-toz mime-versionz content-typezcontent-dispositionzcontent-transfer-encodingz message-idc@s4eZdZeedfddZddZddZdd Zd S) HeaderRegistryTcCs&i|_||_||_|r"|jtdSr)registry base_class default_classupdate_default_header_map)rrrZuse_default_maprrrr9s zHeaderRegistry.__init__cCs||j|<dSr)rrrrIrHrrr map_to_typeKszHeaderRegistry.map_to_typecCs,|j||j}td|j||jfiS)N_)rgetrrr.r(rrrrr __getitem__QszHeaderRegistry.__getitem__cCs||||Srr)rrIrJrrr__call__Us zHeaderRegistry.__call__N) r(r2r3rAr\rrrrrrrrr5s  rN)typesrZemailrrrrrr5r<rArPr\rbrdrorpr|r}r~rrrrrrrrrrrr sV    `6d '7 %