o
    ¡K&b
  ã                	   @   sÚ   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ d dlmZ d d	lmZmZ d d
lmZ d dlmZ e
eeeejejeeeg	Zdefdd„Z	ddededee fdd„ZdS )é    )ÚListÚType)ÚUAConfig)Úfips)ÚUAEntitlement)ÚCommonCriteriaEntitlement)ÚCISEntitlement)ÚESMAppsEntitlementÚESMInfraEntitlement)ÚLivepatchEntitlement)ÚROSEntitlementÚROSUpdatesEntitlement)ÚEntitlementNotFoundError)Úis_config_value_trueÚnamec                 C   s$   t D ]}| |ƒ jv r|  S qtƒ ‚)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 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.
    )ÚENTITLEMENT_CLASSESÚvalid_namesr   )r   Úentitlement© r   ú@/usr/lib/python3/dist-packages/uaclient/entitlements/__init__.pyÚentitlement_factory   s
   ÿr   FÚ
allow_betaÚ	all_namesÚreturnc                 C   sj   t ƒ }t|jdƒ}| |O } t}| sdd„ |D ƒ}|r,g }|D ]	}| |ƒ j¡ qt|ƒS tdd„ |D ƒƒS )zóReturn a list of valid (non-beta) services.

    @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
    zfeatures.allow_betac                 S   s   g | ]}|j s|‘qS r   )Zis_beta©Ú.0r   r   r   r   Ú
<listcomp>;   s    ýÿz"valid_services.<locals>.<listcomp>c                 S   s   g | ]}|ƒ j ‘qS r   )Zpresentation_namer   r   r   r   r   I   s    )r   r   Úcfgr   Úextendr   Úsorted)r   r   r   Zallow_beta_cfgZentitlementsÚnamesr   r   r   r   Úvalid_services,   s    	þÿr!   N)FF) Útypingr   r   Zuaclient.configr   Zuaclient.entitlementsr   Zuaclient.entitlements.baser   Zuaclient.entitlements.ccr   Zuaclient.entitlements.cisr   Zuaclient.entitlements.esmr	   r
   Zuaclient.entitlements.livepatchr   Zuaclient.entitlements.rosr   r   Zuaclient.exceptionsr   Zuaclient.utilr   ZFIPSEntitlementZFIPSUpdatesEntitlementr   Ústrr   Úboolr!   r   r   r   r   Ú<module>   s<    ÷ÿÿÿþ