%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/debian/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/debian/__pycache__/debfile.cpython-312.pyc

�

Cf�c�K���dZddlZddlZddlZddlZddlZddlmZ	ddl	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZddlmZddlmZmZmZdd	lmZdd
lm Z dZ!dZ"gd
�Z#dZ$gd�Z%dZ&dZ'dZ(dZ)Gd�de�Z*Gd�de+�Z,Gd�de,�Z-Gd�de,�Z.Gd�de�Z/e0dk(rHe/ejbd� �Z2e2jfji�Z4e5e4jmd��yy#e$r
dZesd�ZY��wxYw)!zX Representation of Debian binary package (.deb) files


Debfile Classes
===============
�N)�Path)�Any�BinaryIO�Dict�IO�Iterator�List�Optional�Text�TypeVar�Union�overload�
TYPE_CHECKING)�LiteralFc��y�N�)�fs �0/usr/lib/python3/dist-packages/debian/debfile.py�<lambda>r9s��)�ArFile�ArError�ArMember)�	Changelog)�Deb822zdata.tarzcontrol.tar)�gz�bz2�xz�lzma�zstz
debian-binary)�preinst�postinst�prerm�postrm�config�controlzusr/share/doc/%s/changelog.gzz$usr/share/doc/%s/changelog.Debian.gz�md5sumsc��eZdZy)�DebErrorN��__name__�
__module__�__qualname__rrrr*r*Ms��rr*c��eZdZdZd�Zd�Zed��Zd�Zdd�Z	e
dd��Ze
dd	��Zdd
�Ze
			dd��Ze
		dd��Z			dd
�Zd�Z
d�Zd�Zd�Zy)�DebParta�'Part' of a .deb binary package.

    A .deb package is considered as made of 2 parts: a 'data' part
    (corresponding to the possibly compressed 'data.tar' archive embedded
    in a .deb) and a 'control' part (the 'control.tar.gz' archive). Each of
    them is represented by an instance of this class. Each archive should
    be a compressed tar archive although an uncompressed data.tar is permitted;
    supported compression formats are: .tar.gz, .tar.bz2, .tar.xz .

    When referring to file members of the underlying .tar.gz archive, file
    names can be specified in one of 3 formats "file", "./file", "/file". In
    all cases the file is considered relative to the root of the archive. For
    the control part the preferred mechanism is the first one (as in
    deb.control.get_content('control') ); for the data part the preferred
    mechanism is the third one (as in deb.data.get_file('/etc/vim/vimrc') ).
    c� �||_d|_yr)�_DebPart__member�
_DebPart__tgz)�self�members  r�__init__zDebPart.__init__cs����
���
rc����fd�}�j���jj}tjj|�ddd}|tvs|tk(s	|tk(rE|dk(r|ddg�}n�j}	tj|d���_�jStd
|z���jS#tjtjf$r}td	|z��d}~wwxYw)z�Return a TarFile object corresponding to this part of a .deb
        package.

        Despite the name, this method gives access to various kind of
        compressed tar archives, not only gzipped ones.
        c�����	ddl}ddl�|j||j|jd�fd���}|j�jj��d}|jdk7r+t
d	dj|��d
|j�d���tj|�S#tt
f$r&}t
ddj|��d|�d���d}~wwxYw)NrFc�P���j�j�j�Sr)�signal�SIGPIPE�SIG_DFL)r:s�rrz9DebPart.tgz.<locals>._custom_decompress.<locals>.<lambda>}s����M�M�&�.�.�&�.�.�A�r)�stdin�stdout�universal_newlines�
preexec_fnzerror while running command '� z' as subprocess: '�'z	command 'z' has failed with code ')�
subprocessr:�Popen�PIPE�OSError�
ValueErrorr*�join�communicater2�read�
returncode�io�BytesIO)�command_listrC�proc�e�datar:r4s     @�r�_custom_decompressz'DebPart.tgz.<locals>._custom_decompressqs����
<�!��"�'�'� �$�/�/�*�/�/�',� B�	(����#�#�D�M�M�$6�$6�$8�9�!�<�D����!�#�� #���� 6���� I�J�J��:�:�d�#�#���Z�(�
<�� #���� 6�� ;�<�<��
<�s�5B4�4C)�!C$�$C)N�r!�unzstdz--stdoutzr:*)�fileobj�modez#tarfile has returned an error: '%s'z"part '%s' has unexpected extension)r3r2�name�os�path�splitext�	PART_EXTS�	DATA_PART�	CTRL_PART�tarfile�open�	ReadError�CompressionErrorr*)r4rRrW�	extension�bufferrPs`     r�tgzzDebPart.tgzhs����	$�4�:�:���=�=�%�%�D����(�(��.�q�1�!�"�5�I��I�%���):�d�i�>O���%�/��:�0F�G�F�!�]�]�F�N�!(���f�5�!I�D�J�
�z�z���C�d�J�K�K��z�z���	 �)�)�7�+C�+C�D�N�"�#H�1�#L�M�M��N�s�C�#C=�*C8�8C=c��t|�jdd�}|jd�r|S|jd�rd|zSd|zS)zw try (not so hard) to obtain a member file name in a form that is
        stored in the .tar.gz, i.e. starting with ./ �\�/z./�.)�str�replace�
startswith)�fnames r�__normalize_memberzDebPart.__normalize_member�sO���E�
�"�"�4��-�����D�!��L����C� ���;���e�|�rc�j�	g}|jd�ddD]�}|j|�tjj	dj|��}tj|�}|j�j|�}|j�s��|jjd�r(|jjd�}|j}��|j|d<��	tjtjj	��S#t$rYywxYw)z� walk the path following symlinks

        returns:
            resolved_path, info

        if the path is not found even after following symlinks within the
        archive, then None is returned.
        rgrSN���)�split�appendrXrY�normpathrHr0�_DebPart__normalize_memberrd�	getmember�issym�linknamerk�KeyError)r4rY�resolved_path_parts�pathpart�currpath�tinfos      r�__resolve_symlinkszDebPart.__resolve_symlinks�s��	�"$�� �J�J�s�O�A�B�/�
A��#�*�*�8�4��7�7�+�+�C�H�H�5H�,I�J��"�5�5�h�?�����
�,�,�X�6���;�;�=��~�~�0�0��5�.3�n�n�.B�.B�3�.G�+�#(�>�>��38�.�.�+�B�/�%
A�0�)�)�"�'�'�*:�*:�8�*D�E�E��	�	��	�s�BD&�AD&�&	D2�1D2c��tj|�}|j�j�}||vry|r|j	|�}|duS||vS)zmCheck if this part contains a given file name.

        Symlinks within the archive can be followed.
        TN)r0rsrd�getnames�_DebPart__resolve_symlinks)r4rl�follow_symlinks�names�
fname_reals     r�has_filezDebPart.has_file�sZ���*�*�5�1�����
�#�#�%���E�>����0�0��7�J��T�)�)���~�rNc��yrr�r4rl�encoding�errorsr�s     r�get_filezDebPart.get_file����	
rc��yrrr�s     rr�zDebPart.get_file�r�rc�2�tj|�}|r |j|�}|�td��|}	|j	�j|�}|�td��|�tj|||��S|S#t$rtd��wxYw)aReturn a file object corresponding to a given file name.

        If encoding is given, then the file object will return Unicode data;
        otherwise, it will return binary data.

        If follow_symlinks is True, then symlinks within the archive will be
        followed.
        zFile not found inside package�r�r�)	r0rsrr*rd�extractfilerwrL�
TextIOWrapper)r4rlr�r�r�r��fobjs       rr�zDebPart.get_file�s����*�*�5�1����0�0��7�J��!��>�?�?��E�	<��8�8�:�)�)�%�0�D��<��:�;�;����#�#�D�8�F�K�K�����	<��:�;�;�	<�s�B�Bc��yrrr�s     r�get_contentzDebPart.get_content���	
rc��yrrr�s     rr�zDebPart.get_contentr�rc��|jt|�|||��}d}|r |j�}|j�|S)a5Return the string content of a given file, or None (e.g. for
        directories).

        If encoding is given, then the content will be a Unicode object;
        otherwise, it will contain binary data.

        If follow_symlinks is True, then symlinks within the archive will be
        followed.
        )r�r�r�N)r�rirJ�close)r4rlr�r�r�r�contents       rr�zDebPart.get_content$sI�� 
�M�M���J��f�+�
�
��
����f�f�h�G�
�G�G�I��rc�P�t|j�j��Sr)�iterrdr~�r4s r�__iter__zDebPart.__iter__As���D�H�H�J�'�'�)�*�*rc�$�|j|�Sr)r��r4rls  r�__contains__zDebPart.__contains__Es���}�}�U�#�#rc�$�|j|�Sr)r�r�s  r�__getitem__zDebPart.__getitem__Is������&�&rc�8�|jj�yr)r2r�r�s rr�z
DebPart.closeMs���
�
���r)F)NNF)NF)r,r-r.�__doc__r6rd�staticmethodrsrr�rr�r�r�r�r�r�rrrr0r0Qs����"�
4�l�
��
�$F�L�$�
��
��
��
��@�"��$)�	
��
�� �$)�	
��
�"��$)�	�:+�$�'�rr0c��eZdZy)�DebDataNr+rrrr�r�Rs��rr�c�D�eZdZd�Zd�Zedd��Zedd��Zdd�Zy)	�
DebControlc�v�i}tD]-}|j|�s�|j|�}|��)|||<�/|S)zo Return a dictionary of maintainer scripts (postinst, prerm, ...)
        mapping script names to script text. )�
MAINT_SCRIPTSr�r�)r4�scriptsrlrQs    rr�zDebControl.scriptsYsJ��
��"�	*�E��}�}�U�#��'�'��.���#�%)�G�E�N�		*��rc�>�t|jt��S)z� Return the debian/control as a Deb822 (a Debian-specific dict-like
        class) object.

        For a string representation of debian/control try
        .get_content('control') )rr��CONTROL_FILEr�s r�
debcontrolzDebControl.debcontrolgs���d�&�&�|�4�5�5rNc��yrr�r4r�r�s   rr(zDebControl.md5sumsqr�rc��yrrr�s   rr(zDebControl.md5sumsvr�rc�x�|jt�stdtz��|jt||��}i}d}|�d}|j	�D]O}|j|�j
dd�\}}t|t�r|j�||<�K|||<�Q|j�|S)a� Return a dictionary mapping filenames (of the data part) to
        md5sums. Fails if the control part does not contain a 'md5sum' file.

        Keys of the returned dictionary are the left-hand side values of lines
        in the md5sums member of control.tar.gz, usually file names relative to
        the file system root (without heading '/' or './').

        The returned keys are Unicode objects if an encoding is specified,
        otherwise binary. The returned values are always Unicode.z('%s' file not found, can't list MD5 sumsr�z
Ns
rS)r��MD5_FILEr*r��	readlines�rstriprp�
isinstance�bytes�decoder�)	r4r�r��md5_file�sums�newline�line�md5rls	         rr(zDebControl.md5sums{s����}�}�X�&��:�X�E�G�
G��=�=��H�V�=�L���������G��&�&�(�	"�D����W�-�3�3�D�!�<�J�C���#�u�%�!�j�j�l��U��!��U��
	"�	�����r�NNr)r,r-r.r�r�rr(rrrr�r�Ws9���6��
��
��
��
�rr�c��eZdZdZdd�Zd�Zed��Zed��Zed��Z	d�Z
d	�Zedd
��Z
edd��Z
dd�Z
d
�Zd�Zd�Zd�Zy)�DebFilea�Representation of a .deb file (a Debian binary package)

    DebFile objects have the following (read-only) properties:
        - version       debian .deb file format version (not related with the
                        contained package version), 2.0 at the time of writing
                        for all .deb packages in the Debian archive
        - data          DebPart object corresponding to the data.tar.gz (or
                        other compressed or uncompressed tar) archive contained
                        in the .deb file
        - control       DebPart object corresponding to the control.tar.gz (or
                        other compressed tar) archive contained in the .deb
                        file
    Nc�&��tj||||�t|j����fd�}t�vrtdtz��i|_t|j|t���|jt<t|j|t���|jt<d|_|jt�}|j�j�|_|j!�y)Nc�$��tD�cgc]	}|�d|����}}|ttfvr|j|��j	t|��}|st
d|z��t|�dkDrt
d|z��t|�dScc}w)Nrhz9missing required part in given .deb (expected one of: %s)rSz>too many parts in given .deb (was looking for only one of: %s)r)	r[r\r]rq�intersection�setr*�len�list)�basename�ext�
candidates�parts�actual_namess    �r�compressed_part_namez.DebFile.__init__.<locals>.compressed_part_name�s����?H�I��X�s�3�I�J�I��I�y�1�1��!�!�(�+� �-�-�c�*�o�>�E���-�/9�:�;�;��5�z�A�~��9�;E�F�G�G���;�q�>�!��Js�B
z4missing required part in given .deb (expected: '%s'))rr6r�r~�	INFO_PARTr*�_DebFile__partsr�rtr]r�r\�_DebFile__pkgnamerJ�strip�_DebFile__versionr�)r4�filenamerVrUr�rr�s      @rr6zDebFile.__init__�s��������h��g�6��4�=�=�?�+��	"�&�L�(��$�&/�0�1�
1����",�T�^�^� ��+�.-�#.����Y��")�$�.�.� ��+�+-�#.����Y������N�N�9�%��������)���	���	rc�4�|j�d|_y)N�package)r�r�r�s r�__updatePkgNamezDebFile.__updatePkgName�s�����*�9�5��rc��|jSr)r�r�s r�versionzDebFile.version�s���~�~�rc�(�|jtSr)r�r\r�s rrQzDebFile.data�����|�|�I�&�&rc�(�|jtSr)r�r]r�s rr'zDebFile.control�r�rc�6�|jj�S)z See .control.debcontrol() )r'r�r�s rr�zDebFile.debcontrol�s���|�|�&�&�(�(rc�6�|jj�S)z See .control.scripts() )r'r�r�s rr�zDebFile.scripts�s���|�|�#�#�%�%rc��yrrr�s   rr(zDebFile.md5sums�r�rc��yrrr�s   rr(zDebFile.md5sums�r�rc�<�|jj||��S)z See .control.md5sums() r�)r'r(r�s   rr(zDebFile.md5sums�s���|�|�#�#�X�f�#�E�Erc�z�|j�|j�t|jzt|jzfD][}	|jj|d��}tj|��5}|j�}ddd�t�cSy#t$rY�jwxYw#1swY�'xYw)z� Return a Changelog object for the changelog.Debian.gz of the
        present .deb package. Return None if no changelog can be found. NT)r�)rU)r��_DebFile__updatePkgName�CHANGELOG_DEBIAN�CHANGELOG_NATIVErQr�r*�gzip�GzipFilerJr)r4rl�fhr�
raw_changelogs     r�	changelogzDebFile.changelogs���
�>�>�!�� � �"�&����7�&����7�9�		,�E�
��Y�Y�'�'��t�'�D�����r�*�
*�b� "���	�
�
*��]�+�+�		,����
��
��
*�
*�s�B"�:B1�"	B.�-B.�1B:	c�l�|jj�|jj�yr)r'r�rQr�s rr�z
DebFile.closes ���������	�	���rc��|Srrr�s r�	__enter__zDebFile.__enter__s���rc�$�|j�yr)r�)r4�exc_type�exc_val�exc_tbs    r�__exit__zDebFile.__exit__!s���
�
�r)N�rNr�r)r,r-r.r�r6r��propertyr�rQr'r�r�rr(r�r�r�r�rrrr�r��s����&�P6������'��'��'��'�)�
&�
�
��
��
��
�F�
�*�
�rr��__main__rS)r�)7r�r�rLr^�sys�os.pathrX�pathlibr�typingrrrrrr	r
rrr
rr�typing_extensionsr�ImportError�
debian.arfilerrr�debian.changelogr�
debian.deb822rr\r]r[r�r�r�r�r�r�r*�objectr0r�r�r�r,�argv�debr'rd�printrtrrr�<module>r�s$���.�	��
���"�
�
�
�
��4�3�&� �
�	��	�.�	��	�D�
���2��9����	�w�	�~�f�~�B	�g�	�
C��C�LF�f�F�R�z��
�3�8�8�A�;�
'�C�

�+�+�/�/�
�C�	�#�-�-�	�
"�#���i�"��M��"���"�s�"C1�1D�?D

Zerion Mini Shell 1.0