
    Vh                     H    d dl mZmZmZ eZd Zd Zd Zd Z	d Z
d Zd
d	Zy)    )absolute_importdivisionprint_functionc            	      N    t        t        ddd      t        dddd            S )zs
    Return a dictionary with connection options.
    The options are commonly used by most of Zabbix modules.
    strFN)typerequireddefaultT)r   r	   r
   no_log)http_login_userhttp_login_password)dict     q/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/zabbix/plugins/module_utils/helpers.pyzabbix_common_argument_specr      s8    
 

 !	
 r   c                     t        | t        t        t        f      r t	        |       d | D              S t        | t
              r& t	        |       d | j                         D              S | S )z
    Removes the None values from the object and returns the object
    Args:
        obj: object to cleanup

    Returns:
       object: cleaned object
    c              3   8   K   | ]  }|t        |        y wNhelper_cleanup_data).0xs     r   	<genexpr>z&helper_cleanup_data.<locals>.<genexpr>)   s     NA,Q/Ns   c              3   V   K   | ]!  \  }}||t        |      t        |      f # y wr   r   )r   kvs      r   r   z&helper_cleanup_data.<locals>.<genexpr>+   s6      U!QAMam .a02Ea2HI Us   '))
isinstancelisttuplesetr   r   items)objs    r   r   r      sg     #eS)*tCyNNNN	C	tCy U%(YY[U U 	U 
r   c                 :   |yt        |       D ]  \  }}t        |t              r%|j                         |j                         k(  r|c S t        |t              sL|D ]:  }t        |t              s|j                         |j                         k(  s6|c c S   y)zConverts string values to integers

    Parameters:
        elements: list of elements to enumerate
        value: string value

    Returns:
        int: converted integer
    N)	enumerater   r   lowerr   )elementsvalueindexelementdeep_elements        r   helper_to_numeric_valuer,   1   s     }#H- !wgs#5;;=(HLgt$ ' !lC0\5G5G5IU[[]5Z L!	!r   c                    t        | t              r't        t        t        | j	                                     S t        | t
        t        t        f      r t        |       t        t        |             S | | S t        |       S )zConverts unicode objects to strings in dictionary

    Parameters:
        data: unicode object

    Returns:
        dict: strings in dictionary
    )
r   r   maphelper_convert_unicode_to_strr"   r   r    r!   r   r   )datas    r   r/   r/   F   se     $C5tzz|DEE	D4,	-tDz#;TBCC	4yr   c                    t        |       t        |      k7  r|j                  |        |S t        |       D ]w  \  }}t        |t              rH|D ]!  }i }t        |||      }t        |      dk(  s! n t              dk7  sK|j                  ||       ^|||   k7  sg|j                  |       y i |v r|j                  i        i |v r|S )am  
    Compares l1 and l2 lists and adds the items that are different
    to the diff_dict dictionary.
    Used in recursion with helper_compare_dictionaries() function.

    Parameters:
        l1: first list to compare
        l2: second list to compare
        diff_dict: dictionary to store the difference

    Returns:
        dict: items that are different
    r   )lenappendr%   r   r   helper_compare_dictionariesinsertremove)l1l2	diff_dictiitemitem2
diff_dict2s          r   helper_compare_listsr>   Y   s     2w#b'R= '4dD! 
8ujQ
z?a'	
 :!#  D)r!u}  &' 	/ 	/r   c                 N   | j                         D ]  \  }}||vr|||<   t        |t              r*i ||<   t        |||   ||          ||   i k(  r||= D|||<   Jt        |t              r*g ||<   t        |||   ||          ||   g k(  r||= ~|||<   |||   k7  s|||<    |S )ay  
    Compares d1 and d2 dictionaries and adds the items that are different
    to the diff_dict dictionary.
    Used in recursion with helper_compare_lists() function.

    Parameters:
        d1: first dictionary to compare
        d2: second dictionary to compare
        diff_dict: dictionary to store the difference

    Returns:
        dict: items that are different
    )r"   r   r   r4   r   r>   )d1d2r9   r   r   s        r   r4   r4   {   s     
 !1B;IaLaIaL'2a5)A,?|r!aL 	!4 IaL BqE9Q<8|r!aL 	!BqEz 	!)!* r   Nc                     |g }| j                         D ]  \  }}|	|j                  |        |D ]  }|| j                         v s| |=  | |fS )z
    Delete None parameter or specified keys from data.

    Parameters:
        data: dictionary

    Returns:
        data: falsene parameter removed data
        del_keys: deleted keys
    )r"   r3   keys)r0   del_keyskeyr(   s       r   helper_normalize_datarF      sk     jjl !
U=OOC !  $))+S	 >r   r   )
__future__r   r   r   r   __metaclass__r   r   r,   r/   r>   r4   rF   r   r   r   <module>rI      s8    A @($!*&D#Lr   