HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib/python3.6/site-packages/S3/__pycache__/BaseUtils.cpython-36.pyc
3

�9pe�(�/@sNddlmZmZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZddlZddljjZddlmZyddlZWn4ek
r�ejjd�ejj�eje�YnXydd	lmZWn ek
r�dd	l mZYnXye!Z!Wne"k
�re#Z!YnXgZ$eZ%e$j&d
�y
e
�Wn\e'k
�r�Z(z>ye
dd�ej)e
dd�Z
Wne*k
�rze(�YnXWYddZ([(XnXe$j&d
�ej+d�Z,ej+dej-�Z.dd�Z/e$j&d�dd�Z0e$j&d�dd�Z1e$j&d�dd�Z2e$j&d�dd�Z3e$j&d�d?dd�Z4e$j&d�d@dd�Z5e$j&d�dAd d!�Z6e$j&d!�dBd"d#�Z7e$j&d#�dCd%d&�Z8e$j&d&�dDd'd(�Z9e$j&d(�dEd)d*�Z:e$j&d*�d+d,�Z;e$j&d,�d-d.�Z<e$j&d.�d/d0�Z=e$j&d0�d1d2�Z>e$j&d2�d3d4�Z?e$j&d4�d5d6�Z@e$j&d6�d7d8�ZAe$j&d8�d9d:�ZBe$j&d:�d;d<�ZCe$j&d<�d=d>�ZDe$j&d>�dS)F�)�absolute_import�divisionN)�timegm)�md5)�debug�warning�error�)�	EX_OSFILEa*
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ImportError trying to import dateutil.parser.
Please install the python dateutil module:
$ sudo apt-get install python-dateutil
  or
$ sudo yum install python-dateutil
  or
$ pip install python-dateutil
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
)�quote�s3pathF)Zusedforsecurityrz\.[0-9]*(?:[Z\-\+]*?)s9^(<?[^>]+?>\s*|\s*)(<\w+) xmlns=['"](https?://[^'"]+)['"]cCstjd|�}tjj|dd�S)Nz.000T)�fuzzy)�RE_S3_DATESTRING�sub�dateutil�parser�parse)�date�r�/usr/lib/python3.6/BaseUtils.py�dateS3toPythonXsrcCstt|�j��S)N)rr�utctimetuple)rrrr�dateS3toUnix_srcCstjj|dd�S)zW
    Convert a string formatted like '2020-06-27T15:56:34Z' into a python datetime
    T)r
)rrr)rrrr�dateRFC822toPythonesrcCstt|�j��S)N)rrr)rrrr�dateRFC822toUnixmsrcCstjj|dd�}|jd�S)NT)r
z%Y-%m-%d %H:%M)rrrZstrftime)Zs3timestampZdate_objrrr�formatDateTimersr�UTF-8�replacecCsVt|�tkr|S|s$td||f�yt|||�Stk
rPtd|��YnXdS)z<
    Convert 'string' to Unicode or raise an exception.
    zUnicodising %r using %sz Conversion to unicode failed: %rN)�type�unicoder�UnicodeDecodeError)�string�encoding�errors�silentrrr�base_unicodise{sr%cCsVt|�tkr|S|s$td||f�y|j||�Stk
rPtd|��YnXdS)z�
    Convert unicode 'string' to <type str>, by default replacing
    all invalid characters with '?' or raise an exception.
    zDeUnicodising %r using %sz"Conversion from unicode failed: %rN)rrr�encode�UnicodeEncodeError)r!r"r#r$rrr�base_deunicodise�sr(cCst|d|d�S)zE
    Convert S3 UTF-8 'string' to Unicode or raise an exception.
    zUTF-8T)r%)r!r#rrr�decode_from_s3�sr)cCst|d|d�S)z
    Convert Unicode to S3 UTF-8 'string', by default replacing
    all invalid characters with '?' or raise an exception.
    zUTF-8T)r()r!r#rrr�encode_to_s3�sr*TcCs<|r
d}nd}t|�}t||d�}|r0t|�}nt|�}|S)a�
    URI encode every byte. UriEncode() must enforce the following rules:
    - URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9', '-', '.', '_', and '~'.
    - The space character is a reserved character and must be encoded as "%20" (and not as "+").
    - Each URI encoded byte is formed by a '%' and the two-digit hexadecimal value of the byte.
    - Letters in the hexadecimal value must be uppercase, for example "%1A".
    - Encode the forward slash character, '/', everywhere except in the object key name.
    For example, if the object key name is photos/Jan/sample.jpg, the forward slash in the key name is not encoded.
    �~z~/)�safe)r*rr))ZparamZquote_backslashes�unicode_outputZ
safe_charsrrr�s3_quote�s

r.cCsHt|�}|dkr|St|dd�}td||f�|r<t|�St|�SdS)NZverbatimz~/)r,zString '%s' encoded to '%s')r*rrr))r!Zurlencoding_moder-Zencodedrrr�base_urlencode_string�sr/cCs�d}d}x`|D]X}t|�}|dkrD|dttd�|�7}|d7}q|dkr^|d7}|d7}q||7}qW|r�|r�td	||f�|S)
z�
    replace_nonprintables(string)

    Replaces all non-printable characters 'ch' in 'string'
    where ord(ch) <= 26 with ^@, ^A, ... ^Z
    �r��^�@r	�z^?z+%d non-printable characters replaced in: %s)�ord�chrr)r!Zwith_messageZ
new_stringZmodified�c�orrr�base_replace_nonprintables�s


r9cCs�g}x||D]t}i}x\|D]T}t|j�}t|�r>t|g�||<q|jd|j�}|dk	rdt|�||<qd||<qW|r
|j|�q
W|S)Nz.//%s)r)�tag�len�
parseNodes�findtext�append)�nodesZretval�nodeZretval_item�child�nameZ
found_textrrrr<�s


r<cCstjjj|�}|j�S)N)�xmlZdomZminidomZparseStringZtoprettyxml)ZxmlstrZ	xmlparserrrr�getPrettyFromXml	srDcCs4tj|�}|r(|jd�}tjd|d�}nd}||fS)zy
    removeNameSpace(xml) -- remove top-level AWS namespace
    Operate on raw byte(utf-8) xml string. (Not unicode)
    �s\1\2r	N)�RE_XML_NAMESPACE�match�groupr)rCZxmlns_match�xmlnsrrr�stripNameSpaces

rJcCshtt|��\}}ytj|�}|r*||jd<|Stk
rb}ztd|�t|��WYdd}~XnXdS)NrIzError parsing xml: %s)rJr*�ETZ
fromstringZattrib�	Exceptionr)rCrI�tree�errr�getTreeFromXmls


rOcCst|�}|jd|�}t|�S)Nz.//%s)rO�findallr<)rCr@rMr?rrr�getListFromXml-srQcCs�i}x�|D]~}t|�r t|�}n|jdk	r4t|j�nd}t|j�}||kr|t||�tksh||g||<||j|pvd�q
|p�d||<q
W|S)Nr0)r;�getDictFromTree�textr)r:r�listr>)rMZret_dictrAZcontentZ	child_tagrrrrR4s


rRcCsNt|�}|jj|�r,|jdk	r(t|j�SdS|j|�}|dk	rFt|�SdSdS)N)rOr:�endswithrSr)r=)rCZxpathrM�resultrrr�getTextFromXmlGs

rWcCs t|�}|jdk	rt|j�SdS)N)rOr:r))rCrMrrr�getRootTagNameQsrXcCstj|�}t|�|_|S)N)rKZElementr)rS)�tag_namerS�elrrr�xmlTextNodeWs

r[cCst||�}|j|�|S)z�
    Creates a new <tag_name> Node and sets
    its content to 'text'. Then appends the
    created Node to 'parent' element if given.
    Returns the newly created Node.
    )r[r>)rYrS�parentrZrrr�appendXmlTextNode^s

r])rrF)rrF)r)r)TF)NF)F)EZ
__future__rr�	functools�re�	posixpath�sysZcalendarrZhashlibrZloggingrrrZxml.dom.minidomrCZxml.etree.ElementTreeZetreeZElementTreerKZ	ExitCodesr
Zdateutil.parserr�ImportError�stderr�write�flush�exitZurllibrZurllib.parser�	NameError�str�__all__rr>�
ValueError�exc�partialrL�compiler�	MULTILINErFrrrrrr%r(r)r*r.r/r9r<rDrJrOrQrRrWrXr[r]rrrr�<module>
s�