HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/landscape/lib/apt/package/__pycache__/skeleton.cpython-310.pyc
o

�1Db��@s�ddlmZmZddlmZddlZdZdZdZdZ	dZ
d	eBZd
eBZdeBZ
deBZd
eBZde	BZde
BZGdd�de�ZGdd�de�Zdd�Z	ddd�Zddd�ZdS)�)�unicode�_PY3)�sha1N�����iiiiiiic@seZdZdZdS)�PackageTypeErrorzDRaised when an unsupported package type is passed to build_skeleton.N)�__name__�
__module__�__qualname__�__doc__�rr�D/usr/lib/python3/dist-packages/landscape/lib/apt/package/skeleton.pyr
sr
c@sDeZdZdZdZdZdZdZdZdd�Z	dd�Z
dd�Zdd	�ZdS)
�PackageSkeletonNcCs||_||_||_g|_dS�N)�type�name�version�	relations)�selfrrrrrr�__init__#s
zPackageSkeleton.__init__cCs|j�||f�dSr)r�append)rr�inforrr�add_relation)szPackageSkeleton.add_relationcCsp|jdur|jSd|j|j|jf�d�}t|�}|j��|jD]}|�d|d|df�d��q!|�	�S)z�Calculate the package hash.

        If C{set_hash} has been used, that hash will be returned and the
        hash won't be the calculated value.
        Nz
[%d %s %s]�asciiz[%d %s]rr)
�_hashrrr�encoderr�sort�update�digest)r�package_infor!�pairrrr�get_hash,s
�

�zPackageSkeleton.get_hashcCs
||_dS)aZSet the hash to an explicit value.

        This should be used when the hash is previously known and can't
        be calculated from the relations anymore.

        The only use case for this is package resurrection. We're
        planning on getting rid of package resurrection, and this code
        can be removed when that is done.
        N)r)r�package_hashrrr�set_hash?s

zPackageSkeleton.set_hash)
rrr
�section�summary�description�size�installed_sizerrrr$r&rrrrrsrcCs&|\}}}|}|r|d||f7}|S)aConvert an apt relation to a string representation.

    @param relation_tuple: A tuple, (name, version, relation). version
        and relation can be the empty string, if the relation is on a
        name only.

    Returns something like "name > 1.0"
    z %s %sr)�relation_tuplerr�
relation_type�relation_stringrrr�relation_to_stringLs

	r/c
Cs`t�}t�|�|d��}|D]}dd�|D�}|}t|�dkr!|}d�|�}	|�||	f�q|S)a�Parse an apt C{Record} field and return skeleton relations

    @param record: An C{apt.package.Record} instance with package information.
    @param record_field: The name of the record field to parse.
    @param relation_type: The deb relation that can be passed to
        C{skeleton.add_relation()}
    @param or_relation_type: The deb relation that should be used if
        there is more than one value in a relation.
    �cSsg|]}t|��qSr)r/)�.0�relationrrr�
<listcomp>jsz&parse_record_field.<locals>.<listcomp>rz | )�set�apt_pkg�
parse_depends�get�len�join�add)
�record�record_fieldr-�or_relation_typer�values�value�
value_strings�value_relation_typer.rrr�parse_record_field\s
rBFcCsZ|jj|j}}|rt|�t|�}}tt||�}t�}|�t|j	dt
��|�td|jj|jff�|�t|j	dt
t��|�t|j	dt
t��|�td|jj|jff�|�t|j	dt��|�t|j	dt��t|�|_|r�|j|_|j|_|j|_|j|_|jdkr�|j|_|r�ts�|j�d	�|_|j�d	�|_t|jt�s�|j�d	�|_|S)
aSBuild a package skeleton from an apt package.

    @param version: An instance of C{apt.package.Version}
    @param with_info: Whether to extract extra information about the
        package, like description, summary, size.
    @param with_unicode: Whether the C{name} and C{version} of the
        skeleton should be unicode strings.
    �Providesz%s = %szPre-Depends�Dependsz%s < %s�	Conflicts�Breaksrzutf-8)�packagerrrr�DEB_PACKAGEr4r rBr;�DEB_PROVIDESr:�DEB_NAME_PROVIDES�DEB_REQUIRES�DEB_OR_REQUIRES�DEB_UPGRADES�
DEB_CONFLICTS�sortedrr'r(r)r*r+r�decode�
isinstance)r�	with_info�with_unicoder�version_string�skeletonrrrr�build_skeleton_aptssR	��
�
����

rVr)FF)�landscape.lib.compatrr�landscape.lib.hashlibrr5�PACKAGE�PROVIDES�REQUIRES�UPGRADES�	CONFLICTSrHrIrJrKrLrMrN�	Exceptionr
�objectrr/rBrVrrrr�<module>s*2
�