HEX
Server: LiteSpeed
System: Linux us-phx-web629.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64
User: u756937133 (756937133)
PHP: 8.2.30
Disabled: passthru,chgrp
Upload Files
File: //proc/2863166/root/usr/lib/python3.9/site-packages/S3/__pycache__/Utils.cpython-39.opt-1.pyc
a

�9pe+�@s�ddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZzeWne
yjeZYn0ddlZddlZddlmZmZmZmZmZgZd<dd�Ze�d�dd	�Ze�d	�ejejZee�Z d
d�Z!e�d�dd
�Z"e�d
�e�#dd�ddfdd�Z$e�d�e�#dd�ddfdd�Z%e�d�dd�Z&e�d�d=dd�Z'e�d�d>dd�Z(e�d�d?dd �Z)e�d �d@d!d"�Z*e�d"�dAd#d$�Z+e�d$�dBd%d&�Z,e�d&�d'd(�Z-e�d(�d)d*�Z.dCd,d-�Z/e�d-�d.d/�Z0e�d/�d0d1�Z1e�d1�d2d3�Z2e�d3�d4d5�Z3e�d5�zddl4Z4d6d7�Z5Wn$e6�yzddl7Z7d8d7�Z5Yn0e�d7�zddl8Z8d9d:�Z9Wne6�y�d;d:�Z9Yn0e�d:�dS)D�)�absolute_import�divisionN)�debug)�base_urlencode_string�base_replace_nonprintables�base_unicodise�base_deunicodise�md5FcCsd|rt|�pt|�}|rXgd�}d}|dkr@|d}|�d�}q$|rLt|�pRt|�|fS|dfSdS)N)�K�M�G�T�iir)�float�int�pop)�sizeZhuman_readableZfloating_pointZcoeffsZcoeff�r�,/usr/lib/python3.9/site-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�convertHeaderTupleListToDict8srcCs2d}|dkr.|tt�dtd�7}|d8}q|S)Nrrr)�
_rnd_chars�randomZrandint�_rnd_chars_len)�lenrrrr�rndstrDs

r c
Cs�t�d�}d}|dkrz|t|�}z||�WqzWn<tyn}z$|jtjkrZt�|��WYd}~n
d}~00|d8}qt�|�|S)N�?�rr)�os�umaskr �OSError�errnoZEEXIST)�prefix�	randchars�
createfuncZ	old_umaskZtries�dirname�errr�mktmpsomethingMs



r,ZTMPz/tmpz/tmpdir-�
cCst||tj�S�N)r,r#�mkdir)r'r(rrr�mktmpdir`sr0z	/tmpfile-�cCsdd�}t|||�S)NcSst�t�t|�tjtjB��Sr.)r#�close�open�deunicodise�O_CREAT�O_EXCL)�filenamerrr�<lambda>f�zmktmpfile.<locals>.<lambda>)r,)r'r(r)rrr�	mktmpfileesr:c
Cs�|�tj�}g}|r<tj�ttj�|���s<|�|���q|�r�|�|���tj�|�}zt	d|�t�
t|��Wq<ttfy�}z t	d||j
f�WYd}~dSd}~0t�y�}zt	d||f�WYd}~dSd}~00q<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�isdirr4�join�appendrrr/r%�IOError�strerror�	Exception)Zdir_nameZpathmembersZ	tmp_stackZcur_dirr+rrr�mkdir_with_parentsks"rD�replacecCs|stj��j}t||||�Sr.)�S3�Config�encodingr��stringrH�errorsZsilentrrr�	unicodise�srLcCst|||d�S)z.
    Alias to silent version of unicodise
    T)rL�rJrHrKrrr�unicodise_s�srNcCs|stj��j}t||||�Sr.)rFrGrHrrIrrrr4�sr4cCst|||d�S)z0
    Alias to silent version of deunicodise
    T)r4rMrrr�
deunicodise_s�srOcCstt||�|��dd�S)zs
    Convert 'string' to Unicode according to current encoding
    and replace all invalid characters with '?'
    u��?)rLr4rE)rJrHrrr�unicodise_safe�srQcCs |durtj��j}t|||�Sr.)rFrG�urlencoding_moder)rJrRZunicode_outputrrr�urlencode_string�srScCstj��jdk}t||�S)z�
    replace_nonprintables(string)

    Replaces all non-printable characters 'ch' in 'string'
    where ord(ch) <= 26 with ^@, ^A, ... ^Z
    Z	fixbucket)rFrGrRr)rJZwarning_messagerrr�replace_nonprintables�srTc
Cs t|t�r|St|t�s$t|tj�r2tt�|��St|d�rNtt�|����St|d�rft|�d��St|t	�s�t|t
�s�t|t��rz.|�d�r�t��t|dd��WSt|�WSt
�y
zt�|�WYSt
�y}ztd|�WYd}~n
d}~00Yn0tj�d|��dS)	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�hasattrrUrV�str�unicode�bytes�
startswith�
ValueError�strptimerrF�
Exceptions�ParameterError)�t�exrrr�
time_to_epoch�s(


 


rgTcCsJ|r6t�d|tj�}|rftj�d||��df��n0t�d|tj�}|rftj�d||��df��t|�dkr�tj�d|��t|�dkr�tj�d	|��|�rFt|�d
kr�tj�d|��t�d|tj�r�tj�d
|��t�d|tj��rtj�d|��t�d|tj��s$tj�d|��t�d|tj��sFtj�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�UNICODErFrcrd�groupsr)�bucket�
dns_strictZinvalidrrr�check_bucket_name�s.rpcCs,zt|dd�WStjjy&YdS0dS)NT)roF)rprFrcrd�rnrrr� check_bucket_name_dns_conformitysrrcCsd|vrdSt|�S)zk
    Check whether either the host_bucket support buckets and
    either bucket name is dns compatible
    �
%(bucket)sF)rr)Zbucket_hostZbucket_namerrr�check_bucket_name_dns_supportsrtcCsZdtj��jvr|dfStj��j��ddi}t�||tj�}|sL|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.
    rsFrnz(?P<bucket>.*)rT)rFrG�host_bucketrrj�matchrl�group)�hostname�pattern�mrrr�getBucketFromHostnames	r{cCstj��j��d|iS)Nrn)rFrGrurrqrrr�getHostnameFromBucket)sr|cCstt�|�j�S)z?returns a username from the password database for the given uid)rN�pwd�getpwuid�pw_name��uidrrr�getpwuid_username1sr�cCstt���Sr.)rN�getpassZgetuserr�rrrr�6scCstt�|�j�S)z=returns a groupname from the group database for the given gid)rN�grp�getgrgid�gr_name��gidrrr�getgrgid_grpname<sr�cCsdS)NZnobodyrr�rrrr�@s)FF)NrEF)NrE)NrEF)NrE)N)NF)T):Z
__future__rrr#rYrjrJZ
string_modrr&Zloggingrr^�	NameErrorr]Z	S3.ConfigrFZ
S3.ExceptionsZS3.BaseUtilsrrrrr	�__all__rr@r�
ascii_letters�digitsrrrr r,�getenvr0r:rDrLrNr4rOrQrSrTrgrprrrtr{r|r}r��ImportErrorr�r�r�rrrr�<module>
s�




















	
"