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__/BaseUtils.cpython-39.pyc
a

�9pe�(�@sNddlmZmZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZddlZddlmmZddlmZzddlZWn2ey�ej�d�ej��e�e�Yn0zdd	lmZWney�dd	l mZYn0ze!Z!Wne"�ye#Z!Yn0gZ$eZ%e$�&d
�z
e
�Wn\e'�y�Z(zBze
dd�ej)e
dd�Z
Wne*�yve(�Yn0WYdZ([(n
dZ([(00e$�&d
�e�+d�Z,e�+dej-�Z.dd�Z/e$�&d�dd�Z0e$�&d�dd�Z1e$�&d�dd�Z2e$�&d�dd�Z3e$�&d�d?dd�Z4e$�&d�d@dd�Z5e$�&d�dAd d!�Z6e$�&d!�dBd"d#�Z7e$�&d#�dCd%d&�Z8e$�&d&�dDd'd(�Z9e$�&d(�dEd)d*�Z:e$�&d*�d+d,�Z;e$�&d,�d-d.�Z<e$�&d.�d/d0�Z=e$�&d0�d1d2�Z>e$�&d2�d3d4�Z?e$�&d4�d5d6�Z@e$�&d6�d7d8�ZAe$�&d8�d9d:�ZBe$�&d:�d;d<�ZCe$�&d<�d=d>�ZDe$�&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?://[^'"]+)['"]cCst�d|�}tjj|dd�S)Nz.000T�Zfuzzy)�RE_S3_DATESTRING�sub�dateutil�parser�parse��date�r�0/usr/lib/python3.9/site-packages/S3/BaseUtils.py�dateS3toPythonXsrcCstt|����S�N)rr�utctimetuplerrrr�dateS3toUnix_srcCstjj|dd�S)zW
    Convert a string formatted like '2020-06-27T15:56:34Z' into a python datetime
    Tr
)rrrrrrr�dateRFC822toPythonesrcCstt|����Sr)rrrrrrr�dateRFC822toUnixmsrcCstjj|dd�}|�d�S)NTr
z%Y-%m-%d %H:%M)rrr�strftime)Zs3timestampZdate_objrrr�formatDateTimersr�UTF-8�replacecCsVt|�tkr|S|s$td||f�zt|||�WStyPtd|��Yn0dS)z<
    Convert 'string' to Unicode or raise an exception.
    zUnicodising %r using %sz Conversion to unicode failed: %rN)�type�unicoder�UnicodeDecodeError��string�encoding�errorsZsilentrrr�base_unicodise{sr(cCsVt|�tkr|S|s$td||f�z|�||�WStyPtd|��Yn0dS)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)r!r"r�encode�UnicodeEncodeErrorr$rrr�base_deunicodise�sr+cCst|d|d�S)zE
    Convert S3 UTF-8 'string' to Unicode or raise an exception.
    rT)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.
    rT)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.
    �~�~/��safe)r.rr-)ZparamZquote_backslashes�unicode_outputZ
safe_charsrrr�s3_quote�s

r4cCsHt|�}|dkr|St|dd�}td||f�|r<t|�St|�SdS)NZverbatimr0r1zString '%s' encoded to '%s')r.rrr-)r%Zurlencoding_moder3Zencodedrrr�base_urlencode_string�sr5cCs�d}d}|D]X}t|�}|dkrB|dttd�|�7}|d7}q|dkr\|d7}|d7}q||7}q|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


r?cCs~g}|D]p}i}|D]T}t|j�}t|�r:t|g�||<q|�d|j�}|dur`t|�||<qd||<q|r|�|�q|S�Nz.//%s)r-�tag�len�
parseNodes�findtext�append)�nodesZretval�nodeZretval_item�child�nameZ
found_textrrrrC�s

rCcCstjj�|�}|��Sr)�xmlZdomZminidomZparseStringZtoprettyxml)ZxmlstrZ	xmlparserrrr�getPrettyFromXml	srKcCs4t�|�}|r(|�d�}t�d|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)rJZxmlns_match�xmlnsrrr�stripNameSpaces

rQc
Csltt|��\}}zt�|�}|r*||jd<|WStyf}z td|�t|��WYd}~n
d}~00dS)NrPzError parsing xml: %s)rQr.�ETZ
fromstringZattrib�	Exceptionr)rJrP�tree�errr�getTreeFromXmls


rVcCst|�}|�d|�}t|�Sr@)rV�findallrC)rJrGrTrFrrr�getListFromXml-srXcCs�i}|D]~}t|�rt|�}n|jdur2t|j�nd}t|j�}||vrzt||�tksf||g||<||�|ptd�q|p�d||<q|S)Nr6)rB�getDictFromTree�textr-rAr!�listrE)rTZret_dictrHZcontentZ	child_tagrrrrY4s

rYcCsNt|�}|j�|�r,|jdur(t|j�SdS|�|�}|durFt|�SdSdSr)rVrA�endswithrZr-rD)rJZxpathrT�resultrrr�getTextFromXmlGs

r^cCs t|�}|jdurt|j�SdSr)rVrAr-)rJrTrrr�getRootTagNameQsr_cCst�|�}t|�|_|Sr)rRZElementr-rZ)�tag_namerZ�elrrr�xmlTextNodeWs

rbcCst||�}|�|�|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.
    )rbrE)r`rZ�parentrarrr�appendXmlTextNode^s

rd)rr F)rr F)r )r )TF)NF)F)EZ
__future__rr�	functools�re�	posixpath�sysZcalendarrZhashlibrZloggingrrrZxml.dom.minidomrJZxml.etree.ElementTreeZetreeZElementTreerRZ	ExitCodesr
Zdateutil.parserr�ImportError�stderr�write�flush�exitZurllibr�urllib.parser"�	NameError�str�__all__rrE�
ValueError�exc�partialrS�compiler�	MULTILINErMrrrrrr(r+r-r.r4r5r?rCrKrQrVrXrYr^r_rbrdrrrr�<module>
s�