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/S3/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/S3/__pycache__/Utils.cpython-310.pyc
o

�Qa2-�@s�ddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
zeWney;eZYnwddlZddlZddlmZmZmZmZgZdAdd�Ze�d�d	d
�Ze�d
�ejejZe e�Z!dd�Z"e�d�d
d�Z#e�d�e�$dd�ddfdd�Z%e�d�e�$dd�ddfdd�Z&e�d�dd�Z'e�d�dd�Z(e�d�dBdd�Z)e�d�dCd d!�Z*e�d!�dBd"d#�Z+e�d#�dCd$d%�Z,e�d%�dDd&d'�Z-e�d'�dEd(d)�Z.e�d)�d*d+�Z/e�d+�d,d-�Z0dFd/d0�Z1e�d0�d1d2�Z2e�d2�d3d4�Z3e�d4�d5d6�Z4e�d6�d7d8�Z5e�d8�d9d:�Z6e�d:�z
ddl7Z7d;d<�Z8Wne9�ySddl:Z:d=d<�Z8Ynwe�d<�z
ddl;Z;d>d?�Z<Wne9�yqd@d?�Z<Ynwe�d?�dS)G�)�absolute_import�divisionN)�md5)�debug)�base_urlencode_string�base_replace_nonprintables�base_unicodise�base_deunicodiseFcCsf|rt|�p	t|�}|r/gd�}d}|dkr#|d}|�d�}|dks|r)t|�p,t|�|fS|dfS)N)�K�M�G�T�iir)�float�int�pop)�size�human_readable�floating_point�coeffs�coeff�r�*/usr/lib/python3/dist-packages/S3/Utils.py�
formatSize's
�rcCs&i}|D]}|d||d��<q|S)zL
    Header keys are always in lowercase in python2 but not in python3.
    �r)�lower)�list�retval�tuplerrr�convertHeaderTupleListToDict5srcCs8d}|dkr|tt�dtd�7}|d8}|dks|S)Nrrr)�
_rnd_chars�random�randint�_rnd_chars_len)�lenrrrr�rndstrAs�r%c
Cs�t�d�}d}|dkr>|t|�}z||�Wn&ty5}z|jtjkr+t�|��WYd}~nd}~ww|d8}|dkst�|�|S)N�?�rr)�os�umaskr%�OSError�errno�EEXIST)�prefix�	randchars�
createfunc�	old_umask�tries�dirname�errr�mktmpsomethingJs$

����
r4�TMPz/tmpz/tmpdir-�
cCst||tj�S�N)r4r(�mkdir)r-r.rrr�mktmpdir]sr9z	/tmpfile-�cCsdd�}t|||�S)NcSst�t�t|�tjtjB��Sr7)r(�close�open�deunicodise�O_CREAT�O_EXCL)�filenamerrr�<lambda>cszmktmpfile.<locals>.<lambda>)r4)r-r.r/rrr�	mktmpfilebsrBcCs`t�}tt|�d��}	|�d�}|sn|�|�qWd�|��S1s'wY|��S)N�rbTi�)rr<r=�read�update�	hexdigest)r@�h�fp�datarrr�
hash_file_md5hs

�
��rJc
Cs|�tj�}g}|r+tj�ttj�|���s+|�|���|r+tj�ttj�|���r|r�|�|���tj�|�}zt	d|�t�
t|��Wn8ttfyg}zt	d||j
f�WYd}~dSd}~wty�}zt	d||f�WYd}~dSd}~ww|s-dS)z�
    mkdir_with_parents(dst_dir)

    Create directory 'dir_name' with all parent directories

    Returns True on success, False otherwise.
    z	mkdir(%s)z(Can not make directory '%s' (Reason: %s)NFT)�splitr(�sep�path�isdirr=�join�appendrrr8r*�IOError�strerror�	Exception)�dir_name�pathmembers�	tmp_stack�cur_dirr3rrr�mkdir_with_parentsus,�����rX�replacecC�|stj��j}t||||�Sr7)�S3�Config�encodingr��stringr]�errors�silentrrr�	unicodise��rbcC�t|||d�S)z.
    Alias to silent version of unicodise
    T)rb�r_r]r`rrr�unicodise_s��rfcCrZr7)r[r\r]r	r^rrrr=�rcr=cCrd)z0
    Alias to silent version of deunicodise
    T)r=rerrr�
deunicodise_s�rgrhcCstt||�|��dd�S)zs
    Convert 'string' to Unicode according to current encoding
    and replace all invalid characters with '?'
    u��?)rbr=rY)r_r]rrr�unicodise_safe�srjcCs |dur
tj��j}t|||�Sr7)r[r\�urlencoding_moder)r_rk�unicode_outputrrr�urlencode_string�srmcCstj��jdk}t||�S)z�
    replace_nonprintables(string)

    Replaces all non-printable characters 'ch' in 'string'
    where ord(ch) <= 26 with ^@, ^A, ... ^Z
    �	fixbucket)r[r\rkr)r_�warning_messagerrr�replace_nonprintables�s
rpc
Cst|t�r|St|t�st|tj�rtt�|��St|d�r'tt�|����St|d�r3t|�d��St|t	�sBt|t
�sBt|t�r�z|�d�rUt��t|dd��WSt|�WSt
y�zt�|�WYSt
y}ztd|�WYd}~nd}~wwYnwtj�d|��)	z�Convert time specified in a variety of forms into UNIX epoch time.
    Accepts datetime.datetime, int, anything that has a strftime() method, and standard time 9-tuples
    �	timetuple�strftimez%s�+rNz&Failed to parse date with strptime: %sz}Unable to convert %r to an epoch time. Pass an epoch time. Try `date -d 'now + 1 year' +%%s` (shell) or time.mktime (Python).)�
isinstancerr�time�struct_time�mktime�hasattrrqrr�str�unicode�bytes�
startswith�
ValueError�strptimerr[�
Exceptions�ParameterError)�t�exrrr�
time_to_epoch�s0





���r�TcCsB|rt�d|tj�}|rtj�d||��df��nt�d|tj�}|r3tj�d||��df��t|�dkrAtj�d|��t|�dkrOtj�d	|��|r�t|�d
kr_tj�d|��t�d|tj�rotj�d
|��t�d|tj�rtj�d|��t�d|tj�s�tj�d|��t�d|tj�s�tj�d|��dS)Nz([^a-z0-9\.-])z�Bucket name '%s' contains disallowed character '%s'. The only supported ones are: lowercase us-ascii letters (a-z), digits (0-9), dot (.) and hyphen (-).rz([^A-Za-z0-9\._-])z�Bucket name '%s' contains disallowed character '%s'. The only supported ones are: us-ascii letters (a-z, A-Z), digits (0-9), dot (.), hyphen (-) and underscore (_).�z0Bucket name '%s' is too short (min 3 characters)�z1Bucket name '%s' is too long (max 255 characters)r&z0Bucket name '%s' is too long (max 63 characters)z-\.zEBucket name '%s' must not contain sequence '-.' for DNS compatibilityz\.\.zEBucket name '%s' must not contain sequence '..' for DNS compatibilityz	^[0-9a-z]z4Bucket name '%s' must start with a letter or a digitz	[0-9a-z]$z2Bucket name '%s' must end with a letter or a digitT)�re�search�UNICODEr[rr��groupsr$)�bucket�
dns_strict�invalidrrr�check_bucket_name�s0�r�cCs(zt|dd�WStjjyYdSw)NT)r�F)r�r[rr��r�rrr� check_bucket_name_dns_conformity
s
�r�cCsd|vrdSt|�S)zk
    Check whether either the host_bucket support buckets and
    either bucket name is dns compatible
    �
%(bucket)sF)r�)�bucket_host�bucket_namerrr�check_bucket_name_dns_supportsr�cCsZdtj��jvr|dfStj��j��ddi}t�||tj�}|s&|dfS|�d�dfS)z�
    bucket, success = getBucketFromHostname(hostname)

    Only works for hostnames derived from bucket names
    using Config.host_bucket pattern.

    Returns bucket name and a boolean success flag.
    r�Fr�z(?P<bucket>.*)rT)r[r\�host_bucketrr��matchr��group)�hostname�pattern�mrrr�getBucketFromHostnames	r�cCstj��j��d|iS)Nr�)r[r\r�rr�rrr�getHostnameFromBucket3sr�cCszt�}|}|dkr4|�|�|dkr0|�t||��}|s!	|��S|�|�|t|�8}|dks|��S|�|�|��S)Nrr)r�seekrD�minrEr$rF)�buffer�mfile�offset�
chunk_size�
send_chunk�md5_hash�	size_leftrIrrr�calculateChecksum8s

��	
�r�cC�tt�|�j�S)z>returns a username from the password databse for the given uid)rf�pwd�getpwuid�pw_name��uidrrr�getpwuid_usernameM�r�cCstt���Sr7)rf�getpass�getuserr�rrrr�RscCr�)z<returns a groupname from the group databse for the given gid)rf�grp�getgrgid�gr_name��gidrrr�getgrgid_grpnameXr�r�cCsdS)N�nobodyrr�rrrr�\s)FF)NrYF)NrYr7)NF)T)=�
__future__rrr(rur�r_�
string_modr!r+�hashlibr�loggingrrz�	NameErrorry�	S3.Configr[�
S3.Exceptions�S3.BaseUtilsrrrr	�__all__rrPr�
ascii_letters�digitsr r$r#r%r4�getenvr9rBrJrXrbrfr=rhrjrmrpr�r�r�r�r�r�r�r�r��ImportErrorr�r�r�rrrr�<module>s��






















	
"


	


�
�

https://t.me/RX1948 - 2025