https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/boto/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/__pycache__/utils.cpython-310.pyc
o

ckF[���@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZ
ddlZ
ddlZ
ddlZ
ddlZ
ddlZddlZddlZddlmZmZmZmZddlmZddlmZmZeZddlm Z zddl!m"Z"Wne#ye$Z"Ynwgd�Z%e�&d	�Z'e�&d
�Z(e�&d�Z)dd
�Z*		d]dd�Z+d^dd�Z,d^dd�Z-d_dd�Z.d^dd�Z/Gdd�de0�Z1dd�Z2		!d`d"d#�Z3		!dad$d%�Z4		!dbd&d'�Z5d(Z6d)Z7d*Z8e�9�Z:ed+d,��Z;d^d-d.�Z<d/d0�Z=d^d1d2�Z>d3d4�Z?dcd5d6�Z@Gd7d8�d8eA�ZBGd9d:�d:ejCjD�ZEGd;d<�d<e0�ZFGd=d>�d>eA�ZG		ddd?d@�ZHdAdB�ZIdCdD�ZJdEdF�ZKdedJdK�ZLdLdM�ZMdfdOdP�ZNdNdefdQdR�ZOdSdT�ZPdUdV�ZQGdWdX�dXeA�ZRdYdZ�ZSd[d\�ZTdS)gz7
Some handy utility functions used by several classes.
�N)�six�StringIO�urllib�encodebytes)�contextmanager)�md5�sha512)�json)�JSONDecodeError)�acl�cors�defaultObjectAcl�location�logging�
partNumber�policy�requestPayment�torrent�
versioning�	versionId�versions�website�uploads�uploadIdzresponse-content-typezresponse-content-languagezresponse-expireszresponse-cache-controlzresponse-content-dispositionzresponse-content-encoding�delete�	lifecycle�tagging�restore�storageClass�
websiteConfig�compose�billing�userProject�encryptionConfigz(.)([A-Z][a-z]+)z([a-z])([0-9]+)z([a-z0-9])([A-Z])cCs(t|�dkr|S|dtj�|d�fS)N�r)�lenr�parse�unquote)�nv�r)�,/usr/lib/python3/dist-packages/boto/utils.py�	unquote_vksr+c
Csz|stj��}i}|D] }|��}||dur+|dvs!|�|j�r+t||���||<qd|vr4d|d<d|vr<d|d<|j|vrEd|d<|rMt|�|d<t	|�
��}d|}	|D]}||}
|�|j�rn|	d||
f7}	qY|	d|
7}	qY|�d	�}|	|d
7}	t|�dkr�|d�d�}d
d�|D�}dd�|D�}t|�d
kr�|j
dd�d�dd�|D�}|	d	7}	|	d�|�7}	|	S)zE
    Generates the aws canonical string for the given parameters
    N)�content-md5�content-type�dater-�r,r.z%s
z%s:%s
�?rr$�&cSsg|]}|�dd��qS)�=r$)�split��.0�ar)r)r*�
<listcomp>�sz$canonical_string.<locals>.<listcomp>cSs g|]}|dtvrt|��qS)r)�qsa_of_interestr+r4r)r)r*r7�� cSs|dS�Nrr))�xr)r)r*�<lambda>�sz"canonical_string.<locals>.<lambda>)�keycSsg|]}d�|��qS)r2)�joinr4r)r)r*r7�s)�boto�provider�get_default�lower�
startswith�
header_prefix�str�strip�date_header�sorted�keysr3r%�sortr>)
�method�path�headers�expiresr@�interesting_headersr=�lk�sorted_header_keys�buf�val�t�qsar)r)r*�canonical_stringrsL

��

rVcCs`|stj��}|j}|��}|��D]}|��tjjj	j
vr%||||<q|||||<q|S�N)r?r@rA�metadata_prefix�copyrIrB�s3r=�Key�base_user_settable_fields)rM�metadatar@rX�
final_headers�kr)r)r*�
merge_meta�s
r`c	Cs�|stj��}|j}i}|��D]4}|���|�rDtj�	||�}t
|t�r7z|�d�}Wn	t
y6Ynw|||t|�d�<||=q|S�N�utf-8)r?r@rArXrIrBrCrr&r'�
isinstance�bytes�decode�UnicodeDecodeErrorr%)rMr@rXr]�hkeyrSr)r)r*�get_aws_metadata�s"

��rhT�
cCs8td|�D]�}z2tj�i�}tj�|�}tj�|�}|j||d�}|��}	t|	t	j
�s5t|	d�r5|	�d�}	|	WStj
jy_}
z|
��}|dkrU|sUWYd}
~
dSWYd}
~
nd}
~
wtyv}
ztj�d�WYd}
~
nd}
~
ww|d	|kr�tj�d
�t�td|tj�dd
d���qtj�
d�dS)a
    Retry a url.  This is specifically used for accessing the metadata
    service on an instance.  Since this address should never be proxied
    (for security reasons), we create a ProxyHandler with a NULL
    dictionary to override any proxy settings in the environment.
    r)�timeoutrerbi�Nr/z&Caught exception reading instance datar$zSleeping before retrying��Boto�max_retry_delay�<z'Unable to read instance data, giving up)�ranger�request�ProxyHandler�build_opener�Request�open�readrcr�string_types�hasattrre�error�	HTTPError�getcode�	Exceptionr?�log�	exception�debug�time�sleep�min�config�get)�url�retry_on_404�num_retriesrj�i�
proxy_handler�opener�req�r�result�e�coder)r)r*�	retry_url�s:�

�����r�cCst|||�SrW)�LazyLoadMetadata)r�r�rjr)r)r*�_get_instance_metadata�sr�csheZdZddd�Zdd�Z�fdd�Zddd	�Z�fd
d�Z�fdd
�Z�fdd�Z	�fdd�Z
�ZS)r�Nc
Cs�||_||_i|_g|_||_tjj|j|j|jd�}|r`|�d�}|D]=}|�	d�r8|dd�}|j�
|�n#|�d�}|dkrR||dd�}|d|�d}	n|}}	|	|j|<d||<q$dSdS)	N�r�rj�
�/r���r2r$z/openssh-key)�_url�_num_retries�_leaves�_dicts�_timeoutr?�utilsr�r3�endswith�append�find)
�selfr�r�rj�data�fields�fieldr=�p�resourcer)r)r*�__init__�s*




�zLazyLoadMetadata.__init__cCs|D]}||qdSrWr)�r�r=r)r)r*�_materializes
�zLazyLoadMetadata._materializec	s||vrtt|��|�Stt|��|�}|dur|S||jvr�|j|}d}td|j�D]�}z5tjj|j	t
jj|dd�|j|j
d�}|rS|ddkrSt�|�}Wn�|�d�}|dkra|�d�}Wn�ty�}ztj�d|jj|f�tj�d|�|}WYd}~nd}~wty�}ztj�d	d
|jj�|}�d}~wwtj�dd|d
�|d
|jkr�tt��d|tj�ddd��}t�|�q,tj�d�tj�d|jj|f�|�|||<n||jvr�t|j	|d|j�||<tt|��|�S)Nrz/:)�safer��{r�zencountered '%s' exception: %szcorrupted JSON data found: %szencountered unretryablez '%s' exception, re-raisingz"Caught exception reading meta dataz for the '%s' tryr$rkrlrmrnz#Unable to read meta data, giving upr�) �superr��__getitem__r�ror�r?r�r�r�rr&�quoter�r	�loadsr�r3r
r|r~�	__class__�__name__r{rxr��randomr�r�rr�r�)	r�r=rSr��last_exceptionr�r�r��
next_sleep�r�r)r*r�s�

��


��������
��
���

�zLazyLoadMetadata.__getitem__cCs"z||WSty|YSwrW)�KeyError)r�r=�defaultr)r)r*r�Ss

�zLazyLoadMetadata.getc�|��tt|���SrW)r�r�r��values�r�r�r)r*r�Y�zLazyLoadMetadata.valuescr�rW)r�r�r��itemsr�r�r)r*r�]r�zLazyLoadMetadata.itemscr�rW)r�r�r��__str__r�r�r)r*r�ar�zLazyLoadMetadata.__str__cr�rW)r�r�r��__repr__r�r�r)r*r�er�zLazyLoadMetadata.__repr__rW)r��
__module__�__qualname__r�r�r�r�r�r�r�r��
__classcell__r)r)r�r*r��s

Cr�cCsd|||fS)ax
    Builds an EC2 metadata URL for fetching information about an instance.

    Example:

        >>> _build_instance_metadata_url('http://169.254.169.254', 'latest', 'meta-data/')
        http://169.254.169.254/latest/meta-data/

    :type url: string
    :param url: URL to metadata service, e.g. 'http://169.254.169.254'

    :type version: string
    :param version: Version of the metadata to get, e.g. 'latest'

    :type path: string
    :param path: Path of the metadata to get, e.g. 'meta-data/'. If a trailing
                 slash is required it must be passed in with the path.

    :return: The full metadata URL
    z%s/%s/%sr))r��versionrLr)r)r*�_build_instance_metadata_urljsr��latest�http://169.254.169.254�
meta-data/�cCsDzt|||�}t|||d�WStjjy!tj�d|�YdSw)a�
    Returns the instance metadata as a nested Python dictionary.
    Simple values (e.g. local_hostname, hostname, etc.) will be
    stored as string values.  Values such as ancestor-ami-ids will
    be stored in the dict as a list of string values.  More complex
    fields such as public-keys and will be stored as nested dicts.

    If the timeout is specified, the connection to the specified url
    will time out after the specified number of seconds.

    r�zBException caught when trying to retrieve instance metadata for: %sN)r�r�rrx�URLErrorr?r|r})r�r�r�rjr��metadata_urlr)r)r*�get_instance_metadata�s
��r�c
Cs�i}t||d�}z2t|||d�}|�d�}|D] }t|d|d||d�}	|	ddkr1t�|	�}	|r7|	||<q|WStjjyFYdSw)zF
    Returns the instance identity as a nested Python dictionary.
    zdynamic/instance-identity/r�r�r�rr�N)r�r�r3r	r�rrxr�)
r�r�rjr��iid�base_urlr�r�r�rSr)r)r*�get_instance_identity�s$�

��r�c
Csbt||d�}t|d||d�}|r/|r/|�|�}i}|D]}|�d�}	|	d��||	d��<q|S)Nz	user-dataF)r�r�rjr2r$r)r�r�r3rF)
r��sepr�rjr��ud_url�	user_data�l�nvpairrTr)r)r*�get_instance_userdata�s

r�z%Y-%m-%dT%H:%M:%SZz%Y-%m-%dT%H:%M:%S.%fZz%a, %d %b %Y %H:%M:%S %Zccsl�t�)t�tj�}zt�tj|�VWt�tj|�nt�tj|�wWd�dS1s/wYdS)zE
    A context manager to set the locale in a threadsafe manner.
    N)�LOCALE_LOCK�locale�	setlocale�LC_ALL)�name�savedr)r)r*r��s�""�r�cCs|st��}t�t|�SrW)r�gmtime�strftime�ISO8601)�tsr)r)r*�get_ts�sr�cCs�td��M|��}ztj�|t�}|WWd�StyPztj�|t�}|WYWd�StyOtj�|t�}|YYWd�Sww1sTwYdS)N�C)r�rF�datetime�strptimer��
ValueError�
ISO8601_MS�RFC1123)r��dtr)r)r*�parse_ts�s$
��	
�	��r�cCsp|rd||f}|�d�}d}z"|dd�D]}|r t||�}qttd�|dd���|�}q|WSYdS)Nz%s.%s�.r$rr�)r3�getattr�
__import__r>)�module_name�
class_name�modules�c�mr)r)r*�
find_class�s
r�cCs,d}|d7}tj�|||||f�}|��S)z=
    Update your Dynamic DNS record with DNSMadeEasy.com
    z,https://www.dnsmadeeasy.com/servlet/updateipz$?username=%s&password=%s&id=%s&ip=%s)rrp�urlopenru)�username�password�dme_id�
ip_address�dme_url�sr)r)r*�
update_dme�sr�c
Cs�tj�d|�|durt��}zb|�d�r;|td�d��dd�\}}tj||d�}|�	|�}|�
|�}|�|�n0|r^|r^tj
��}	|	�d|||�tj
�|	�}
tj
�|
�}tj
�|�tj
�|�}|�|���|�d�W|S�)z�
    Fetch a file based on the URI provided.
    If you do not pass in a file pointer a tempfile.NamedTemporaryFile,
    or None if the file could not be retrieved is returned.
    The URI can be either an HTTP url, or "s3://bucket_name/key_name"
    zFetching %sNzs3://r�r$)�aws_access_key_id�aws_secret_access_keyr)r?r|�info�tempfile�NamedTemporaryFilerCr%r3�
connect_s3�
get_bucket�get_key�get_contents_to_filerrp�HTTPPasswordMgrWithDefaultRealm�add_password�HTTPBasicAuthHandlerrr�install_openerr��writeru�seekr})
�uri�filer�r��bucket_name�key_namer��bucketr=�passman�authhandlerr�r�r)r)r*�
fetch_file�s0
�


�rc@sTeZdZddd�Zddd�Zdd	�Zd
d�Zeeedd�Zd
d�Z	ee	edd�Z
dS)�ShellCommandTFNcCs0d|_||_t�|_||_||_|j|d�dS)Nr)�cwd)�	exit_code�commandr�log_fp�wait�	fail_fast�run)r�rrrrr)r)r*r�$szShellCommand.__init__cCs�tj�d|j�tj|jdtjtjtj|d�|_|jri|j�	�durDt
�d�|j��}|j
�|d�|j
�|d�|j�	�dus#tj�|j
���|jj|_|jrf|jdkrftd|jd|j��|jSdS)Nz
running:%sT)�shell�stdin�stdout�stderrrr$rzCommand z failed with status )r?r|r�r�
subprocess�Popen�PIPE�processr�pollrr��communicaterr�getvalue�
returncoderrr{)r�rrTr)r)r*r,s0
�

�

���zShellCommand.runcCst�rW)�AttributeError�r��valuer)r)r*�setReadOnlyB�zShellCommand.setReadOnlycCs|jSrW)rr�r)r)r*�	getStatusEszShellCommand.getStatuszThe exit code for the commandcCs
|j��SrW)rrr�r)r)r*�	getOutputK�
zShellCommand.getOutputz*The STDIN and STDERR output of the command)TFNrW)r�r�r�r�rr$r&�property�statusr'�outputr)r)r)r*r
"s

��r
cs(eZdZdZ�fdd�Zdd�Z�ZS)�AuthSMTPHandlera�
    This class extends the SMTPHandler in the standard Python logging module
    to accept a username and password on the constructor and to then use those
    credentials to authenticate with the SMTP server.  To use this, you could
    add something like this in your boto config file:

    [handler_hand07]
    class=boto.utils.AuthSMTPHandler
    level=WARN
    formatter=form07
    args=('localhost', 'username', 'password', 'from@abc', ['user1@abc', 'user2@xyz'], 'Logger Subject')
    cs&tt|��||||�||_||_dS)z�
        Initialize the handler.

        We have extended the constructor to accept a username/password
        for SMTP authentication.
        N)r�r,r�r�r�)r��mailhostr�r��fromaddr�toaddrs�subjectr�r)r*r�`s
�
zAuthSMTPHandler.__init__c	Cs�z@|j}|s	tj}t�|j|�}|�|j|j�|�|�}d|j	d�
|j�|�|�t
j��|f}|�|j	|j|�|��WdSttfyJ�|�|�YdS)z�
        Emit a record.

        Format the record and send it to the specified addressees.
        It would be really nice if I could add authorization to this class
        without having to resort to cut and paste inheritance but, no.
        z-From: %s
To: %s
Subject: %s
Date: %s

%s�,N)�mailport�smtplib�	SMTP_PORT�SMTPr-�loginr�r��formatr.r>r/�
getSubject�emailr��
formatdate�sendmail�quit�KeyboardInterrupt�
SystemExit�handleError)r��record�port�smtp�msgr)r)r*�emitms&


�zAuthSMTPHandler.emit)r�r�r��__doc__r�rDr�r)r)r�r*r,Rs

r,c@speZdZdZGdd�de�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�LRUCacheaqA dictionary-like object that stores only a certain number of items, and
    discards its least recently used item when full.

    >>> cache = LRUCache(3)
    >>> cache['A'] = 0
    >>> cache['B'] = 1
    >>> cache['C'] = 2
    >>> len(cache)
    3

    >>> cache['A']
    0

    Adding new items to the cache does not increase its size. Instead, the least
    recently used item is dropped:

    >>> cache['D'] = 3
    >>> len(cache)
    3
    >>> 'B' in cache
    False

    Iterating over the cache returns the keys, starting with the most recently
    used:

    >>> for key in cache:
    ...     print key
    D
    A
    C

    This code is based on the LRUCache class from Genshi which is based on
    `Myghty <http://www.myghty.org>`_'s LRUCache from ``myghtyutils.util``,
    written by Mike Bayer and released under the MIT license (Genshi uses the
    BSD License).
    c@seZdZdd�Zdd�ZdS)zLRUCache._ItemcCsd|_|_||_||_dSrW)�previous�nextr=r#)r�r=r#r)r)r*r��s
zLRUCache._Item.__init__cC�
t|j�SrW)�reprr#r�r)r)r*r��r(zLRUCache._Item.__repr__N)r�r�r�r�r�r)r)r)r*�_Item�srKcCst�|_||_d|_d|_dSrW)�dict�_dict�capacity�head�tail)r�rNr)r)r*r��s
zLRUCache.__init__cCs
||jvSrW)rMr�r)r)r*�__contains__�r(zLRUCache.__contains__ccs&�|j}|r|jV|j}|sdSdSrW)rOr=rH)r��curr)r)r*�__iter__�s��zLRUCache.__iter__cCrIrW)r%rMr�r)r)r*�__len__�r(zLRUCache.__len__cCs|j|}|�|�|jSrW)rM�_update_itemr#)r�r=�itemr)r)r*r��s

zLRUCache.__getitem__cCsT|j�|�}|dur|�||�}||j|<|�|�dS||_|�|�|��dSrW)rMr�rK�_insert_itemr#rU�_manage_size)r�r=r#rVr)r)r*�__setitem__�s

zLRUCache.__setitem__cCrIrW)rJrMr�r)r)r*r��r(zLRUCache.__repr__cCs:d|_|j|_|jdur||j_n||_||_|��dSrW)rGrOrHrPrX)r�rVr)r)r*rW�s

zLRUCache._insert_itemcCs`t|j�|jkr.|j|jj=|j|jkr|jj|_d|j_nd|_|_t|j�|jksdSdSrW)r%rMrNrPr=rOrGrHr�r)r)r*rX�s

�zLRUCache._manage_sizecCsV|j|krdS|j}|j|_|jdur||j_n||_d|_|j|_||j_|_dSrW)rOrGrHrP)r�rVrGr)r)r*rU�s


zLRUCache._update_itemN)r�r�r�rE�objectrKr�rQrSrTr�rYr�rWrXrUr)r)r)r*rF�s%	
	rFc@s>eZdZdZeZd
dd�Zdd�Zdd�Zd	d
�Z	dd�Z
dS)�Passwordzp
    Password object that stores itself as hashed.
    Hash defaults to SHA512 if available, MD5 otherwise.
    NcCs||_|r
||_dSdS)zh
        Load the string from an initial value, this should be the
        raw hashed password.
        N)rE�hashfunc)r�rEr\r)r)r*r�s
�zPassword.__init__cCs(t|t�s
|�d�}|�|���|_dSra)rcrd�encoder\�	hexdigestrEr"r)r)r*�sets

zPassword.setcCs
t|j�SrW�rEr�r)r)r*r�r(zPassword.__str__cCs<|durdSt|t�s|�d�}t|�|����t|j�kS)NFrb)rcrdr]rEr\r^)r��otherr)r)r*�__eq__s


zPassword.__eq__cCs|jrt|j�SdSr:)rEr%r�r)r)r*rTs
zPassword.__len__�NN)r�r�r�rE�_hashfnr\r�r_r�rbrTr)r)r)r*r[s
	r[c
Cs�|pg}|rdtj�dd�|f}|stj�ddd�}|r�z�tj�ddd�}tjj��}||d<||d	<||d
<tjjdd�|d
<||d<|rQ|�	tjj
�|��|rktjj�
dd�}|�|�tj�|�|�	|�|D]}|�	|�qmtj�ddd�}	tj�dd�r�t�|	ttj�dd���}
nt�|	�}
tj�dd�r�|
��|
��|
��tj�ddd�}tj�ddd�}|r�|
�||�|
�|||���|
��WdStj�d�YdSdS)Nz[%s] %s�Instancezinstance-id�Notification�smtp_to�	smtp_fromr?�FromzReply-To�ToT)�	localtime�Date�Subject�text�html�	smtp_host�	localhost�	smtp_port�smtp_tls�	smtp_userr/�	smtp_passz
notify failed)r?r��	get_valuer9�mime�	multipart�
MIMEMultipartr�r:�attachrn�MIMEText�base�MIMEBase�set_payload�encoders�
encode_base64r3r5�int�getbool�ehlo�starttlsr6r;�	as_stringr<r|r})
r0�body�	html_body�	to_string�attachments�append_instance_id�from_stringrC�partrp�serverrtrur)r)r*�notify&s`��

��
�r�cCsDtjs
t|t�r
|St|tj�st�|�}t|tj�r |�d�}|Sra)r�PY2rcrdrv�	text_typer]�r#r)r)r*�get_utf8_value^s

r�cCs*t|t�st|t�rt|�}|S|g}|SrW)rc�list�tupler�r)r)r*�mklistks

�r�cCs(t�d|�}t�d|�}t�d|���S)a~Convert camel case to a "pythonic" name.

    Examples::

        pythonize_name('CamelCase') -> 'camel_case'
        pythonize_name('already_pythonized') -> 'already_pythonized'
        pythonize_name('HTTPRequest') -> 'http_request'
        pythonize_name('HTTPStatus200Ok') -> 'http_status_200_ok'
        pythonize_name('UPPER') -> 'upper'
        pythonize_name('') -> ''

    z\1_\2)�_first_cap_regex�sub�_number_cap_regex�_end_cap_regexrB)r��s1�s2r)r)r*�pythonize_namets
r�F�
text/plain�:cCs�tjj��}|D]?\}}t||�}|�dd�\}}	|dkr'tjjj||	d�}
ntjj�	||	�}
|
�
|�tj�|
�|
j
dd|d�|�|
�q|��}|rmt�}tjd|d	�}
z|
�|�W|
��n|
��w|��}|S)
a�Description:
    :param content: A list of tuples of name-content pairs. This is used
    instead of a dict to ensure that scripts run in order
    :type list of tuples:

    :param compress: Use gzip to compress the scripts, defaults to no compression
    :type bool:

    :param deftype: The type that should be assumed if nothing else can be figured out
    :type str:

    :param delimiter: mime delimiter
    :type str:

    :return: Final mime multipart
    :rtype: str:
    r�r$rn)�_subtypezContent-Disposition�
attachment)�filename�wb)�mode�fileobj)r9rwrxry�guess_mime_typer3rnr{r|r}r~rr��
add_headerrzr�r�gzip�GzipFiler�closer)�content�compress�deftype�	delimiter�wrapperr��con�
definite_type�maintype�subtype�mime_con�rcontentrR�gzr)r)r*�write_mime_multipart�s(

r�cCs@ddddddd�}|}|��D]\}}|�|�r|}|Sq|S)z�Description: Guess the mime type of a block of text
    :param content: content we're finding the type of
    :type str:

    :param deftype: Default mime type
    :type str:

    :rtype: <type>:
    :return: <description>
    ztext/x-include-urlztext/x-shellscriptztext/cloud-configztext/upstart-jobztext/part-handlerztext/cloud-boothook)z#includez#!z
#cloud-configz#upstart-jobz
#part-handlerz#cloud-boothook)r�rC)r�r��starts_with_mappings�rtype�
possible_type�mimetyper)r)r*r��s
�
�r�� cCst|||td�S)a�
    Compute MD5 hash on passed file and return results in a tuple of values.

    :type fp: file
    :param fp: File pointer to the file to MD5 hash.  The file pointer
               will be reset to its current location before the
               method returns.

    :type buf_size: integer
    :param buf_size: Number of bytes per read request.

    :type size: int
    :param size: (optional) The Maximum number of bytes to read from
                 the file pointer (fp). This is useful when uploading
                 a file in multiple parts where the file is being
                 split inplace into different parts. Less bytes may
                 be available.

    :rtype: tuple
    :return: A tuple containing the hex digest version of the MD5 hash
             as the first element, the base64 encoded version of the
             plain digest as the second element and the data size as
             the third element.
    )�hash_algorithm)�compute_hashr)�fp�buf_size�sizer)r)r*�compute_md5�sr�c
Cs�|�}|��}|r||kr|�|�}n|�|�}|rIt|t�s$|�d�}|�|�|r6|t|�8}|dkr6n|rB||krB|�|�}n|�|�}|s|��}t|�	���
d�}|ddkrb|dd�}|��|}	|�|�|||	fS)Nrbrr�r�)�tellrurcrdr]�updater%r^r�digestrer)
r�r�r�r��hash_obj�sposr��
hex_digest�
base64_digest�	data_sizer)r)r*r��s0




�

r�cs�fdd�|D�S)z�
    Takes a specific header name and a dict of headers {"name": "value"}.
    Returns a list of matching header names, case-insensitive.

    cs g|]}|�����kr|�qSr))rB�r5�h�r�r)r*r7r9z)find_matching_headers.<locals>.<listcomp>r))r�rMr)r�r*�find_matching_headerssr�cs"t|��}d��fdd�|D��S)z�
    Takes a specific header name and a dict of headers {"name": "value"}.
    Returns a string of all header values, comma-separated, that match the
    input header name, case-insensitive.

    r1c3s(�|]}�|durt�|�VqdSrWr`r��rMr)r*�	<genexpr>s�
��z(merge_headers_by_name.<locals>.<genexpr>)r�r>)r�rM�matching_headersr)r�r*�merge_headers_by_names
r�c@seZdZdZddd�ZdS)�RequestHookz�
    This can be extended and supplied to the connection object
    to gain access to request and response object after the request completes.
    One use for this would be to implement some specific request logging.
    FcCsdSrWr))r�rp�responserxr)r)r*�handle_request_data#r%zRequestHook.handle_request_dataN)F)r�r�r�rEr�r)r)r)r*r�sr�cCs:|rt|t�s	dS|�d�rdSt|�d��dkrdSdS)zQ
    Detect (naively) if the hostname is an IPV6 host.
    Return a boolean.
    F�[Tr�rk)rcrErCr%r3��hostnamer)r)r*�host_is_ipv6's
r�cCs6|��}t|�r|�dd�d�d�S|�dd�dS)z�
    Given a hostname that may have a port name, ensure that the port is trimmed
    returning only the host, including hostnames that are IPV6 and may include
    brackets.
    z]:r$rz[]r�)rFr�r3r�r)r)r*�
parse_host>sr�rcrW)TriN)r�r�r�Nr�)r�r�Nr�)r�Nr�Nr�)NNN)NNNNT)Fr�r�)r�N)UrErr�logging.handlersrr?�
boto.providerr�r�r3r��re�email.mime.multipartr9�email.mime.base�email.mime.text�email.utils�email.encodersr��	threadingr��boto.compatrrrr�
contextlibr�hashlibrrrdr	�boto.compat.jsonr
�ImportErrorr�r8�compiler�r�r�r+rVr`rhr�r�rLr�r�r�r�r�r�r�r��Lockr�r�r�r�r�r�rrZr
�handlers�SMTPHandlerr,rFr[r�r�r�r�r�r�r�r�r�r�r�r�r�r)r)r)r*�<module>s�%�



�
:


#v
�
�
�






#07w&
�8
	
-
	


https://t.me/RX1948 - 2025