HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/baredoc.cpython-310.pyc
o

�N�gP,�@s�dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZe�e
�Zdedefdd�Zdefd	d
�Zdedefdd
�Zd!dd�Zdededefdd�Zd"defdd�Zd#dd�Zd#dd�Zdd�Zdd �ZdS)$z�
Baredoc walks the installed module and state directories and generates
dictionaries and lists of the function names and their arguments.

.. versionadded:: 3001

�N)�ArgumentValueError)�OrderedDict�filename�returnc	Csbtj�|��d�d}dd�|jD�}|D]}z|jdjdkr$|jj}Wqt	y.Yqw|S)zT
    Returns the value of __virtual__ if found.
    Otherwise, returns filename
    �.rcS�g|]
}t|tj�r|�qS���
isinstance�astZAssign��.0�noderr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/baredoc.py�
<listcomp>�z$_get_module_name.<locals>.<listcomp>Z__virtualname__)
�os�path�basename�split�body�targets�id�value�s�AttributeError)�treer�module_name�assignments�assignrrr�_get_module_names��r c	Csxi}dd�|jD�}|D]-}z"|jdjdkr/t�|jj|jj�D]
\}}|�|j	|j	i�q!Wqt
y9Yqw|S)z<
    Get __func_alias__ dict for mapping function names
    cSrrr	rrrrr+rz%_get_func_aliases.<locals>.<listcomp>rZ__func_alias__)rrr�	itertools�zip_longestr�keys�values�updaterr)r�fun_aliasesrr�keyrrrr�_get_func_aliases&s���r(�functionc	Csg}|jj}|r|D]}|�|j�q
g}|jj}|rF|D](}t|tj�r,|�|j�qt|tj�r9|�|j	�qt|tj
�rE|�|j�qtt
�t|�t|���}ttt|�����}z	|jjj|d<Wn	tynYnwz
|jjj|d<W|Sty�Y|Sw)z>
    Given a function def, returns arguments and defaults
    �args�kwargs)r*�append�arg�defaultsr
rZNameConstantrZStrrZNum�nrr!r"�reversed�list�items�varargr�kwarg)	r)�arg_stringsZlist_of_argumentsr-Zarg_default_stringsZlist_arg_defaultsZarg_defaultZbackwards_argsZordered_argsrrr�	_get_args8s@�����r6c
Csi}tjjj|ddd��t}t�|���}t||�}|rd|vr&t�|�||<t	|�}dd�|j
D�}|D]D}t�|�}	|j�d�sx|j}
|rV|�
�D]\}}|j|krU|}
qJ|rod|vro|
|�d�dkrn|	||�d|
��<q4|	||�d|
��<q4Wd	�n1s�wYtjj�|�S)
zM
    Gather module docstrings or module.function doc string if requested
    �r�utf8��encodingrcSrr�r
rZFunctionDefrrrrrprz&_parse_module_docs.<locals>.<listcomp>�_�N)�salt�utils�files�fopenr�parse�readr Z
get_docstringr(r�name�
startswithr2r�docZ	strip_rst)
Zmodule_path�mod_name�ret�cur_filerrr&�	functions�fnZ
doc_string�
function_name�k�vrrr�_parse_module_docsbs4


�����rO�	module_py�return_typecCs�i}tjjj|ddd��`}t�|���}t||�}t|�}dd�|j	D�}g}|D]6}	|	j
�d�s_|	j
}
|rF|��D]\}}|	j
|krE|}
q:t
|	�}
|dkrT|�|
�q)i}|
||
<|�|�q)|||<Wd�|S1sowY|S)	zw
    Parse module files for proper module_name and function name, then gather
    functions and possibly arguments
    r7r8r9cSrrr;rrrrr�rz+_parse_module_functions.<locals>.<listcomp>r<�namesN)r>r?r@rArrBrCr r(rrDrEr2r6r,)rPrQrHrIrrr&rJZ	func_listrKrLrMrNr*Z	fun_entryrrr�_parse_module_functions�s6

�
�

��rSF�statesr*c	Cs@g}g}|dkr!|�tj�tdd��|�tj�tdd��n|dkr=|�tj�tdd��|�tj�tdd��|rqd|vrR|dkrKtd��|�d�d}|D]}tj�||d	�}tj�|�rn|�|�|SqT|St	|�D](}zt�
|�D]}|�d	�r�|d
kr�|�tj�||��q}Wquty�Yquw|S)z�
    Determine if modules/states directories or files are requested

    return_type = names ==  names_only=True
    return_type = args == names_only=Fals
    return_type = docs
    �modulesZextension_modulesZsaltpathrTr�docszFunction name givenrz.pyz__init__.py)
r,rr�joinZ__opts__Z
__grains__rr�existsr0�listdir�endswith�FileNotFoundError)rD�typerQ�dirs�found_files�dirZ	file_pathrPrrr�
_get_files�s>
�����r`cC�Li}|rd}nd}t|d|d�}|D]}|�t||d��qtt|����S)aC
    Walk the Salt install tree for state modules and return a
    dictionary or a list of their functions as well as their arguments.

    :param name: specify a specific module to list. If not specified, all modules will be listed.
    :param names_only: Return only a list of the callable functions instead of a dictionary with arguments

    CLI Example:

    (example truncated for brevity)

    .. code-block:: bash

        salt myminion baredoc.list_states

        myminion:
            ----------
        [...]
          at:
          - present:
              name: null
              timespec: null
              tag: null
              user: null
              job: null
              unique_tag: false
           - absent:
              name: null
              jobid: null
              kwargs: kwargs
           - watch:
              name: null
              timespec: null
              tag: null
              user: null
              job: null
              unique_tag: false
           - mod_watch:
              name: null
              kwargs: kwargs
        [...]
    rRr*rT�r\rQ�rQ�r`r%rSr�sortedr2�rDZ
names_onlyrHrQr^�filerrr�list_states�s+rhcCra)a�
    Walk the Salt install tree for execution modules and return a
    dictionary or a list of their functions as well as their arguments.

    :param name: specify a specific module to list. If not specified, all modules will be listed.
    :param names_only: Return only a list of the callable functions instead of a dictionary with arguments

    CLI Example:

    .. code-block:: bash

        salt myminion baredoc.list_modules

        myminion:
            ----------
        [...]
          at:
        - atq:
            tag: null
        - atrm:
            args: args
        - at:
            args: args
            kwargs: kwargs
        - atc:
            jobid: null
        - jobcheck:
            kwargs: kwargs
        [...]
    rRr*rUrbrcrdrfrrr�list_modulessricG�d}i}|r$|D]}t|d|d�d}|�t||��qtt|����Sg}|�td|d��|D]	}|�t|��q1tt|����S)a
    Return the docstrings for all state modules. Optionally, specify a state module or a
    function to narrow the selection.

    :param name: specify a specific module to list.

    CLI Example:

    .. code-block:: bash

        salt myminion baredoc.state_docs at
    rVrTrbr�r`r%rOrrer2�extend�rRrQrHrDrgr^rrr�
state_docs.�
rncGrj)a
    Return the docstrings for all modules. Optionally, specify a module or a
    function to narrow the selection.

    :param name: specify a specific module to list.

    CLI Example:

    .. code-block:: bash

        salt myminion baredoc.module_docs
    rVrUrbrrkrmrrr�module_docsJrorp)N)FrTr*)FF)�__doc__rr!�loggingrZsalt.utils.docr>Zsalt.utils.filesZsalt.exceptionsrZsalt.utils.odictr�	getLogger�__name__�log�strr �dictr(r6rOrSr1r`rhrirnrprrrr�<module>s(

* !
+
6*