%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/entitlements/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/entitlements/__pycache__/__init__.cpython-312.pyc

�

�Hcfk#�
���ddlZddlZddlmZddlmZmZmZmZm	Z	m
Z
ddlmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZmZdd
lmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(ddl)m*Z*ddl+m,Z,eeeeeejZej\ej^ee!e#e'e(g
Z0d/dede1de1fd�Z2	d0dede3de3dee1fd�Z4dedee1dee1fd�Z5ejlGd�dejn��Z8dedee1fd �Z9dedee1fd!�Z:ded"e
ed#e8d$ee1e3fd%ee1f
d&�Z;ded#e8dee1fd'�Z<d(ee1defd)�Z=dede3dej|fd*�Z?d+�Z@dede3fd,�ZAd/ded-e1fd.�ZBy)1�N)�defaultdict)�Dict�List�
NamedTuple�Optional�Tuple�Type)�
exceptions)�UAConfig)�fips)�AnboxEntitlement)�
UAEntitlement)�CommonCriteriaEntitlement)�CISEntitlement)�ApplicabilityStatus)�ESMAppsEntitlement�ESMInfraEntitlement)�LandscapeEntitlement)�LivepatchEntitlement)�RealtimeKernelEntitlement)�RepoEntitlement)�ROSEntitlement�ROSUpdatesEntitlement)�EntitlementNotFoundError)�is_config_value_true�cfg�name�variantc��tD]J}||��}||jvs�|s|cS||jvr|j|cSt|���t|���)aReturns a UAEntitlement class based on the provided name.

    The return type is Optional[Type[UAEntitlement]].
    It cannot be explicit because of the Python version on Xenial (3.5.2).
    :param cfg: UAConfig instance
    :param name: The name of the entitlement to return
    :param not_found_okay: If True and no entitlement with the given name is
        found, then returns None.
    :raise EntitlementNotFoundError: If not_found_okay is False and no
        entitlement with the given name is found, then raises this error.
    �r)�entitlement_name)�ENTITLEMENT_CLASSES�valid_names�variantsr)rrr�entitlement�ents     �@/usr/lib/python3/dist-packages/uaclient/entitlements/__init__.py�entitlement_factoryr((sg��+�I���c�"���3�?�?�"��"�"��C�L�L�(��|�|�G�,�,�.��H�H�I�#�D�
9�9��
allow_beta�	all_names�returnc�V�t|jd�}||z}t}|s|D�cgc]}|js|��}}|r6g}|D]$}|j	||��j
��&t
|�St
|D�cgc]}||��j��c}�Scc}wcc}w)aReturn a list of valid (non-beta) services.

    :param cfg: UAConfig instance
    :param allow_beta: if we should allow beta services to be marked as valid
    :param all_names: if we should return all the names for a service instead
        of just the presentation_name
    zfeatures.allow_betar )rrr"�is_beta�extendr#�sorted�presentation_name)rr*r+�allow_beta_cfg�entitlementsr%�namess       r'�valid_servicesr5@s���*�#�'�'�3H�I�N��.� �J�&�L�� ,�
���&�&�
�
��
����'�	;�K��L�L���-�9�9�:�	;��e�}��� ,�	
��
�C� �2�2�	
����
��	
s�B!�B&�entsc�F���t|���fd��t|�fd���S)zR
    A function to sort entitlments for enabling that preserves invalid names
    c�\��	�j|�S#t$rt��cYSwxYw�N)�index�
ValueError�len)r&�valid_ents_ordereds �r'� sort_order_with_nonexistent_lastzIorder_entitlements_for_enabling.<locals>.sort_order_with_nonexistent_lastls4���	+�%�+�+�C�0�0���	+��)�*�*�	+�s��+�+c����|�Sr9�)r&r>s �r'�<lambda>z1order_entitlements_for_enabling.<locals>.<lambda>rs
���(H��(M�r))�key)�entitlements_enable_orderr0)rr6r>r=s  @@r'�order_entitlements_for_enablingrDds%���3�3�7��+��$�M�N�Nr)c�(�eZdZe�Ze�Zy)�	SortOrderN)�__name__�
__module__�__qualname__�object�REQUIRED_SERVICES�DEPENDENT_SERVICESr@r)r'rFrFus�������r)rFc�8�t|tj��S)zR
    Return the entitlements disable order based on dependent services logic.
    �r�
sort_order)�_sort_entitlementsrFrLr s r'�entitlements_disable_orderrQ{s���#�)�2N�2N�O�Or)c�8�t|tj��S)zP
    Return the entitlements enable order based on required services logic.
    rN)rPrFrKr s r'rCrC�s���#�)�2M�2M�N�Nr)�ent_clsrO�visited�orderc��|j|vry|tjk(r*||�jD�cgc]}|j��}}nt||�j�}|D]!}|j|vs�t|||||���#|jt|j��d|t|j�<ycc}w)N�rrSrOrTrUT)
rrFrK�required_servicesr%�list�dependent_services�_sort_entitlements_visit�append�str)rrSrOrTrU�e�cls_list�cls_dependencys        r'r[r[�s����|�|�w����Y�0�0�0�+2�3�<�+I�+I�J�a�A�M�M�J��J�����7�7�8��"����<�<�w�&�$��&�%���
��
�L�L��W�\�\�"�#�!%�G�C�������Ks�Cc�D�g}i}tD]}t|||||���|S)NrW)r"r[)rrOrUrTrSs     r'rPrP�s9���E��G�&�
�� ���!���	
�
��Lr)r4c��g}|D]$}|t|dd��vs�|j|��&tt|�t|�z
�}||fS)z�Return a list of valid entitlement names.

    :param names: List of entitlements to validate
    :return: a tuple of List containing the valid and invalid entitlements
    T)rr*r+)r5r\r0�set)r4r�entitlements_found�ent_name�entitlements_not_founds     r'�get_valid_entitlement_namesrg�sg�����0���~����
�
�
�%�%�h�/�	0�$�C��J��5G�1H�$H�I���5�5�5r)c���t||��}dj|�}djtjd|zdzddd���}t	j
d	dj|�|�
�S)z{
    Constructs the MESSAGE_INVALID_SERVICE_OP_FAILURE message
    based on the attempted services and valid services.
    )rr*�, �
zTry �.�PF)�width�break_long_words�break_on_hyphens�enable)�	operation�invalid_service�service_msg)r5�join�textwrap�wrapr
�InvalidServiceOpError)rfrr*�valid_services_namesr#rss      r'�*create_enable_entitlements_not_found_errorry�sx��*�c�j�I���)�)�0�1�K��)�)��
�
��[� �3�&��"�"�		
��K��+�+���	�	�"8�9���r)c�"�t|t�Sr9)�
isinstancer)r&s r'�_is_repo_entitlementr|�s���c�?�+�+r)c�l�tt�}t|�D�]}t||�|�}t	|�s�"|j�\}}|tjk(rW|j}|jxsd}|D]6}|jj||�}	||	j|||d���8|j�D]e\}
}t|�dkDs�|dd}|dd}tj |j"dj%t'd�|D���||�	����y
)Nr@)�from�apt_url�suite�rrr�ric3�&K�|]	}|d���y�w)r~Nr@)�.0r&s  r'�	<genexpr>z>check_entitlement_apt_directives_are_unique.<locals>.<genexpr>s����D�s�s�6�{�D�s�)�urlr4rr�T)rrYr5r(r|�applicability_statusr�
APPLICABLEr�
apt_suites�repo_policy_check_tmpl�formatr\�itemsr<r
�%EntitlementsAPTDirectivesAreNotUnique�contract_urlrtr0)r�entitlement_directivesrer&r��_rr�r��entitlement_directive�def_path�
ent_directives            r'�+check_entitlement_apt_directives_are_uniquer��sY��)��.��"�3�'�$��0�!�#�x�0��5��#�C�(��"%�":�":�"<���a��#6�#A�#A�A��k�k�G����-�2�J�#�

��(+�(B�(B�(I�(I��U�)�%�'�'<�=�D�D� (�#*�!&���	

�(>�'C�'C�'E�	�#�H�m��=�!�A�%�'��*�9�5��%�a�(��1�� �F�F��(�(��)�)��D�m�D�D��$��
��	�1$�Lr)rec�z�	t|||��||��jS#tj$r|cYSwxYw)N)r)�called_name)r(�titler
�UbuntuProError)rrers   r'�	get_titler�sF���B�"�3��'�B��X�
�
�%�	���$�$�����s�"�:�:)�)FF)C�enumru�collectionsr�typingrrrrrr	�uaclientr
�uaclient.configr�uaclient.entitlementsr�uaclient.entitlements.anboxr
�uaclient.entitlements.baser�uaclient.entitlements.ccr�uaclient.entitlements.cisr�(uaclient.entitlements.entitlement_statusr�uaclient.entitlements.esmrr�uaclient.entitlements.landscaper�uaclient.entitlements.livepatchr�uaclient.entitlements.realtimer�uaclient.entitlements.repor�uaclient.entitlements.rosrr�uaclient.exceptionsr�
uaclient.utilr�FIPSEntitlement�FIPSUpdatesEntitlement�FIPSPreviewEntitlementr"r]r(�boolr5rD�unique�EnumrFrQrCr[rPrgr�ryr|r�r�r@r)r'�<module>r�s����#�@�@��$�&�8�4�>�4�H�M�@�@�D�6�K�8�.����������������������":�X�:�S�:�3�:�2@E�!�	�!�#�!�8<�!�	�#�Y�!�HO�	�O��c��O�	�#�Y�O�"���"��	�	�"�
�"�
P�H�P��c��P�O�8�O��S�	�O�&�	�&�
�-�
 �&��&��#�t�)�_�	&�
��9�&�:
�H�
�)�
��S�	�
� 6�t�C�y�6�x�6�&�!)��:>������4,�+�	�+�	�+�\�8��s�r)

Zerion Mini Shell 1.0