HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/libcloud/utils/__pycache__/misc.cpython-310.pyc
o

;j��@s�ddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZ
dd
lmZgd�Zdd
�Ze
ZeZe	Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�d�ZdS) �N)�List)�
DEFAULT_DELAY)�DEFAULT_BACKOFF)�DEFAULT_TIMEOUT)�TRANSIENT_SSL_ERROR)�Retry)�TransientSSLError)�
get_driver)�
set_driver)�findr	r
�merge_valid_keys�get_new_obj�	str2dicts�dict2str�reverse_dict�lowercase_keys�get_secure_random_string�	ReprMixincs*�fdd�|D�}t|�dkr|dSdS)Ncsg|]}�|�r|�qS�r)�.0�x��	predicater�G/opt/saltstack/salt/lib/python3.10/site-packages/libcloud/utils/misc.py�
<listcomp>/�zfind.<locals>.<listcomp>r)�len)�valuer�resultsrrrr.srcCs:i}|s|S|D]}||vr||||<||||<q|S)z�
    Merge valid keys from extra into params dictionary and return
    dictionary with keys which have been merged.

    Note: params is modified in place.
    r)�paramsZ
valid_keys�extraZmerged�keyrrrr<s�rc	Cs�i}t|j���D]$\}}t|t�r|��||<q	t|ttf�r)|dd�||<q	|||<q	t|���D]1\}}|dur=q4t|t�ra|�|i�}t|���D]
\}}|durWqN|||<qN|||<q4|||<q4|di|��S)z�
    Pass attributes from the existing object 'obj' and attributes
    dictionary to a 'klass' constructor.
    Attributes from 'attributes' dictionary are only passed to the
    constructor if they are not None.
    Nr)�list�__dict__�items�
isinstance�dict�copy�tuple�get)	�obj�klass�
attributes�kwargsr!rZkwargs_valueZkey1Zvalue2rrrr
Os&





r
cCs�g}|�i�|d}|�d�}|D]1}|��}|s&i}|�|�|d}q|�d�}|s.q|d|�}||dd�}|�||i�qdd�|D�}|S)	z�
    Create a list of dictionaries from a whitespace and newline delimited text.

    For example, this:
    cpu 1100
    ram 640

    cpu 2200
    ram 1024

    becomes:
    [{'cpu': '1100', 'ram': '640'}, {'cpu': '2200', 'ram': '1024'}]
    ����
� r�NcSsg|]}|ikr|�qSrr)r�valrrrr�rzstr2dicts.<locals>.<listcomp>)�append�split�stripr�update)�data�	list_data�d�lines�line�
whitespacer!rrrrrqs&



rc	CsZg}|�d�D]#}|��}|sqz|�d�}|d}Wn	ty$Yqw|�|�q|S)z�
    Create a list of values from a whitespace and newline delimited text
    (keys are ignored).

    For example, this:
    ip 1.2.3.4
    ip 1.2.3.5
    ip 1.2.3.6

    becomes:
    ['1.2.3.4', '1.2.3.5', '1.2.3.6']
    r/r0r1)r4r5�	Exceptionr3)r7r8r;r4rrrr�str2list�s

�r>cCsLd}|D]}||dur|d�t|�t||��7}q|dt|�7}q|S)z�
    Create a string with a whitespace and newline delimited text from a
    dictionary.

    For example, this:
    {'cpu': '1100', 'ram': '640', 'smp': 'auto'}

    becomes:
    cpu 1100
    ram 640
    smp auto

    cpu 2200
    ram 1024
    �Nz{} {}
z%s
)�format�str)r7�result�krrrr�srcCsdd�t|���D�S)NcSsi|]\}}||�qSrr)rr!rrrr�
<dictcomp>�sz reverse_dict.<locals>.<dictcomp>)r"r$�Z
dictionaryrrrr�srcCsdd�|��D�S)NcSsi|]	\}}|��|�qSr)�lower)rrC�vrrrrD�sz"lowercase_keys.<locals>.<dictcomp>)r$rErrrr�srcCs*t�|�}t�|�}|�d�d|�}|S)z�
    Return a string of ``size`` random bytes. Returned string is suitable for
    cryptographic use.

    :param size: Size of the generated string.
    :type size: ``int``

    :return: Random string.
    :rtype: ``str``
    zutf-8N)�os�urandom�binascii�hexlify�decode)�sizerrrrr�s

rc@s$eZdZdZgZdd�Zdd�ZdS)rzl
    Mixin class which adds __repr__ and __str__ methods for the attributes
    specified on the class.
    cCsLg}|jD]}t||d�}|�d�||��q|jjd�|�f}d|}|S)Nz{}={}z, z<%s %s>)�_repr_attributes�getattrr3r@�	__class__�__name__�join)�selfr,Z	attributer�valuesrBrrr�__repr__�s
zReprMixin.__repr__cCst|���S)N)rArU)rSrrr�__str__szReprMixin.__str__N)rQ�
__module__�__qualname__�__doc__rNrUrVrrrrr�s

r)rHrJ�typingrZlibcloud.utils.retryrrrrrrZlibcloud.common.providersr	Z_get_driverr
Z_set_driver�__all__rZretryrr
rr>rrrrrrrrr�<module>s2")!