Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/pyanaconda/payload/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/pyanaconda/payload/__pycache__/requirement.cpython-36.pyc

3

C��ez �@svddlmZmZddlmZddlmZddlmZee	�Z
edddg�Zdd	gZGd
d	�d	e
�ZGdd�de
�ZdS)
�)�OrderedDict�
namedtuple)�PayloadRequirementType)�PayloadRequirementsMissingApply)�get_module_logger�PayloadRequirementReason�reason�strong�PayloadRequirements�PayloadRequirementc@sXeZdZdZddd�Zedd��Zedd��Zed	d
��Zddd
�Z	dd�Z
dd�ZdS)ra�An object to store a payload requirement with info about its reasons.

    For each requirement multiple reasons together with their strength
    can be stored in this object using the add_reason method.
    A reason should be just a string with description (ie for tracking purposes).
    Strength is a boolean flag that can be used to indicate whether missing the
    requirement should be considered fatal. Strength of the requirement is
    given by strength of all its reasons.
    NcCs||_|pg|_dS)N)�_id�_reasons)�selfZreq_id�reasons�r�#/usr/lib64/python3.6/requirement.py�__init__+szPayloadRequirement.__init__cCs|jS)z1Identifier of the requirement (eg a package name))r)rrrr�id/szPayloadRequirement.idcCsdd�|jD�S)z#List of reasons for the requirementcSsg|]\}}|�qSrr)�.0rr	rrr�
<listcomp>7sz.PayloadRequirement.reasons.<locals>.<listcomp>)r
)rrrrr4szPayloadRequirement.reasonscCstdd�|jD��S)z?Strength of the requirement (ie should it be considered fatal?)css|]\}}|VqdS)Nr)rrr	rrr�	<genexpr><sz,PayloadRequirement.strong.<locals>.<genexpr>)�anyr
)rrrrr	9szPayloadRequirement.strongFcCs|jjt||��dS)zEAdds a reason to the requirement with optional strength of the reasonN)r
�appendr)rrr	rrr�
add_reason>szPayloadRequirement.add_reasoncCsd|j|j|jfS)Nz0PayloadRequirement(id=%s, reasons=%s, strong=%s))rrr	)rrrr�__str__BszPayloadRequirement.__str__cCsd|j|jfS)Nz%PayloadRequirement(id=%s, reasons=%s))rr
)rrrr�__repr__GszPayloadRequirement.__repr__)N)F)�__name__�
__module__�__qualname__�__doc__r�propertyrrr	rrrrrrrr!s	

c@s�eZdZdZdd�Zddd�Zddd�Zd	d
�Zdd�Ze	d
d��Z
e	dd��Zdd�Zdd�Z
e	dd��Ze	dd��Zdd�ZdS)r
aMA container for payload requirements imposed by installed functionality.

    Stores names of packages and groups required by used installer features,
    together with descriptions of reasons why the object is required and if the
    requirement is strong. Not satisfying strong requirement would be fatal for
    installation.
    cCs0d|_d|_i|_xtD]}t�|j|<qWdS)NT)�"_apply_called_for_all_requirements�	_apply_cb�_reqsrr)r�req_typerrrrTs

zPayloadRequirements.__init__TcCs|jtj|||�dS)a�Add packages required for the reason.

        If a package is already required, the new reason will be
        added and the strength of the requirement will be updated.

        :param package_names: names of packages to be added
        :type package_names: list of str
        :param reason: description of reason for adding the packages
        :type reason: str
        :param strong: is the requirement strong (ie is not satisfying it fatal?)
        :type strong: bool
        N)�_addr�package)rZ
package_namesrr	rrr�add_packages[s
z PayloadRequirements.add_packagescCs|jtj|||�dS)a�Add groups required for the reason.

        If a group is already required, the new reason will be
        added and the strength of the requirement will be updated.

        :param group_ids: ids of groups to be added
        :type group_ids: list of str
        :param reason: descripiton of reason for adding the groups
        :type reason: str
        :param strong: is the requirement strong
        :type strong: bool
        N)r%r�group)rZ	group_idsrr	rrr�
add_groupsjs
zPayloadRequirements.add_groupscCsbx\|D]T}|jdkr*|j|jg|jd�q|jdkrJ|j|jg|jd�qtjd|j|�qWdS)z{Add requirements from a list of Requirement instances.

        :param requirements: list of Requirement instances
        r&)rr(z.Unknown type: %s in requirement: %s, skipping.N)�typer'�namerr)�logZwarning)rZrequirementsZrequirementrrr�add_requirementsys


z$PayloadRequirements.add_requirementscCsn|stjd|j|�|j|}xJ|D]B}||kr<t|�||<||j||�d|_tjd|j|||�q$WdS)Nzno %s requirement added for %sFz+added %s requirement '%s' for %s, strong=%s)r,�debug�valuer#rrr!)rr$Zidsrr	ZreqsZr_idrrrr%�s

zPayloadRequirements._addcCst|jtjj��S)z~List of package requirements.

        return: list of package requirements
        rtype: list of PayloadRequirement
        )�listr#rr&�values)rrrr�packages�szPayloadRequirements.packagescCst|jtjj��S)zzList of group requirements.

        return: list of group requirements
        rtype: list of PayloadRequirement
        )r0r#rr(r1)rrrr�groups�szPayloadRequirements.groupscCs
||_dS)aSet the callback for applying requirements.

        The callback will be called by apply() method.
        param callback: callback function to be called by apply() method
        type callback: a function taking one argument (requirements object)
        N)r")r�callbackrrr�set_apply_callback�sz&PayloadRequirements.set_apply_callbackcCs0|jr(d|_|j|�}tjd||�|St�dS)a]Apply requirements using callback function.

        Calls the callback supplied via set_apply_callback() method. If no
        callback was set, an axception is raised.

        return: return value of the callback
        rtype: type of the callback return value
        raise PayloadRequirementsMissingApply: if there is no callback set

        Tz.apply with result %s called on requirements %sN)r"r!r,r.r)r�rvrrr�apply�s
zPayloadRequirements.applycCs|jp
|jS)zzWas all requirements applied?

        return: Was apply called for all current requirements?
        rtype: bool
        )�emptyr!)rrrr�applied�szPayloadRequirements.appliedcCst|jj��S)zsAre requirements empty?

        return: True if there are no requirements, else False
        rtype: bool
        )rr#r1)rrrrr8�szPayloadRequirements.emptycCsHg}x:tD]2}x,|j|j�D]\}}|j|j||f�qWq
Wt|�S)N)rr#�itemsrr/�str)r�rr$ZridZreqrrrr�s

zPayloadRequirements.__str__N)T)T)rrrrrr'r)r-r%r r2r3r5r7r9r8rrrrrr
Ks

					N)�collectionsrrZpyanaconda.core.constantsrZpyanaconda.payload.errorsrZpyanaconda.anaconda_loggersrrr,r�__all__�objectrr
rrrr�<module>s*