Wc$cs& ddlZddlZddlZddgZdZej eeddZejdjZ Gd d e Z d Z d Zd ZdZdZdZddgfdZddZgfdZdZdZdZedkr edSdS)Ngetcaps findmatchztThe {name} module is deprecated and will be removed in Python {remove}. See the mimetypes module for an alternative.)ii )Zremovecs"d|vr d|dfSdS)Nlinenor)r)Zentrys /usr/lib64/python3.12/mailcap.pylineno_sort_keyrs!5%/!!tz[^\xa1-\U0010FFFF\w@+=:,./-]cseZdZdS)UnsafeMailcapInputN)__name__Z __module__Z __qualname__rrrr r s33rr cs  i}d}tD]^} t|d}|5t||\}}dddj D]\}}||vr|||<|||z||<`|S#t$rYnwxYw#1swYLxYw)NrZr)listmailcapfilesZopenZOSError_readmailcapfileZitems)capsrZmailcapfpZmorecapskeyZvalues rrrs D F#% . . gs#B < </F; Hf < < < < <"..* . .JC$;;!S  I-S  . K    H  < < < < < < < <  Orcsf tjdtdt|d\}}|S)Nz2readmailcapfile is deprecated, use getcaps instead)warningswarnZDeprecationWarningr )rr Z_rrreadmailcapfilerKs3I MMF$a))r4(GD! Krcs@ i} |j}|s ||fS|ddks|jdkr;|}|dddkr'|j}|sd}|dd|z}|dddkr't|\}}|r|s| ||d<|dz }|jd }t t |D]}||j||<d j |j}||vr||j|n|g||<) Nrrz#iz\ z r/) Zreadlinestrip parselinerrangelenZjoinlowerappend) rrr lineZnextlinerfieldsZtypesZj rr r SsU D {{}tU6 <3 7c>>TZZ\R// rsmv%%{{}H8X9x'Drsmv%%  o V   %F8  aKF #s5z" ( (AQx~~'E!HHhhuo##% $;; I  V $ $ $DI9 rcs g}dt|}}||kr0t|||\}}|j||dz}||kr0t|dkrdS|d|d|dd}}}d|i}|D]T}|jd}|dkr|}d} n+|d|j }||dzdj } ||vrP| ||<V||fS)NrrrNNview=r)r parsefieldrZfindr) rr infieldrr#ZrestZfkeyZfvalue rrr|s F c$iqA a%%dAq)q e aC a%% 6{QzQiF12JtCd^F " " JJsO q55DFF!9??$D1Q34[&&(F 6>> !F4LL ;rcs |}||kr'||}|dkrn|dkr|dz}n|dz}||kr'|||j|fS)Nz;\rr)r)rr&r'startcs rr%r%sm9 E a%% G 88  $YY!AA!A a%% a=   ! ##rr#z /dev/nullcsF t|r%d|d}tj|tdSt |||}|D]Z}d|vr6t |d||}||rt j|dkr=t |||||} | V| |fcSdS)Nz&Refusing to use mailcap with filename z . Use a safe temporary filename.r"testr) _find_unsaferrr lookupsubstrsystem) r MIMEtyperfilenameplistmsgentrieser-commandr)rrrsH\d\d\df c-..zT8S)G    Q;;6He4D|t $1,,#(E:  A:    :rcsg}||vr |||z}|jd}|ddz}||vr |||z} fd|D}t|t}|S)Nrrz/*cs g|] }|vs| Srr)Z.0r7rs rz zlookup..s 2221112r)r)rsortedr)r r2rr6Z MIMEtypess ` rr/r/sG4DN*s#I|d"H4DN* 2222g22W/22G Nrcs~d}dt|}}||kr$||}|dz}|dkr|dkr |||dz}|dz}||z}n||}|dz}|dkr||z}n|dkr||z}n|dkr8t|r%d|d }tj|tdS||z}n|d kr|} ||kr$||d kr|dz}||kr ||d kr|| |} |dz}t | |} t| r(d | d | d}tj|tdS|| z}n|dz|z}||kr$|S)Nrrrz%r*ZsZtz!Refusing to substitute MIME type z into a shell command.z{z}z!Refusing to substitute parameter z (z) into a shell command)rr.rrr findparam) r(r2r3r4Zresr&r'r,r5r+nameZparams rr0r0s C c%jqA a%% !H!A#a 88Dyy!AaCLac!'CCaAac!CxxAgcHnc)))YaYaYacCMM#'9::4Hnc!eeaC!A!eeaCU1~aC!$.&&&]b]b]bdhdhdhiCMM#'9::4Ek Ci!mE a%%F Jrcs|jdz}t|}|D]!}|d|j|ks||dcSdS)Nr$r)rr)r;r4r'Zps rr:r:sV ::<# D D A  Ra5;;=D QR5LLL 2rcs$ddl}t}|jddst|dSt dt |jdD]}|j||dz}t |dkrt ddS|d}|d}t||d|\}}|st dtot d|tj|}tj|}|st d|dS) Nrrrz"usage: mailcap [MIMEtype file] ...r#zNo viewer found forz Executing:z Exit status:) sysrZargvshowrrprintrtyperr1Zwaitstatus_to_exitcode) r<r r&Zargsr2Zfiler8r7Zstsr!rr-r-s JJJ 9D 88AB<< T  1c#((mQ '++xx!A# t9q== 6 7 7 FF7AwtXvt< w ' . . . , ( ())G$C++C0Csnc***++rcstdtD]}td|zt|s t}tdtt|}|D]S}t|||}|D]8}t|}|D]}td|z||t:UdS)NzMailcap files:z zMailcap entries:z %-15s)r>r rr9)r ZfnZckeysr?r6r7ZkeysZks rr=r=s  22%r "2"2"2 GG 4   GG 4LE d t*  A!9D + +i!mQqT*** GGG  rZ__main__)N)rrZreZ__all__Z_DEPRECATION_MSGZ _deprecatedr rZcompileZsearchr.ZWarningr rr rr rr%rr/r0r:r-r=rrrr@s+  [ !#X/@@@rzz9:AA 4444444 4$'''R> $ $ $ #);b6    ,.''''R+++." zDFFFFr