Qfu$ ddlZddlZddlZddgZdZej eeddZejdjZ Gd d e Z d Z d Zd ZdZdZdZddgfdZddZgfdZdZdZdZedk(reyy)Ngetcaps findmatchztThe {name} module is deprecated and will be removed in Python {remove}. See the mimetypes module for an alternative.) )removecd|vrd|dfSy)Nlinenor)r)entrys ./opt/alt/python312/lib64/python3.12/mailcap.pylineno_sort_keyrs5%/!!z[^\xa1-\U0010FFFF\w@+=:,./-]c eZdZy)UnsafeMailcapInputN)__name__ __module__ __qualname__r rr rrs3rrc  i}d}tD]V} t|d}|5t||\}}dddj D]\}}||vr|||<|||z||<X|S#t$rYfwxYw#1swYIxYw)Nrr)listmailcapfilesopenOSError_readmailcapfileitems)capsr mailcapfpmorecapskeyvalues r rrs D F#% gs#B/F; Hf"..*JC$;!S  I-S +& K    Rs A+A:+ A76A7:B c dtjvr4tjd}|jtj}|Sdtjvrtjd}nd}|dzdddg}|S)NMAILCAPSHOME.z /.mailcapz /etc/mailcapz/usr/etc/mailcapz/usr/local/etc/mailcap)osenvironsplitpathsep)pathstrmailcapshomes r rr9swARZZ**Z(==, O RZZ ::f%DD;&"$<> Orc\ tjdtdt|d\}}|S)Nz2readmailcapfile is deprecated, use getcaps instead)warningswarnDeprecationWarningr)rr_s r readmailcapfiler3Ks.I MMF$a)r4(GD! Krc* i}|jx}r|ddk(s|jdk(r.|}|dddk(r%|j}|sd}|dd|z}|dddk(r%t|\}}|r|sp| ||d<|dz }|jd }t t |D]}||j||<d j |j}||vr||j|n|g||<|jx}r||fS) Nr#z\  r r /) readlinestrip parseliner(rangelenjoinlowerappend) rr rlinenextliner fieldstypesjs r rrSs< D++- $  7c>TZZ\R/ rsmv%{{}HX9x'Drsmv%  o V   %F8  aKF #s5z"AQx~~'E!H#hhuo##% $; I  V $DI5++- $ 6 <rcz g}dt|}}||kr,t|||\}}|j||dz}||kr,t|dkry|d|d|dd}}}d|i}|D]P}|jd}|dkr|}d} n)|d|j }||dzdj } ||vrL| ||<R||fS)Nrr r.NNview=r6)r> parsefieldrAfindr;) rBrDinfieldr rIrestfkeyfvalues r r<r<zs F c$iqA a%dAq)q e aC a% 6{QQiF12JtCd^F JJsO q5DF!9??$D1Q34[&&(F 6> !F4L ;rc~ |}||kr!||}|dk(rn|dk(r|dz}n|dz}||kr!|||j|fS)N;\r.r )r;)rBrMrNstartcs r rKrKsb9 E a% G 8  $Y!A!A a% a=   ! ##rrIz /dev/nullc t|r!d|d}tj|tyt |||}|D]M}d|vr.t |d||}||rt j|dk7r5t |||||} | I| |fcSy)Nz&Refusing to use mailcap with filename z . Use a safe temporary filename.rHtestr) _find_unsafer/r0rlookupsubstr&system) rMIMEtyper filenameplistmsgentrieserYcommands r rrsH\df c-.T8S)G  Q;6He4D| $1,#(E:  A:  rcg}||vr|||z}|jd}|ddz}||vr|||z}||Dcgc] }||vs| }}t|t}|Scc}w)Nr9rz/*)r )r(sortedr)rr^r rb MIMEtypesrcs r r[r[sG4DN*s#I|d"H4DN* %2g1g2W/2G N3s AAc*d}dt|}}||kr||}|dz}|dk7r|dk(r |||dz}|dz}||z}n||}|dz}|dk(r||z}n|dk(r||z}n|dk(r2t|r!d|d }tj|ty||z}nz|d k(rm|} ||kr||d k7r|dz}||kr ||d k7r|| |} |dz}t | |} t| r$d | d | d}tj|ty|| z}n|dz|z}||kr|S)Nr6rr %rUstz!Refusing to substitute MIME type z into a shell command.{}z!Refusing to substitute parameter z (z) into a shell command)r>rZr/r0r findparam) rOr^r_r`resrMrNrWrarVnameparams r r\r\se C c%jqA a% !H!A#a 8Dy!AaCLac!'CaAac!CxAgcHnc)YacCMM#'9:Hnc!eaC!A!eaCU1~aC!$.&]bdhiCMM#'9:Ek Ci!mE a%F Jrc|jdz}t|}|D]}|d|j|k(s||dcSy)NrJr6)r@r>)rpr`rNps r rnrnsI ::<# D D A  Ra5;;=D QR5L rcddl}t}|jdds t|yt dt |jdD]}|j||dz}t |dkr t dy|d}|d}t||d|\}}|st dt^t d|tj|}tj|}|st d|y) Nrr r.z"usage: mailcap [MIMEtype file] ...rIzNo viewer found forz Executing:z Exit status:) sysrargvshowr=r>printrtyper&r]waitstatus_to_exitcode) rurrMargsr^filerdrcstss r rYrYs 9D 88AB< T  1c#((mQ 'xx!A# t9q= 6 7 7AwtXvt<  ' . , ())G$C++C0Cnc*(rcXtdtD]}td|zt|s t}tdtt|}|D]G}t|||}|D]0}t|}|D]}td|z||t2Iy)NzMailcap files: zMailcap entries:z %-15s)rxrrrf)rfnckeysryrbrckeysks r rwrws  %r "2  G    G 4LE d t*A!9Di!mQqT* G r__main__)N)r&r/re__all___DEPRECATION_MSG _deprecatedrrcompilesearchrZWarningrrrr3rr<rKrr[r\rnrYrwr rr rs+  [ !#X/@rzz9:AA 44 4$%N> $ #);b6 ,.'R+." zFr