| Current Path : /usr/lib/python3/dist-packages/uaclient/entitlements/__pycache__/ |
| Current File : //usr/lib/python3/dist-packages/uaclient/entitlements/__pycache__/__init__.cpython-38.pyc |
U
8�-d< �
@ s� d dl Z d dlZd dlmZmZmZ d dlmZ d dlm Z d dl
mZ d dlm
Z
d dlmZ d dlmZ d d lmZmZ d d
lmZ d dlmZ d dlmZmZ d d
lmZ d dlmZ eeeeej ej!eeeeg
Z"e e#d�dd�Z$d,e e%e%ee# d�dd�Z&e ee# ee# d�dd�Z'e j(G dd� de j)��Z*e ee# d�dd�Z+e ee# d�dd�Z,e ee
e*ee#e%f ee# d �d!d"�Z-e e*ee# d#�d$d%�Z.ee# e d&�d'd(�Z/e e%ej0d)�d*d+�Z1dS )-� N)�Dict�List�Type)�messages)�UAConfig)�fips)�
UAEntitlement)�CommonCriteriaEntitlement)�CISEntitlement)�ESMAppsEntitlement�ESMInfraEntitlement)�LivepatchEntitlement)�RealtimeKernelEntitlement)�ROSEntitlement�ROSUpdatesEntitlement)�EntitlementNotFoundError)�is_config_value_true)�cfg�namec C s. t D ]}||| d�jkr| S qt|��dS )a Returns 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 N)�ENTITLEMENT_CLASSES�valid_namesr )r r �entitlement� r �@/usr/lib/python3/dist-packages/uaclient/entitlements/__init__.py�entitlement_factory s
r F)r �
allow_beta� all_names�returnc sl t � jd�}||O }t}|s*dd� |D �}|rVg }|D ]}|�|� d�j� q6t|�S t� fdd�|D ��S )a Return 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_betac S s g | ]}|j s|�qS r )Zis_beta��.0r r r r �
<listcomp>A s �z"valid_services.<locals>.<listcomp>r c s g | ]}|� d �j �qS )r )Zpresentation_namer r r r r! O s �)r r r �extendr �sorted)r r r Zallow_beta_cfgZentitlements�namesr r r r �valid_services2 s"