Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /opt/alt/python311/lib64/python3.11/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python311/lib64/python3.11/__pycache__/sndhdr.cpython-311.pyc
�

�,d���dZddlZejed���ddgZddlmZedd	��Zd
ej_dej	_dej
_d
ej_dej_d�Z
d�ZgZd�Ze�e��d�Ze�e��d�Ze�e��d�Ze�e��d�Ze�e��d�Ze�e��d�Ze�e��d�Ze�e��d�Zd�Zd�Zd�Zd�Zd�Zedkre��dSdS) 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.
�N)��
)�remove�what�whathdr)�
namedtuple�
SndHeadersz.filetype framerate nchannels nframes sampwidthz�The 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.c�$�t|��}|S)zGuess the type of a sound file.)r)�filename�ress  �-/opt/alt/python311/lib64/python3.11/sndhdr.pyrr8s��
�(�
�
�C��J�c���t|d��5}|�d��}tD]'}|||��}|rt|�ccddd��S�(	ddd��dS#1swxYwYdS)zRecognize sound headers.�rbiN)�open�read�testsr	)r�f�h�tfrs     r
rr>s���	
�h��	�	���
�F�F�3�K�K���	(�	(�B��"�Q��(�(�C��
(�!�3�'�'�'���������
(��
��������������������s�7A$�A$�$A(�+A(c�:�tj��5tjdt���ddl}ddd��n#1swxYwY|�d��sdS|dd�dkrd	}n|dd�d
krd}ndS|�d��	|�|d��}n#t|j	f$rYdSwxYw||�
��|���|���d|�
��zfS)
zAIFC and AIFF files�ignore)�categoryrN�FORM��sAIFC�aifcsAIFF�aiff�r)�warnings�catch_warnings�simplefilter�DeprecationWarningr�
startswith�seekr�EOFError�Error�getframerate�getnchannels�
getnframes�getsampwidth)rrr�fmt�as     r
�	test_aifcr.Osm��	�	 �	"�	"�����h�1C�D�D�D�D�����������������������
�<�<�� � ���t���2��w�'������	
�1�R�4��G�	�	�����t��F�F�1�I�I�I���I�I�a��������d�j�!�����t�t���������!�!�1�>�>�#3�#3�
�L�L�N�N�A���� 0� 0�0�2�2s#� A�A�A�B3�3C�Cc��|�d��rt}n|dd�dvrt}ndSd}||dd���}||dd���}||dd���}||dd	���}||d	d
���}d}	|dkrd}
n|d
krd}
n
|dkrd}
d
}	nd}
|	|z}|r||z}nd}|||||
fS)zAU and SND filess.sndN�)sds.sdns.�aurr�����U�r�?���)r$�get_long_be�get_long_le)
rr�func�filetype�hdr_size�	data_size�encoding�rate�	nchannels�sample_size�sample_bits�
frame_size�nframes
             r
�test_aurGgs���|�|�G�������	
�2�A�2��%�	%�	%�����t��H��t�A�a��c�F�|�|�H���Q�q��t�W�
�
�I��t�A�b��e�H�~�~�H��4��"�R�%��>�>�D���Q�r�"�u�X���I��K��1�}�}����	�Q������	�Q�����������y�(�J����Z�'������T�9�f�k�9�9rc��|dd�dks|dd�dkrdSt|dd	���}|rd
|z}nd}d|d
ddfS)z	HCOM file�A�EsFSSD��sHCOMN��i"Vr�hcomr5r9r)r:)rr�divisorrAs    r
�	test_hcomrQ�sj����B��x�7���a��C��j�G�3�3��t��!�C��G�*�%�%�G����w�������4��B��!�!rc���|�d��sdSt|dd���}d}d|cxkrdkr1nn.||dkr"d||d	zz
}|rtd
|z��}d|ddd
fS)zVOC filesCreative Voice FileNr3�ri�r5�r0g��.A�vocr9r)r$�get_short_le�int)rr�sbseekrA�ratecodes     r
�test_vocrZ�s����<�<�2�3�3���t�
�!�B�r�E�(�
#�
#�F��D��F�����S������Q�v�Y�!�^�^���6�!�8��$���	-��y�8�+�,�,�D��$��2�q� � rc��ddl}|�d��r|dd�dks|dd�dkrdS|�d��	|�|d	��}n#t|jf$rYdSwxYwd
|���|���|���d|�	��zfS)zWAV filerNsRIFFrrsWAVEr2sfmt r�wav)
�waver$r%rr&r'r(r)r*r+)rrr]�ws    r
�test_wavr_�s����K�K�K��<�<�� � ��A�a��d�G�w�$6�$6�!�B�r�E�(�g�:M�:M��t��F�F�1�I�I�I���I�I�a��������d�j�!�����t�t������1�>�>�#�#�Q�^�^�%5�%5��<�<�>�>�1�Q�^�^�%5�%5�#5�7�7s�A%�%A:�9A:c�P�|�d��r|dd�dkrdSdS)z	8SVX filerrrs8SVXN)�8svxrr5rr)r$)rrs  r
�	test_8svxrb�s3���<�<�� � ��A�a��d�G�w�$6�$6��t��rc��|�d��r5t|dd���}t|dd���}d|d|dfSdS)	z	SNDT filesSOUNDrrr3rS�sndtr5N)r$r;rV)rr�nsamplesrAs    r
�	test_sndtrf�s[���|�|�H���,��q��2��w�'�'���A�b��e�H�%�%���t�Q��!�+�+�,�,rc��|�d��r/t|dd���}d|cxkrdkr
nd
Sd|ddd	fSd
Sd
S)z	SNDR filesr7r0i�i�a�sndrr5r9rN)r$rV)rrrAs   r
�	test_sndrri�sq���|�|�G���*��A�a��c�F�#�#���4� � � � �5� � � � � � ��4��B��)�)�*�*� � rc�Z�|ddz|ddzz|ddzz|dzS)Nrr4r5r2r7rr���bs r
r:r:��3��
�a�D�B�J�1�Q�4�2�:�&�!�A�$�!�)�4�q��t�;�;rc�Z�|ddz|ddzz|ddzz|dzS)Nrr4r7r2r5rrrkrls r
r;r;�rnrc�*�|ddz|dzS)Nrrr5rkrls r
�get_short_berq����
�a�D�A�I��1���rc�*�|ddz|dzS)Nr5rrrkrls r
rVrV�rrrc�n�ddl}d}|jdd�r|jddkr|jdd�=d}	|jdd�r t|jdd�|d��dStdg|d��dS#t$r3|j�d��|�d��YdSwxYw)Nrr5z-rr7�.z
[Interrupted]
)�sys�argv�testall�KeyboardInterrupt�stderr�write�exit)rv�	recursives  r
�testr~�s����J�J�J��I�
�x����|������t�+�+��H�Q�q�S�M��	���8�A�B�B�<�	)��C�H�Q�R�R�L�)�Q�/�/�/�/�/��S�E�9�a�(�(�(�(�(�������
���,�-�-�-��������������s�-A7�#A7�79B4�3B4c�F�ddl}ddl}|D�]}|j�|��r�t	|dzd���|s|rft	d��ddl}|�|j�|�|��d����}t||d����t	d����t	|dzd���|j	�
��	t	t|������#t$rt	d	��Y��wxYwdS)
Nrz/:� )�endzrecursing down:�*z*** directory (use -r) ***�:z*** not found ***)
rv�os�path�isdir�print�glob�join�escaperx�stdout�flushr�OSError)�listr}�toplevelrvr�rr��namess        r
rxrx�sL���J�J�J�
�I�I�I��+�+��
�7�=�=��"�"�	+��(�T�/�s�+�+�+�+��
4�H�
4��'�(�(�(������	�	�"�'�,�,�t�{�{�8�/D�/D�c�"J�"J�K�K����y�!�,�,�,�,��2�3�3�3�3��(�S�.�c�*�*�*�*��J������
+��d�8�n�n�%�%�%�%���
+�
+�
+��)�*�*�*�*�*�
+����+�+s�$D�D�D�__main__)�__doc__r �_deprecated�__name__�__all__�collectionsrr	r=�	frameraterB�nframes�	sampwidthrrrr.�appendrGrQrZr_rbrfrir:r;rqrVr~rxrkrr
�<module>r�sd����:�������X�g�.�.�.�.�
�9�
��"�"�"�"�"�"�
�Z��H�J�J�
� >�
���!1�
���!6�
����
���!#�
���������	��2�2�2�*���Y����:�:�:�>���W����	"�	"�	"����Y����
!�
!�
!����X����7�7�7����X����������Y����,�,�,����Y����*�*�*����Y����<�<�<�<�<�<�������
�
�
�+�+�+�*�z����D�F�F�F�F�F��r

ZeroDay Forums Mini