3 \@s.ddgZddlmZeddZdej_dej_dej_d ej_d ej _d dZ d dZ gZ d dZ e je ddZe jeddZe jeddZe jeddZe jeddZe jeddZe jeddZe jeddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zed)kr*ed*S)+whatwhathdr) namedtuple SndHeadersz.filetype framerate nchannels nframes sampwidthzThe value for type indicates the data type and will be one of the strings 'aifc', 'aiff', 'au','hcom', 'sndr', 'sndt', 'voc', 'wav', '8svx', 'sb', 'ub', or 'ul'.zYThe sampling_rate will be either the actual value or 0 if unknown or difficult to decode.z^The number of channels or 0 if it cannot be determined or if the value is difficult to decode.z?The value for frames will be either the number of frames or -1.zAEither the sample size in bits or 'A' for A-LAW or 'U' for u-LAW.cCs t|}|S)N)r)filenameresr/usr/lib64/python3.6/sndhdr.pyr4sc CsHt|d4}|jd}x"tD]}|||}|rt|SqWdSQRXdS)Nrbi)openreadtestsr)rfhZtfrrrr r:s     cCsddl}|jdsdS|dddkr,d}n|dddkrBd}ndS|jdy|j|d }Wnt|jfk rzdSX||j|j|jd|j fS) NrsFORM sAIFCaifcsAIFFZaiffr) r startswithseekr EOFErrorError getframerate getnchannels getnframes getsampwidth)rrrZfmtarrr test_aifcKs  rc Cs|jdrt}n|dddkr&t}ndSd}||dd}||dd}||dd}||dd }||d d }d } |d krd } n$|d krd} n|dkrd} d } nd} | |} | r|| } nd} |||| | fS)Ns.sndds.dns.ZaurrU?)rr )r get_long_be get_long_le) rrfuncfiletypeZhdr_sizeZ data_sizeencodingrate nchannelsZ sample_sizeZ sample_bitsZ frame_sizeZnframerrr test_au`s2  r1cCsT|dddks |dddkr$dSt|dd}|rBd |}nd }d |d dd fS)NAEsFSSDsHCOMi"VrZhcomr$rr))r*)rrZdivisorr/rrr test_hcoms  r8cCst|jdsdSt|dd}d}d|ko4dknrf||dkrfd||d}|rftd |}d |dd d fS) NsCreative Voice Filer"rir$rg.AZvocrr))r get_short_leint)rrZsbseekr/Zratecoderrr test_vocs $ r=cCsddl}|jd s4|dddks4|dddkr8dS|jdy|j|d}Wnt|jfk rldSXd |j|j|jd|j fS) NrsRIFFrrsWAVEr!sfmt rZwav) waverrZopenfprrrrrr)rrr>wrrr test_wavs, r@cCs$|jd s|dddkr dSdS) NsFORMrrs8SVX8svxrr$)rArr$rr)r)rrrrr test_8svxsrBcCs<|jdr8t|dd}t|dd}d|d|dfSdS)NsSOUNDrrr"r9Zsndtr$)rr+r;)rrZnsamplesr/rrr test_sndts rCcCsD|jdr@t|dd}d|ko,dknr@d|dd dfSdS) Nsr&riiaZsndrr$rr))rr;)rrr/rrr test_sndrs rDcCs,|dd>|dd>B|dd>B|dBS)Nrr#r$r!r&rr'r)brrr r*sr*cCs,|dd>|dd>B|dd>B|dBS)Nr'r#r&r!r$rrr)rErrr r+sr+cCs|dd>|dBS)Nrrr$r)rErrr get_short_besrFcCs|dd>|dBS)Nr$rrr)rErrr r;sr;c Csddl}d}|jddr8|jddkr8|jdd=d}y8|jddr`t|jdd|dntdg|dWn*tk r|jjd|jdYnXdS)Nrr$z-rr&.z [Interrupted] )sysargvtestallKeyboardInterruptstderrwriteexit)rH recursiverrr tests  rPc Csddl}ddl}x|D]}|jj|rzt|ddd|s>|rptdddl}|j|jj|d}t||dqtdqt|ddd|jj ytt |Wqt k rtd YqXqWdS) Nrz/: )endzrecursing down:*z*** directory (use -r) ***:z*** not found ***) rHospathisdirprintglobjoinrJstdoutflushrOSError)listrOZtoplevelrHrUrrYnamesrrr rJs"    rJ__main__N)__all__ collectionsrrr-__doc__Z framerater0ZnframesZ sampwidthrrr rappendr1r8r=r@rBrCrDr*r+rFr;rPrJ__name__rrrr !sF