ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/sndhdr.cpython-35.pyc



B�Ma�@svdZddgZddlmZedd�Zdd�Zdd�ZgZd	d
�Zej	e�dd�Z
ej	e
�d
d�Zej	e�dd�Zej	e�dd�Z
ej	e
�dd�Zej	e�dd�Zej	e�dd�Zej	e�dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zed%krre�d&S)'a�Routines to help recognizing sound files.

Function whathdr() recognizes various types of sound file headers.
It understands almost all headers that SOX can decode.

The return tuple contains the following items, in this order:
- file type (as SOX understands it)
- sampling rate (0 if unknown or hard to decode)
- number of channels (0 if unknown or hard to decode)
- number of frames in the file (-1 if unknown or hard to decode)
- number of bits/sample, or 'U' for U-LAW, or 'A' for A-LAW

If the file doesn't have a recognizable type, it returns None.
If the file can't be opened, OSError is raised.

To compute the total time, divide the number of frames by the
sampling rate (a frame contains a sample for each channel).

Function what() calls whathdr().  (It used to also use some
heuristics for raw data, but this doesn't work very well.)

Finally, the function test() is a simple main program that calls
what() for all files mentioned on the argument list.  For directory
arguments it calls what() for all files in that directory.  Default
argument is "." (testing all files in the current directory).  The
option -r tells it to recurse down directories found inside
explicitly given directories.
�what�whathdr�)�
namedtuple�
SndHeadersz.filetype framerate nchannels nframes sampwidthcCst|�}|S)zGuess the type of a sound file.)r)�filename�res�r�+/opt/alt/python35/lib64/python3.5/sndhdr.pyr(scCs`t|d��J}|jd�}x-tD]%}|||�}|r(t|�Sq(WdSWdQRXdS)zRecognize sound headers.�rbiN)�open�read�testsr)r�f�hZtfrrrr	r.s
cCs�ddl}|jd�sdS|dd�dkr>d}n#|dd�dkr]d}ndS|jd�y|j|d	�}Wnt|jfk
r�dSYnX||j�|j�|j�d|j	�fS)
NrsFORM��sAIFC�aifcsAIFFZaiff�r)
r�
startswith�seekr�EOFError�Error�getframerate�getnchannels�
getnframes�getsampwidth)rrrZfmt�arrr	�	test_aifc?s		
	rc
Cs6|jd�rt}n#|dd�dkr7t}ndSd}||dd��}||dd��}||dd��}||dd	��}||d	d
��}d}	|dkr�d}
n6|d
kr�d}
n!|dkr�d}
d
}	nd}
|	|}|r||}nd}|||||
fS)Ns.snd��ds.�dns.Zaurr�����U���?)rr ���)r�get_long_be�get_long_le)
rr�funcZfiletypeZhdr_sizeZ	data_size�encoding�rateZ	nchannelsZsample_sizeZsample_bitsZ
frame_sizeZnframerrr	�test_auTs2					

r/cCsr|dd�dks,|dd�dkr0dSt|dd��}|rYd	|}nd
}d|ddd
fS)N�A�EsFSSD��sHCOM��i"VrZhcomr$rr))r*)rrZdivisorr.rrr	�	test_hcomus,
r6cCs�|jd�sdSt|dd��}d}d|koFdknr�||dkr�d||d}|r�td	|�}d
|dddfS)
NsCreative Voice Filer"�ri�r$�rg��.AZvocrr))r�get_short_le�int)rrZsbseekr.Zratecoderrr	�test_voc�s,r;cCs�ddl}|jd�sH|dd�dksH|dd�dkrLdS|jd�y|j|d�}Wnt|jfk
r�dSYnXd	|j�|j�|j�d|j	�fS)
NrsRIFFrrsWAVEr!sfmt rZwav)
�waverrZopenfprrrrrr)rrr<�wrrr	�test_wav�s<
	r>cCs.|jd�s&|dd�dkr*dSdS)	NsFORMrrs8SVX�8svxrr$)r?rr$rr)r)rrrrr	�	test_8svx�s&r@cCsR|jd�rNt|dd��}t|dd��}d|d|dfSdS)NsSOUNDrrr"r7Zsndtr$)rr+r9)rrZnsamplesr.rrr	�	test_sndt�srAcCsX|jd�rTt|dd��}d|ko<dknrTd|dd	dfSdS)
Nsr&ri�i�aZsndrr$rr))rr9)rrr.rrr	�	test_sndr�srBcCs,|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)rCrrr	r+�sr+cCs|dd>|dBS)Nrrr$r)rCrrr	�get_short_be�srDcCs|dd>|dBS)Nr$rrr)rCrrr	r9�sr9cCs�ddl}d}|jdd�rN|jddkrN|jdd�=d}yJ|jdd�r�t|jdd�|d�ntdg|d�Wn/tk
r�|jjd�|jd�YnXdS)Nrr$z-rr&�.z
[Interrupted]
)�sys�argv�testall�KeyboardInterrupt�stderr�write�exit)rF�	recursiverrr	�test�s& 
rNcCsddl}ddl}x�|D]�}|jj|�r�t|ddd�|sW|r�td�ddl}|j|jj|d��}t||d�q�td�qt|ddd�|jj	�ytt
|��Wqtk
r�td	�YqXqWdS)
Nrz/:�end� zrecursing down:�*z*** directory (use -r) ***�:z*** not found ***)rF�os�path�isdir�print�glob�joinrH�stdout�flushr�OSError)�listrMZtoplevelrFrSrrW�namesrrr	rH�s"




rH�__main__N)�__doc__�__all__�collectionsrrrrr
r�appendr/r6r;r>r@rArBr*r+rDr9rNrH�__name__rrrr	�<module>s>	











Zerion Mini Shell 1.0