o nnh@sddlmZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZd gZGd d d e eZdS) ) annotationsN)AnsibleParserError AnsibleError) to_native) string_types)NonInheritableFieldAttribute)Base)CollectionSearch)load_list_of_roles)RoleRequirement RoleMetadatacsveZdZdZedddZededZeddZede dZ dfd d Z e dd d Z d dZddZddZZS)r zt This class wraps the parsing and validation of the optional metadata within each Role (meta/main.yml). boolF)isadefaultlistdict)rNcs||_tt|dSN)_ownersuperr __init__)selfowner __class__I/usr/local/lib/python3.10/dist-packages/ansible/playbook/role/metadata.pyr-szRoleMetadata.__init__cCs4t|ts td|t|dj|||d}|S)zY Returns a new RoleMetadata object based on the datastructure passed in. z3the 'meta/main.yml' for role %s is not a dictionary)r)variable_managerloader) isinstancerrget_namer load_data)datarrrmrrrload1s zRoleMetadata.loadc s^g}|rTt|tstd|jd|D]A}t|ts!d|vs!d|vr'||qzt|}|dr8|d|d<||Wqt yS}z tt |||dd}~wwd}d}|j rt j |j j}|j jddplg}|j jrfdd|D}|d d |vr|d zt||j j||j|j|d WSty} ztd |j| dd} ~ ww) z This is a helper loading function for the dependencies list, which returns a list of RoleInclude objects z(Expected role dependencies to be a list.)objrolename)r$orig_excNcsg|]}|kr|qSrr).0cowner_collectionrr bsz3RoleMetadata._load_dependencies..rzansible.legacy)playcurrent_role_pathrrcollection_search_listz6A malformed list of role dependencies was encountered.)rrr_dsrappendr role_yaml_parsegetrrrospathdirname _role_path collections_role_collectioninsertr _play_variable_manager_loaderAssertionError) rattrdsrolesrole_def def_parsedexcr.r/err*r_load_dependencies=sJ        zRoleMetadata._load_dependenciescCst|j|jdS)N)allow_duplicates dependencies)r_allow_duplicates _dependencies)rrrr serializeoszRoleMetadata.serializecCs,t|d|ddt|d|dgdS)NrGFrH)setattrr3)rr!rrr deserializeuszRoleMetadata.deserializer)NN)__name__ __module__ __qualname____doc__rrGrrH galaxy_inforargument_specsr staticmethodr#rFrKrM __classcell__rrrrr "s      2) __future__rr4ansible.errorsrr+ansible.module_utils.common.text.convertersransible.module_utils.sixransible.playbook.attributeransible.playbook.baser!ansible.playbook.collectionsearchr ansible.playbook.helpersr !ansible.playbook.role.requirementr __all__r rrrrs