a )g@sddlmZmZmZeZddlZddlmZm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZd gZGd d d eeZdS) )absolute_importdivisionprint_functionN)AnsibleParserError AnsibleError) to_native) string_types)NonInheritableFieldAttribute)Base)CollectionSearch)load_list_of_roles)RoleRequirement RoleMetadatacs~eZdZdZedddZededZeddZede dZ dfd d Z e dd d Z ddZddZddZddZZS)rzt This class wraps the parsing and validation of the optional metadata within each Role (meta/main.yml). boolF)isadefaultlistZ GalaxyInfo)rdictNcs||_tt|dS)N)_ownersuperr__init__)selfowner __class__B/usr/lib/python3.9/site-packages/ansible/playbook/role/metadata.pyr/szRoleMetadata.__init__cCs4t|tstd|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) isinstancerrZget_namerZ load_data)datarrrmrrrload3s zRoleMetadata.loadc sg}|rt|ts td|jd|D]}t|tsBd|vsBd|vrN||q$z.t|}|drp|d|d<||Wq$t y}ztt |||dWYd}~q$d}~00q$d}d}|j r*t j |j j}|j jddpg}|j jrfdd|D}|d d |vr*|d zt||j j||j|j|d WSty~} ztd |j| dWYd} ~ n d} ~ 00dS) 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.)objZrolename)r#Zorig_excNcsg|]}|kr|qSrr).0cZowner_collectionrr dz3RoleMetadata._load_dependencies..rzansible.legacy)Zplaycurrent_role_pathrrcollection_search_listz6A malformed list of role dependencies was encountered.)rrrZ_dsrappendr Zrole_yaml_parsegetrrrospathdirnameZ _role_path collectionsZ_role_collectioninsertr Z_playZ_variable_managerZ_loaderAssertionError) rattrdsZrolesZrole_defZ def_parsedexcr*r+err'r_load_dependencies?sB     *    zRoleMetadata._load_dependenciescCs|S)z This is a helper loading function for the galaxy info entry in the metadata, which returns a GalaxyInfo object rather than a simple dictionary. r)rr4r5rrr_load_galaxy_infoqszRoleMetadata._load_galaxy_infocCst|j|jdS)N)allow_duplicates dependencies)rZ_allow_duplicatesZ _dependencies)rrrr serializezszRoleMetadata.serializecCs,t|d|ddt|d|dgdS)Nr:Fr;)setattrr-)rr rrr deserializeszRoleMetadata.deserialize)N)NN)__name__ __module__ __qualname____doc__r r:rr;Z galaxy_inforZargument_specsr staticmethodr"r8r9r<r> __classcell__rrrrr$s     2 )Z __future__rrrtypeZ __metaclass__r.Zansible.errorsrrZansible.module_utils._textrZansible.module_utils.sixrZansible.playbook.attributer Zansible.playbook.baser Z!ansible.playbook.collectionsearchr Zansible.playbook.helpersr Z!ansible.playbook.role.requirementr __all__rrrrrs