ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/sndhdr.cpython-34.pyo

�
i fp�@sZdZddgZdd�Zdd�ZgZdd�Zeje�dd�Zeje�d	d
�Zeje�dd�Z	eje	�d
d�Z
eje
�dd�Zeje�dd�Zeje�dd�Z
eje
�dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zed!krVe�nd"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�whathdrcCst|�}|S)zGuess the type of a sound file.)r)�filename�res�r�+/opt/alt/python34/lib64/python3.4/sndhdr.pyr#scCsYt|d��D}|jd�}x'tD]}|||�}|r(|Sq(WdSWdQXdS)zRecognize sound headers.�rbiN)�open�read�tests)r�f�hZtfrrrrr)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)
N�sFORM��sAIFC�aifcsAIFFZaiff�r)
r�
startswith�seekr�EOFError�Error�getframerate�getnchannels�
getnframes�getsampwidth)rrrZfmt�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)
rr�funcZfiletypeZhdr_sizeZ	data_size�encoding�rateZ	nchannelsZsample_sizeZsample_bitsZ
frame_sizeZnframerrr�test_auOs2					

r-cCsr|dd�dks,|dd�dkr0dSt|dd��}|rYd	|}nd
}d|ddd
fS)N�A�EsFSSD��sHCOM��i"Vr
Zhcomr"rr')r()rrZdivisorr,rrr�	test_hcomps,
r4cCs�|jd�sdSt|dd��}d}d|koFdknr�||dkr�d||d}|r�td	|�}q�nd
|dddfS)
NsCreative Voice Filer �r
i�r"�rg��.AZvocrr')r�get_short_le�int)rrZsbseekr,Zratecoderrr�test_voc}s,r9cCs�ddl}|jd�sH|dd�dksH|dd�dkrLdS|jd�y|j|d�}Wnt|jfk
r�dSYnXd	|j�|j�|j�d|j	�fS)
Nr
sRIFFrrsWAVErsfmt rZwav)
�waverrZopenfprrrrrr)rrr:�wrrr�test_wav�s<
	r<cCs.|jd�s&|dd�dkr*dSdS)	NsFORMrrs8SVX�8svxr
r")r=r
r"r
r)r)rrrrr�	test_8svx�s&r>cCsR|jd�rNt|dd��}t|dd��}d|d|dfSdS)NsSOUNDrrr r5Zsndtr")rr)r7)rrZnsamplesr,rrr�	test_sndt�sr?cCs[|jd�rWt|dd��}d|ko<dknrWd|dd	dfSndS)
Nsr$ri�i�aZsndrr"rr')rr7)rrr,rrr�	test_sndr�sr@cCs,|dd>|dd>B|dd>B|dBS)Nr
r!r"rr$rr%r)�brrrr(�sr(cCs,|dd>|dd>B|dd>B|dBS)Nr%r!r$rr"rr
r)rArrrr)�sr)cCs|dd>|dBS)Nr
rr"r)rArrr�get_short_be�srBcCs|dd>|dBS)Nr"rr
r)rArrrr7�sr7cCs�ddl}d}|jdd�rQ|jddkrQ|jdd�=d}nyJ|jdd�r�t|jdd�|d�ntdg|d�Wn/tk
r�|jjd�|jd�YnXdS)Nr
r"z-rr$�.z
[Interrupted]
)�sys�argv�testall�KeyboardInterrupt�stderr�write�exit)rD�	recursiverrr�test�s&	 
rLc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)
Nr
z/:�end� zrecursing down:�*z*** directory (use -r) ***�:z*** not found ***)rD�os�path�isdir�print�glob�joinrF�stdout�flushr�OSError)�listrKZtoplevelrDrQrrU�namesrrrrF�s"




rF�__main__N)�__doc__�__all__rrr
r�appendr-r4r9r<r>r?r@r(r)rBr7rLrF�__name__rrrr�<module>s8











Zerion Mini Shell 1.0