HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/lib/python3.9/site-packages/ansible/cli/__pycache__/doc.cpython-39.pyc
a

�)g��@sddlmZmZmZeZddlmZddlZddl	Z	ddl
Z	ddlZddlZddl
Z
ddlmmZddlmZddlmZddlmZddlmZddlmZdd	lmZmZm Z m!Z!dd
l"m#Z#m$Z$ddl%m&Z&ddl'm(Z(dd
l)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddlm7Z7m8Z8ddl9m:Z:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAmBZBmCZCe?�ZDejEdZFgd�ZGiZHgd�ZId+dd�ZJdd�ZKGd d!�d!eL�ZMGd"d#�d#eeM�ZNd$d%�ZOd&d'�ZPd,d(d)�ZQeRd*k�reQ�dS)-�)�absolute_import�division�print_function)�CLIN)�Path)�	constants)�context)�option_helpers)�list_collection_dirs)�AnsibleError�AnsibleOptionsError�AnsibleParserError�AnsiblePluginNotFound)�	to_native�to_text)�is_sequence)�	json_dump)�	yaml_dump)�	importlib)�string_types)�read_docstub)�	from_yaml)�
AnsibleDumper)�list_plugins)�
action_loader�fragment_loader)�AnsibleCollectionConfig�AnsibleCollectionRef)�_get_collection_name_from_path)�Display)�get_plugin_docs�
get_docstring�get_versioned_doclink)�role�keyword)ZPlayZRoleZBlockZTask)�	inventory�lookup�modulecCs"tjddd�|�t||��dS)NzJadd_collection_plugins method, use ansible.plugins.list functions instead.�2.17��version)�display�
deprecated�updater)�plugin_list�plugin_type�coll_filter�r1�3/usr/lib/python3.9/site-packages/ansible/cli/doc.py�add_collection_plugins6sr3c
CsZzt�t|��WnBtyT}z*t�t���tdt|���WYd}~n
d}~00dS)NzXWe could not convert all the documentation into JSON as there was a conversion issue: %s)r+r�	TypeError�vvv�	traceback�
format_excrr)�text�er1r1r2�jdump;s
r:c@sreZdZdZdd�ejD�dd�ejD�Zddd�Zddd	�Zdd
d�Z	dd
�Z
dd�Zddd�Zddd�Z
dS)�	RoleMixinz�A mixin containing all methods relevant to role argument specification functionality.

    Note: The methods for actual display of role data are not present here.
    cCsg|]}d|�qS)�argument_specsr1��.0r9r1r1r2�
<listcomp>K�zRoleMixin.<listcomp>cCsg|]}d|�qS)�mainr1r=r1r1r2r?Kr@Nc
Cs|rtj�|d|d�}n |r,tj�|d�}ntd|��d}|jD]&}tj�||�}tj�|�rB|}qjqB|durviSzXt|d��:}t|��|d�}	|	dur�i}	|	�	di�Wd�WS1s�0YWnBt
tf�y}
z$td|t
|
�f|
d	��WYd}
~
n
d}
~
00dS)
aCLoad the role argument spec data from the source file.

        :param str role_name: The name of the role for which we want the argspec data.
        :param str collection_path: Path to the collection containing the role. This
            will be None for standard roles.
        :param str role_path: Path to the standard role. This will be None for
            collection roles.

        We support two files containing the role arg spec data: either meta/main.yml
        or meta/argument_spec.yml. The argument_spec.yml file will take precedence
        over the meta/main.yml file, if it exists. Data is NOT combined between the
        two files.

        :returns: A dict of all data underneath the ``argument_specs`` top-level YAML
            key in the argspec data file. Empty dict is returned if there is no data.
        �roles�metaz7A path is required to load argument specs for role '%s'N�r)�	file_namer<z8An error occurred while trying to read the file '%s': %s�Zorig_exc)�os�path�joinr�ROLE_ARGSPEC_FILES�exists�openr�read�get�IOError�OSErrorr
r)�selfZ	role_name�collection_path�	role_path�	meta_pathrH�specfile�	full_path�f�datar9r1r1r2�
_load_argspecMs*
0zRoleMixin._load_argspecc
Cs�t�}t�}|D]�}tj�|�s"qt�|�D]n}tj�||�}|jD]T}tj�|d|�}	tj�|	�rD|dust||vr�||vr�|�||f�|�|�q,qDq,q|S)a�Find all non-collection roles that have an argument spec file.

        Note that argument specs do not actually need to exist within the spec file.

        :param role_paths: A tuple of one or more role paths. When a role with the same name
            is found in multiple paths, only the first-found role is returned.
        :param name_filters: A tuple of one or more role names used to filter the results.

        :returns: A set of tuples consisting of: role name, full role path
        rCN)	�setrGrH�isdir�listdirrIrJrK�add)
rQZ
role_paths�name_filters�foundZfound_namesrH�entryrSrUrVr1r1r2�_find_all_normal_roles{s 


z RoleMixin._find_all_normal_rolesc	Cst�}t|d�}|D�]�}t|dd�}t|�}tj�|d�}tj�|�rt�|�D]�}	|j	D]�}
tj�||	d|
�}tj�|�r\|dur�|�
|	||f�np|D]j}t|�d��dkr�|�d�\}
}}d�|
|g�|kr�|	|kr�|�
|	||f�q�||	kr�|�
|	||f�q�qRq\qRq|S)	a�Find all collection roles with an argument spec file.

        Note that argument specs do not actually need to exist within the spec file.

        :param name_filters: A tuple of one or more role names used to filter the results. These
            might be fully qualified with the collection name (e.g., community.general.roleA)
            or not (e.g., roleA).

        :param collection_filter: A string containing the FQCN of a collection which will be
            used to limit results. This filter will take precedence over the name_filters.

        :returns: A set of tuples consisting of: role name, collection name, collection path
        )r0�surrogate_or_strict��errorsrBrCN�.�)
rZr
rrrGrHrIrKr\rJr]�len�split)rQr^�collection_filterr_Z
b_colldirs�b_pathrHZcollnameZ	roles_dirr`rUrV�fqcn�ns�colr#r1r1r2�_find_all_collection_roles�s,



z$RoleMixin._find_all_collection_rolescCsb|rd�||g�}n|}i}||d<i|d<|��D]$}||pBi}|�dd�|d|<q4||fS)a�Build a summary dict for a role.

        Returns a simplified role arg spec containing only the role entry points and their
        short descriptions, and the role collection name (if applicable).

        :param role: The simple role name.
        :param collection: The collection containing the role (None or empty string if N/A).
        :param argspec: The complete role argspec data dict.

        :returns: A tuple with the FQCN role name and a summary dict.
        re�
collection�entry_points�short_description�)rI�keysrN)rQr#ro�argspecrk�summary�ep�
entry_specr1r1r2�_build_summary�szRoleMixin._build_summaryc
Cs�|rd�||g�}n|}i}||d<||d<i|d<|��D],}|dusP||kr<||pZi}	|	|d|<q<t|d���dkr�d}||fS)NrerHrorpr)rIrsrg)
rQr#rHrort�entry_pointrk�docrvrwr1r1r2�
_build_doc�szRoleMixin._build_docTcCs:|��}|��}|s |�|�}ng}|j|d�}i}|D]t\}}z,|j||d�}	|�|d|	�\}
}|||
<Wq8ty�}z&|r��ddt|�i||<WYd}~q8d}~00q8|D]�\}}
}z,|j||d�}	|�||
|	�\}
}|||
<Wq�t�y2}z0|�r�ddt|�i|d|
|f<WYd}~q�d}~00q�|S)	a�Return a dict describing the listing of all roles with arg specs.

        :param role_paths: A tuple of one or more role paths.

        :returns: A dict indexed by role name, with 'collection' and 'entry_points' keys per role.

        Example return:

            results = {
               'roleA': {
                  'collection': '',
                  'entry_points': {
                     'main': 'Short description for main'
                  }
               },
               'a.b.c.roleB': {
                  'collection': 'a.b.c',
                  'entry_points': {
                     'main': 'Short description for main',
                     'alternate': 'Short description for alternate entry point'
                  }
               'x.y.z.roleB': {
                  'collection': 'x.y.z',
                  'entry_points': {
                     'main': 'Short description for main',
                  }
               },
            }
        )ri�rSrr�errorz*Error while loading role argument spec: %sN�rR�%s.%s)�_get_roles_path�_get_collection_filterrarnrYrx�	Exceptionr)rQ�fail_on_errors�
roles_pathrirB�	collroles�resultr#rSrtrkrur9rorRr1r1r2�_create_role_list�s8� �(zRoleMixin._create_role_listcCs.|��}|j||d�}|j|d�}i}|D]v\}}	z4|j||	d�}
|�||	d|
|�\}}|rd|||<Wq*ty�}
z ddt|
�i||<WYd}
~
q*d}
~
00q*|D]�\}}}z4|j||d�}
|�||||
|�\}}|r�|||<Wq�t�y&}
z(ddt|
�i|d||f<WYd}
~
q�d}
~
00q�|S)	a�
        :param role_names: A tuple of one or more role names.
        :param role_paths: A tuple of one or more role paths.
        :param entry_point: A role entry point name for filtering.
        :param fail_on_errors: When set to False, include errors in the JSON output instead of raising errors

        :returns: A dict indexed by role name, with 'collection', 'entry_points', and 'path' keys per role.
        )r^r|rrr}zError while processing role: %sNr~r)r�rarnrYr{r�r)rQZ
role_namesryr�r�rBr�r�r#rSrtrkrzr9rorRr1r1r2�_create_role_doc5s.	� �(zRoleMixin._create_role_doc)NN)N)NN)T)NT)�__name__�
__module__�__qualname__�__doc__�CZYAML_FILENAME_EXTENSIONSrJrYrarnrxr{r�r�r1r1r1r2r;Cs 
.
"
*
Br;cs�eZdZdZdZdZe�d�Ze�d�Z	e�d�Z
e�d�Ze�d�Ze�d	�Z
e�d
�Ze�d�Ze�d�Ze�d
�Ze�d�Ze�d�Z�fdd�ZedPdd��Zedd��Z�fdd�Z�fdd�Zdd�Zdd�Zdd �Zed!d"��Zed#d$��Zd%d&�Z d'd(�Z!dQd+d,�Z"d-d.�Z#ed/d0��Z$�fd1d2�Z%ed3d4��Z&ed5d6��Z'ed7d8��Z(ed9d:��Z)ed;d<��Z*ed=d>��Z+d?d@�Z,edAdB��Z-edRdCdD��Z.edEdF��Z/edSdGdH��Z0edTdJdK��Z1dLdM�Z2edUdNdO��Z3�Z4S)V�DocCLIa displays information on modules installed in Ansible libraries.
        It displays a terse listing of plugins and their short descriptions,
        provides a printout of their DOCUMENTATION strings,
        and it can create a short "snippet" which can be pasted into a playbook.  zansible-doc)	r'Zdocuri�
version_added�version_added_collectionrqZnow_date�
plainexamples�
returndocsroz\bI\(([^)]+)\)z\bB\(([^)]+)\)z\bM\(([^)]+)\)z\bL\(([^)]+), *([^)]+)\)z\bU\(([^)]+)\)z\bR\(([^)]+), *([^)]+)\)z\bC\(([^)]+)\)z\bHORIZONTALLINE\bz	.. note::z.. seealso::z:\w+?:`z	.. \w+?::cstt|��|�t�|_dS�N)�superr��__init__rZr.)rQ�args��	__class__r1r2r�yszDocCLI.__init__NcCs tjddd�t|||g���S)Nz^find_plugins method as it is incomplete/incorrect. use ansible.plugins.list functions instead.r(r))r+r,rrs)�clsrHZinternalr/r0r1r1r2�find_plugins~szDocCLI.find_pluginscCs�|j�d|�}|j�d|�}|j�d|�}|j�d|�}|j�d|�}|j�d|�}|j�d|�}|j�d�	d�|�}|j
�d|�}|j�d	|�}|j�d
|�}|j
�d|�}|S)Nz`\1'z*\1*z[\1]z\1z\1 <\2>z
{0}
z
-------------z	See also:zNote:�`rr)�_ITALIC�sub�_BOLD�_MODULE�_URL�_LINK�_REF�_CONST�_RULER�format�_RST_SEEALSO�	_RST_NOTE�
_RST_ROLES�_RST_DIRECTIVES)r�r8�tr1r1r2�tty_ify�szDocCLI.tty_ifyc
s@d}tt|�jddd�t�|j�t�|j�|jjddddd	�|jjd
ddd
dd�t	�t	d�|jjddddddd�|jjdddt
jtjdd�tj
dd�|j��}|jdd d!d"d#�|jd$d%ddd&d'd(�t�d�|jd)d*ddd+d,|d�|jd-d.ddd/d0|d�|jd1ddd2d3d�|jjd4ddd5d6d�dS)7Nz[A supplied argument will be used for filtering, can be a namespace or full collection name.zplugin documentation toolzWSee man pages for Ansible CLI options or website for tutorials https://docs.ansible.com)�desc�epilogr��*ZPlugin�plugin)�nargs�help�metavarz-tz--type�storer'�typezQChoose which plugin type (defaults to "module"). Available plugin types are : {0})�action�default�destr��choicesz-jz--json�
store_trueF�json_formatzChange output into json format.)r�r�r�r�z-rz--roles-pathr�T)�pathsepz0The path to the directory containing your roles.)r�r�r�r�r�z-ez
--entry-pointryz#Select the entry point for role(s).)r�r�z-sz	--snippet�show_snippetz0Show playbook snippet for these plugin types: %s�, z-Fz--list_files�
list_fileszOShow plugin names and their source files without summaries (implies --list). %sz-lz--list�list_dirzList available plugins. %sz--metadata-dump�dumpzT**For internal use only** Dump json metadata for all entries, ignores other options.z--no-fail-on-errors�no_fail_on_errorsz}**For internal use only** Only used for --metadata-dump. Do not fail on errors. Report the error message in the JSON instead.)r�r��init_parser�opt_helpZadd_module_options�parserZadd_basedir_options�add_argumentr��TARGET_OPTIONSr�ZDEFAULT_ROLES_PATHZunfrack_pathZPrependListAction�add_mutually_exclusive_grouprI�SNIPPETS)rQr0Z	exclusiver�r1r2r��sR
����
�

������zDocCLI.init_parsercstt|��|�}|jt_|Sr�)r�r��post_process_args�	verbosityr+)rQ�optionsr�r1r2r��szDocCLI.post_process_argsc
	Cs�tdd�|��D��}tj|d}g}g}tjdr�t|���D]�}t||�}|�d�}|d�	d�r�|dd	kr�|d
dvr�|dd
d�|d<d�
|�}|�d|||t|�|f�qB|�d|||t|�|f�qBn�t|���D]�}t
�||�}	t|	�|k�r|	d|�d
}	|�d�}|d�	d��rp|dd
d�|d<d�
|�}|�d|||t|	�|	f�q�|�d|||t|	�|	f�q�t|�dk�r�|�d�|�|�t
�d�
|��dS)Ncss|]}t|�VqdSr��rg�r>�xr1r1r2�	<genexpr>�r@z-DocCLI.display_plugin_list.<locals>.<genexpr>�r�re����_r�ansible�)Zbuiltin�legacyz%-*s %-*.*s�...z
DEPRECATED:�
)�maxrsr+�columnsr�CLIARGS�sortedrrh�
startswithrI�appendrgr�r��extend�pager)
rQ�resultsZdisplace�	linelimitr8r,r��filenameZpbreakr�r1r1r2�display_plugin_list�s6

&
 



zDocCLI.display_plugin_listc
Cs�t|���}t�}|D]$}||d��D]}|�|�q*qd}d}|rZtdd�|D��}|rptdd�|D��}tj||d}g}	t|�D]R}||d��D]<\}}
t	|
�|kr�|
d|�d}
|	�
d	|||||
f�q�q�t�d
�
|	��dS)z�Display all roles we can find with a valid argument specification.

        Output is: fqcn role name, entry point, short description
        rprcss|]}t|�VqdSr�r�r�r1r1r2r�r@z2DocCLI._display_available_roles.<locals>.<genexpr>css|]}t|�VqdSr�r�r�r1r1r2r�r@r�Nr�z%-*s %-*s %sr�)�listrsrZr]r�r+r�r��itemsrgr�r�r�rI)rQZ	list_jsonrBZentry_point_namesr#ryZmax_role_lenZ
max_ep_lenr�r8r�r1r1r2�_display_available_roless,
�zDocCLI._display_available_rolescCsBt|���}g}|D]}||�|||�7}qt�d�|��dS)Nr�)r�rs�get_role_man_textr�r�rI)rQ�	role_jsonrBr8r#r1r1r2�_display_role_doc!s
zDocCLI._display_role_doccCstt�dd��S)Nr�zkeyword_desc.yml)r�pkgutil�get_datar1r1r1r2�_list_keywords*szDocCLI._list_keywordsc
Cs�i}t��}|D�]�}|�d�r&d}n|dkr4d}n|}�z*d||i}g|d<tD]�}|tvr�d|��}t�|�}t||d�t|<|t|j	vrT|d�
|�d|vrTt|j	�|�}	t|	d	�r�i}t�t|	d
d�|d<|�
d�s�|d
vr�d|d<nt|	d��rd|d<nd|d<dD]}
t|	|
�||
<�qqTt|���D]}||du�r>||=�q>|||<Wqttf�y�}z<t�d|t|�f�tjdk�r�t�t���WYd}~qd}~00q|S)NZwith_Zloop�asyncZ	async_val�descriptionZ
applies_tozansible.playbook.%sr�ZprivateZisa�stringZwhen)ZuntilZimplicit�templateZstaticZexplicit)�alias�priorityz+Skipping Invalid keyword '%s' specified: %srf)r�r�r��
PB_OBJECTS�	PB_LOADED�lowerr�
import_module�getattrZfattributesr�rN�KeyError�endswithr�rs�AttributeErrorr+�warningrr��verboser6r7)
rsrX�descs�keyr$ZkdataZpobjZ	obj_classZloaded_class�faZvisible�kr9r1r1r2�_get_keywords_docs.sP






&zDocCLI._get_keywords_docscCs\d}ttjd�dkrXtjdd}t�|�s>td�|���nttjd�dkrXtd��|S)Nr�r�rzGInvalid collection name (must be of the form namespace.collection): {0}z-Only a single collection filter is supported.)rgrr�rZis_valid_collection_namerr�r)rQr0r1r1r2r�rs
zDocCLI._get_collection_filtercs�i}i�_t�|�}���}�j�t||��|dkrB��|�}n>|dkrd�fdd��j��D�}ndd��j��D�}t��_	|S)N�dir�filescsi|]}|�j|d�qS)r)�plugins�r>r�rQr1r2�
<dictcomp>�r@z(DocCLI._list_plugins.<locals>.<dictcomp>cSsi|]
}|i�qSr1r1rr1r1r2r�r@)
rr��_prep_loaderr�r-r�_get_plugin_list_descriptionsrsrZr.)rQr/�contentr��loaderr0r1rr2�
_list_plugins~s
zDocCLI._list_pluginsFTcCs�t�|�}i}|D�]z}i}z&t|||ttjddk�\}}	}
}Wn�ty�}z&t�t	|��WYd}~qWYd}~n�d}~0t
y�}zh|s�ddt	|�i||<WYd}~qt�t�
��d||t	|�f}
|r�t�|
�nt|
��WYd}~n
d}~00|�s|sddi||<qt�||||	|
|�}|�s�zt|�WnFt
�y�}z,ddt	|�i||<WYd}~qWYd}~n
d}~00|||<q|S)Nr�rr}z:Missing documentation or could not parse documentation: %szC%s %s missing documentation (or could not parse documentation): %s
zNo valid documentation foundz*Cannot serialize documentation as JSON: %s)r�rr rrr�rr+r�rr�r5r6r7r�_combine_plugin_docr)rQr/�names�fail_okr�rZplugin_docsr�rzr�r��metadatar9�msg�docsr1r1r2�_get_plugins_docs�s>

& "
zDocCLI._get_plugins_docscCsVtjd}tjddurRtj�tjdd�}tj�|�rB|f|}|tjdf}|S)ao
         Add any 'roles' subdir in playbook dir to the roles search path.
         And as a last resort, add the playbook dir itself. Order being:
           - 'roles' subdir of playbook dir
           - DEFAULT_ROLES_PATH (default in cliargs)
           - playbook dir (basedir)
         NOTE: This matches logic in RoleDefinition._load_role_path() method.
        r��basedirNrB)rr�rGrHrIr[)rQr�Zsubdirr1r1r2r��s	

zDocCLI._get_roles_pathcCsbttd|�}tjddur0|jtjddd�tjdrXtjdD]}|rD|�|�qDd|_|S)z' return a plugint type specific loader �	%s_loaderrNT)Zwith_subdirZmodule_path)r��
plugin_loaderrr�Z
add_directoryZ_paths)r/rrHr1r1r2r�s
zDocCLI._prep_loadercs�tt|���tjd}tjd��}tjdp8tjd}tjdpLtjd}tjdr^d}ntjdrnd}nd}i}|r�|t_|tvr�t	d	|��tjd�rTt}i|d
<|D]�}t
tjd�}	|dkr�|j|	d
�}
|j|
�
�tjd|	d
�|d
|<q�|dk�r&t��}t�|�
��|d
|<q�|�|d�}|j|||dv|	d�|d
|<q�n�|�r�|dk�rnt��}n |dk�r�|��}n|�||�}nnttjd�dk�r�t	d��|dk�r�t�tjd�}n6|dk�r�|�tjdtjd�}n|�|tjd�}|�rt|��n�g}
|tjv�r.|�r8|�r8|�|�n�tjd�r�|tv�r`tdd�t���|��D]h\}}zt�|||d�}Wn<t�y�}z"t�d�|t |���WYd}~nd}~00|
�!|��qhnX|��D]N\}}t�"|||d|d|d|d�}|�r|
�!|�nt�d|��q�nP|dk�rhtjd�rV|�rV|�#|�n|�r~|�$|�n|�r~t�%t�&|��}
|
�r�t�'d�|
��dS)Nrr�r�r�r�r�rrz)Unknown or undocumentable plugin type: %s�allr�r#)r�ryr$)�test�filter)rr�r�rzEMissing name(s), incorrect options passed for detailed documentation.r�z>Snippets are only available for the following plugin types: %sr�rzz,Unable to construct a snippet for '{0}': {1}�examples�returnrz.No valid documentation was retrieved from '%s'rr)(r�r��runrr�r�rZplaybook_pathsr�r�boolr�r�rsr�rrrrgr:r��DOCUMENTABLE_PLUGINSr�r�rrIr��format_snippet�
ValueErrorr+r�r�rr��format_plugin_docr�r�r��
_dump_yamlr�)rQrr/Zdo_jsonZlistingr
rZptypesZptypeZno_failrBrZplugin_namesr8r�Zdoc_dataZtextretr9r�r1r2r�s�


$
"






���
z
DocCLI.runcCs>ttd|�}|��}i}|D]}|�t|��qt|���S)Nr)r�rZ_get_paths_with_contextr-rr�rs)r/r�pathsrZpath_contextr1r1r2�get_all_plugins_of_typeMszDocCLI.get_all_plugins_of_typecCs�ttd|�}|j|dddd�}|js6td�||���|j}|j}z(t|t	t
jddk||d�\}}}}Wn2ty�t
�t���td	|||f��Yn0|dur�dSt|t�|||j�|�d
d�|�dd�d
�S)Nrz.pyT)�mod_typeZignore_deprecatedZ
check_aliasesz$unable to load {0} plugin named {1} r�r)r��collection_namer/zM%s %s at %s has a documentation formatting error or is missing documentation.rqZUNKNOWNr�)�name�	namespacer�r�)r�rZfind_plugin_with_contextZresolvedrr�Zplugin_resolved_pathZplugin_resolved_collectionr!rrr�r�r+r5r6r7�dictr��namespace_from_plugin_filepath�package_pathrN)r/�plugin_namerr�r�r&rz�__r1r1r2�get_plugin_metadataVs*�

�zDocCLI.get_plugin_metadatacCs`|�d�s|d7}|�|d�}tj�|�d}|�|d�d�d�}|�dd�}|dkr\d}|S)N�/rrrr�z/_re)r��replacerGrH�splitext�rsplit�strip)�filepathr,rZrel_pathZextension_freeZnamespace_onlyZclean_nsr1r1r2r*rs
z%DocCLI.namespace_from_plugin_filepathcCs0|dkr"|tvrd|d<nd|d<||||d�S)Nr'T�
has_actionF)rzrrr)r)r�r/rzr�r�rr1r1r2r
s

zDocCLI._combine_plugin_doccCsb|dkr(|�di��d�r(td�|���g}|dkr>t|�}nd|vrNt|�}|�d�d�|�S)z9 return heavily commented plugin use to insert into play r%r�r�z�The {0} inventory plugin does not take YAML type config source that can be used with the "auto" plugin so a snippet cannot be created.r&rrr�)rNr r��_do_lookup_snippet�_do_yaml_snippetr�rI)r�r/rzr8r1r1r2r�s�

zDocCLI.format_snippetc	
Cs�|d}||d<||d<||d<zt�|||�}WnJty|}z2t�t���td|t|�f|d��WYd}~n
d}~00|S)Nror�r�rz5Unable to retrieve documentation from '%s' due to: %srF)	r��get_man_textr�r+r5r6r7rr)	r�r/rzr�r�rr&r8r9r1r1r2r!�s	.zDocCLI.format_plugin_docc
Cs0i}|j��D�]}d}tt|j|d��}d}zt|�}Wn(tyf}z|}WYd}~n
d}~00|dur�|�d�d}|�||j�}	t	j
D]L}
|	�|
�}z|��r�t|�}Wq�ty�}z|}WYd}~q�d}~00q�|r�t
�d||f�q|�rt|t��sd}n|�dd���}|||<q|S)Nrrer�z+%s has a documentation formatting error: %sZUNDOCUMENTEDrqzINVALID SHORT DESCRIPTION)rrsrrrr�rh�	with_name�suffixr�ZDOC_EXTENSIONS�with_suffixrKr+r��
isinstancer)rNr3)
rQrr�r�rzr�Zdocerrorr9�baseZbasefile�	extensionZdocfiler�r1r1r2r	�s6


z$DocCLI._get_plugin_list_descriptionscCs@g}|jdd�D]"}t|dd�}||vr|�|�qtj�|�S)z; Returns a string suitable for printing of the search path F)�subdirsrbrc)Z
_get_pathsrr�rGr�rI)�finder�ret�ir1r1r2�print_paths�szDocCLI.print_pathscCst||dtd��d�S)Nz'')�default_flow_styleZ
default_styleZDumperr�)rr�rstrip)�struct�
flow_styler1r1r2r"�szDocCLI._dump_yamlcs$t�d��fdd�|�d�D���S)Nr�csg|]}�|�qSr1r1)r>�line��indentr1r2r?�r@z(DocCLI._indent_lines.<locals>.<listcomp>)r�r�rIrh)r8rJr1rIr2�
_indent_lines�szDocCLI._indent_linescCs2|dkrd}|dkrdS|r(d||f}d|fS)Nzansible.builtinzansible-coreZ
historicalz%s of %sz
version %sr1)r�r�r1r1r2�_format_version_added�szDocCLI._format_version_addedrrcCsxt|�D�]h}t||�}|�dd�}t|t�s<td|��|rFd}	nd}	|�d||	|f�d|vrntd��t|d�r�t|dd	�D]F\}
}t|t	�s�td
||
t
|�f��|�tjt
�|�|||d��q�nHt|dt	�s�td|t
|d�f��|�tjt
�|d�|||d��|d=g}d
D]$}
|
|v�r(|�|
|�|
�f��q(|�sl|�sld|v�rld|d<i}dD]`}||v�rt||�rtdd�|�|�D�||<t
jD]&}||D]}||v�r�||=�q��q��qtd|v�rJ|d�rJg|d<|dD]H}d|v�r2|d�|dd|d�dd�d��n|d�|��q�|d=|�rl|�t
�t
�d|i�|��|�dd�}|�dd�}t|�D]n}|�d��r��q�t||��r�|�t
�d|t
j||dd�f|��n |�t
�t
�|||i�|���q�|�r|�d|t
�||�f�|D]B\}
}|�d�|�d ||
��f�t
�||||d!||��q |s|�d�qdS)"N�requiredFz8Incorrect value for 'Required', a boolean is needed.: %s�=�-z%s%s %sr�zCAll (sub-)options and return values must have a 'description' fieldr�z8Expected string in description of %s at index %s, got %s��initial_indent�subsequent_indentz,Expected string in description of %s, got %s)r��
suboptions�contains�specr�)�envZiniZyaml�varsr$cSsg|]}t|��qSr1)r))r>�itemr1r1r2r?*r@z%DocCLI.add_fields.<locals>.<listcomp>�cli�optionr'z--%sr�)r'rZZset_viar�r��%s: %sT)rGz%sadded in: %s
rrz%s%s:
z    )r�r)�popr<rrr�r�	enumeraterr��textwrap�fillr�r��IGNOREr0rKr"r�rL�upper�
add_fields)r8�fields�limit�
opt_indent�
return_valuesZbase_indent�o�optrMZ
opt_leadinZ	entry_idxr`rSZsubkeyZconfZconfig�ignorerXrYr�r�rZsubdatar1r1r2rb�sv

""



**$
zDocCLI.add_fieldscCs"g}d}tjd}ttjt|�d�}|�d|��|�d�f�|dD�]�}|d|}|�d�r�|�d||�d�f�n|�d	|�|�d
�r�t|d
t�r�d�	|d
�}	n|d
}	|�dt
jt�
|	�|||d
��|�d��r|�d�t�||�d�||�|�d�|�d��rT|�d�|�t�t�|�d��|��|�d�dD]�}
|
|v�rj�qXt||
t��r�|�d|
��t
jt�
||
�|t|
�d|d�f�nZt||
ttf��r�|�d|
��d�	||
�f�n$|�t�t�|
��||
i�d��|�d��qXqJ|S)a�Generate text for the supplied role suitable for display.

        This is similar to get_man_text(), but roles are different enough that we have
        a separate method for formatting their display.

        :param role: The role name.
        :param role_json: The JSON for the given role as returned from _create_role_doc().

        :returns: A array of text suitable for displaying to screen.
        �        皙�����?�F�
> %s    (%s)
rHrprqzENTRY POINT: %s - %s
zENTRY POINT: %s
r�� �%s
rPr��OPTIONS (= is mandatory):
rr�
attributes�ATTRIBUTES:
)Zauthorr[��rRr�)r+r�r��intr�rarNr<r�rIr^r_r�r�rbr\rKr"rrg�tuple)rQr#r�r8re�padrdryrzr�rr1r1r2r�VsL


�





�"$zDocCLI.get_role_man_textc
Csnt|�}tjtjdft_d}g}tjd}ttjt|�d�}|�	tjd|�	d��pf|�	d�pf|}|rxd||f}|�
d|��|�d	�f�t
|d
t�r�d�|�d
��}n
|�d
�}|�
dtjt�|�|||d
��d|v�r|�d�}	|�dd�}
|�
dt�|	|
��|�	dd��r�|�
d�t
|dt��r�d|dv�rb|�
d|�d��nDd|dv�r�d|dv�r�|dd|dd<|�
d|�d��n|�
d|�d��|�
d�|�dd��r�|�
dd�|�	dd��r|�
d�t�||�d�||�|�
d �|�	d!d��rZ|�
d"�|�
t�t�|�d!��|��|�
d �|�	d#d��r�|�
d$�|d#D]4}|�
tjt�|�|d%|dd&�d'|d
���qz|�
d �|�
d �|d#=|�	d(d��rb|�
d)�|d(D�]Z}d*|v�r�|�
tjt�d+|d*�|d%|dd&�d'|d
��|�	d
�}
|
du�r`|d*�d,��r`d-|d*}
|
du�r�|�
tjt�|
�|d%|d.|d.d
��|d*�d,��rDd/|d*�d0d1d2�}|�
tjt�t|��|d%|d.|d
���q�d|v�r�d3|v�r�d
|v�r�|�
tjt�|d�|d%|dd&�d'|d
��|�
tjt�|d
�|d%|d.|d.d
��|�
tjt�|d3�|d%|d.|d.d
��n�d4|v�r�d
|v�r�|�
tjt�d5|d4�|d%|dd&�d'|d
��|�
tjt�|d
�|d%|d.|d.d
��|�
tjt�td6|d4��|d%|d.|d.d
���q�|�
d �|�
d �|d(=|�	d7d��r�d8�|�d7��}|�
d9tjt�|�|d:d;|d
��t|�D]�}|tjv�s�||�s̐q�t
||t��r|�
d<|��tjt�||�|t|�d2|d=�f�nZt
||ttf��rL|�
d<|��d8�||�f�n$|�
t�t�|��||i�d ��||=|�
d ��q�|�	d>d��r2|�
d?�|�
d �t
|d>t��r�|�
|�d>����nRz|�
t|�d>�d2dd@��Wn2t �y}zt!dA|dB��WYd}~n
d}~00|�
d �|�
d �|�	dCd��rd|�
dD�tj||�dC�||dEdF�d�|�S)GNr�rjrkrlr'r/rrmr�r�rnrorPr�r�z
ADDED IN: %s
r,Fz
DEPRECATED: 
Zremoved_at_datezg	Reason: %(why)s
	Will be removed in a release after %(removed_at_date)s
	Alternatives: %(alternative)sr*Z
removed_inz[	Reason: %(why)s
	Will be removed in: Ansible %(removed_in)s
	Alternatives: %(alternative)sz%sr�r5z
  * note: %s
z.This module has a corresponding action plugin.r�rprrrqrrZnoteszNOTES:����z* Zseealsoz	SEE ALSO:r'z	Module %szansible.builtin.z,The official documentation on the %s module.z   zcollections/%s_module.htmlrer/rs�link�refzAnsible documentation [%s]z/#stq=%s&stp=1Zrequirementsr�zREQUIREMENTS:%s
�z  r[rtr�z	EXAMPLES:)rJrDz Unable to parse examples sectionrFr�zRETURN VALUES:T)rf)"r)r�r`rr�r+r�r�rurNr�rar\r<r�rIr^r_r�rLrbrKr"r�r0r"r�rrgrvr3rr�r
)rzr&r/rer8rwrdr,r�r�r�ZnoterXr�Zrelative_urlZreqrr9r1r1r2r8�s�
&
�



�





�



�

�����
���

&:"$

"


zDocCLI.get_man_text)N)FT)F)N)Frr)rrrr)5r�r�r�r�r'r`�re�compiler�r�r�r�r�r�r�r�r�r�r�r�r��classmethodr�r�r�r�r�r�r��staticmethodr�rr�rrr�rrr$r.r*r
rr!r	rCr"rKrLrbr�r8�
__classcell__r1r1r�r2r�]s|












4-!	

C
+
l





'


X=r�cCsfg}t�|d�}|�d�}|r>|�d|�|�d|�n|�d|�d|�d���d}d	�|d
�}tj|}t|d���D]�}|d|}t	|dt
�r�t�|d�}	nt�d
�|d��}	|�dd�}
t	|
t�s�t
d|
��d|}|�r&|
�rd|	}	|�d|tj|	||d�f�q�|
�r2d}n|�dd�}|�d||tj|	||dd�f�q�|S)Nrqr'z
- name: %sz  %s:z# %s:r�r'�z# rsr�r�rnrMF�7Incorrect value for 'Required', a boolean is needed: %sz%s:z
(required) %sz      %-20s   # %srtz
(required)r��Nonez%s %-9s # %srf)rRZ	max_lines)r�r�rNr��rjustr+r�r�rsr<rrIrr r^r_)rzr8Zmdescr'rwZsubdentrdrgrhr�rMr�r1r1r2r7s8


 $r7c
Csg}d|�d|�d��}g}t|d���D]�}|d|}|�d||�dd�|�dd	�f�|d
vrx|d|7}q.|�dd
�}t|t�s�td|��|r�d}n|�dd�}|�d�dvr�|d||f7}q.|d||f7}q.|d7}|�r|�|�|�d	�|�|�|S)Nz
lookup('%s', r�r'r�z# %s(%s): %sr�r�r�rr)Z_termsZ_rawZ_listz< %s >rMFr�z
<REQUIRED>r�r�)r��strz	, %s='%s'z, %s=%s�))rNr�rsr�r<rr r�)rzr8ZsnippetZcommentrgrhrMr�r1r1r2r6Ls0$



r6cCst�|�dSr�)r�Zcli_executor)r�r1r1r2rArsrA�__main__)N)N)SZ
__future__rrrr�Z
__metaclass__Zansible.clirr�rGZos.pathr}r^r6Zansible.plugins.loaderrrr�pathlibrr�rr�rZansible.cli.argumentsr	r�Zansible.collections.listr
Zansible.errorsrrr
rZansible.module_utils._textrrZ'ansible.module_utils.common.collectionsrZ ansible.module_utils.common.jsonrZ ansible.module_utils.common.yamlrZansible.module_utils.compatrZansible.module_utils.sixrZansible.parsing.plugin_docsrZansible.parsing.utils.yamlrZansible.parsing.yaml.dumperrZansible.plugins.listrrrZansible.utils.collection_loaderrrZ2ansible.utils.collection_loader._collection_finderrZansible.utils.displayrZansible.utils.plugin_docsr r!r"r+rr�r�r�r�r3r:�objectr;r�r7r6rAr�r1r1r1r2�<module>sj

I-&