o nnh"@sddlmZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZdd lmZeZd d d ZddZdddZddZdddZd ddZdddZdddZdddZdS)!) annotationsN)context) constants)list_collections) AnsibleError) to_nativeto_bytes)loader)Display)_get_collection_path) async_wrapper)base)modulecachecCs|}d|vr |}n|dkr|drd}d||ddd}|g}|r8||tjj|dd|t|d|S)N.ansible.legacyzansible.builtin.ansible.builtin) startswithjoinsplitextendospathsepappendr) collectionnamerdepthresolved_collection resource_name compositer#?/usr/local/lib/python3.10/dist-packages/ansible/plugins/list.pyget_composite_names  r%c Cs i}|D]}td|||t|}tj|drqtj|rtj |r| }t |D]}|dr;q3td|tj |\} } t | } tj||} tj | r~|tjvrmtjtj| dsmq3|t|t | g||ddq3t| tjvt | tjv| dv| t|dvtj| grq3|d vrz t|| || } Wnty}ztd | t |fWYd}~q3d}~ww| D]} t|| jtjt | |}| ||<qq3t|| tjt | |}| ||<q3qtd |qtd |q|S) Nz&Searching '{0}'s '{1}' for {2} plugins).s__zFound possible plugin: '{0}'s __init__.pyr)r)s.ymls.yamls.jsonr#)testfilterzSkipping file %s: %sz6Skip listing plugins in '{0}' as it is not a directoryz2Skip listing plugins in '{0}' as it does not exist)displaydebugformatrrrbasenamerexistsisdirlowerlistdirsplitextrrCSYNTHETIC_COLLECTIONSupdate_list_plugins_from_pathsany IGNORE_FILES REJECT_EXTSIGNOREgetislink_list_j2_plugins_from_fileKeyErrorwarningr% ansible_namedirname)ptypedirsrrpluginsrb_pathbkey plugin_fileb_pluginb_extplugin full_path file_pluginse plugin_namer#r#r$r5-s^     "     ,r5cCs"ttd|}||||}|S)N {0}_loader)getattrr r+get_contained_plugins)r plugin_pathrArMploaderrKr#r#r$r<psr<c Csi}z ttd|}Wntytd|w|D]L}|dkr/dd|D}n3|dkrLdd|D}tj ddrK| tjdnt t j ||}ttj||d |g}|t|||q|d vr|D] }||df||<qt|St|D]7}d} z |j |d d } Wn!ty} ztd ||||t| WYd} ~ nd} ~ ww||| f||<q|S)NrNz8Cannot list plugins, incorrect plugin type supplied: {0}rcSsg|]}|jr|jqSr#internalr.0dr#r#r$ z+list_collection_plugins..rcSsg|]}|js|jqSr#rSrUr#r#r$rXrY module_pathsplugins)rT) class_onlyz8The '{0}' {1} plugin could not be loaded from '{2}': {3})rOr r+AttributeErrorrkeys_get_paths_with_contextrCLIARGSr:rrr2COLLECTION_PTYPE_COMPATrrrrr4r5list Exceptionr)vvv) rA collections search_pathsrCrRrrBb_ptyperIpobjrLr#r#r$list_collection_pluginsws>   *rhc Cst|tr|g}i}i}|dur"d|d<d|d<|t|ddn4|D]1}|dkr3d||<d|d<q$z tt|||<Wq$tyU}z td|t ||dd}~ww|r`|t |||S)NrrT)rededupez'Cannot use supplied collection {0}: {1})orig_exc) isinstancestrr4rrr ValueErrorrr+rrh)rArdrerCplugin_collectionsrrLr#r#r$ list_pluginss*  rpcCsddt||DS)NcSsg|]}|jqSr#)r?)rVrIr#r#r$rXsz%list_plugin_names..)rprArr#r#r$list_plugin_namessrrc t||fddDS)Ncg|]}|dqSrr#rVkrCr#r$rXrYz%list_plugin_files..rpr]rqr#rxr$list_plugin_files rzcrs)Ncrt)rr#rvrxr#r$rXrYz'list_plugin_classes..ryrqr#rxr$list_plugin_classesr{r|ru)N)NN) __future__rransiblerrr2ansible.collections.listransible.errorsr+ansible.module_utils.common.text.convertersrransible.pluginsr ansible.utils.displayr 2ansible.utils.collection_loader._collection_finderr r)r9r%r5r<rhrprrrzr|r#r#r#r$s,         C  6