MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyo
�
d�bc@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	j
jZddlZddl
mZd�Zdd�Zdd�Zd�Zdd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#dd�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d d!�Z,d"�Z-d#�Z.d$�Z/d%�Z0d&�Z1d'd(�Z2d)�Z3dS(*i����N(tustrcCs|jd�}tj|�S(s(
    Parse xml document from string
    sutf-8(tencodetminidomtparseString(txml_text((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt	parse_doc"scCs=|dkrgS|dkr)|j|�S|j||�SdS(s=
    Get all nodes by tag and namespace under Node root.
    N(tNonetgetElementsByTagNametgetElementsByTagNameNS(trootttagt	namespace((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytfindall,s

cCsCt||d|�}|dk	r;t|�dkr;|dSdSdS(s>
    Get first node by tag and namespace under Node root.
    RiiN(RRtlen(R	R
Rtnodes((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytfind9scCsA|dkrdSx*|jD]}|j|jkr|jSqWdS(s
    Get node text
    N(Rt
childNodestnodeTypet	TEXT_NODEtdata(tnodetchild((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytgettextDscCst||d|�}t|�S(s@
    Get text of node by tag and namespace under Node root.
    R(RR(R	R
RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytfindtextQscCs!|dk	r|j|�SdSdS(s#
    Get attribute of xml node
    N(RtgetAttribute(Rt	attr_name((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt	getattribYs
cCs7d}x*|D]"}|d>t|||�B}q
W|S(s*
    Unpack bytes into python values.
    ii(t
str_to_ord(tbuftoffsettvalue_rangetresultti((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytunpackcs
 cCs&t||tt|ddd���S(s8
    Unpack little endian bytes into python values.
    ii����(R!tlisttrange(RRtlength((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytunpack_little_endianmscCst||ttd|���S(s5
    Unpack big endian bytes into python values.
    i(R!R"R#(RRR$((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytunpack_big_endiantscCs5djg||||!D]}dt|�^q�S(s-
    Dump range of buf in formatted hex.
    ts%02X(tjoinR(RRR$tchar((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt	hex_dump3{scCst|dt|��S(s$
    Dump buf in formatted hex.
    i(R*R
(R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt	hex_dump2�scCs||ko|kSS(s4
    Return True if 'a' in 'low' <= a <= 'high'
    ((tatlowthigh((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytis_in_range�scCsXt|td�td��pWt|td�td��pWt|td�td��S(s2
    Return True if character is displayable.
    tAtZR,tzt0t9(R/R(tch((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytis_printable�scCs�|dkrt|�}nd}x�td|�D]�}|ddkrX|d|7}n||}t|�tkr�t|jd��}n|d|7}|d@dkr�|d	7}n|d
ddks�|d
|kr1|}xI|d
ddkr,|d7}|d@dkr|d	7}n|d
7}q�W|d	7}x�t||d|d
�D]e}||}t|�tkr�t|jd��}nd}t|�r�t|�}n||7}qSW|d
|kr�|d
7}q�q1q1W|S(s;
    Return Hex formated dump of a 'buffer' of 'size'.
    iR'is%06X: tlatin1s%02X iit is   t.s
(	R
R#ttypetstrtordtdecodeRR6tchr(tbuffertsizeRR tbytetjtk((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pythex_dump�s>

$


"
cCsCt|�td�ks0t|�td�kr?t|�}n|S(sl
    Allows indexing into a string or an array of integers transparently.
    Generic utility function.
    R'u(R:R<(R,((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyR�s0cCsFx?t|||�D]*}t||�t||�krtSqWtS(N(R#RtFalsetTrue(R,tbtstartR$R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt
compare_bytes�s cCs0d|d?d@|d?d@|d?d@|d@fS(s$
    Build DHCP request string.
    s%u.%u.%u.%uii�ii((R,((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytint_to_ip4_addr�sc	Cs`d}xStdt|�d�D]8}|tjdt||d|dd!d��7}q W|S(s8
    Return hex string packed into a binary struct.
    R'iitBi(R#R
tstructtpacktint(R,RGtc((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pythexstr_to_bytearray�s 6cCst}d}|}x�tdt|��D]�}||j|�rl||krldj||�||<t}q(||j�jd�r(||j�jd�r�|}q�||kr�|}q�q(q(W|s�||kr�|}n|j|dj||��n|S(Ni����is{0} {1}tmatchs	match all(RER#R
t
startswithtformatRFtlowertinsert(tconfigtnametvaltfoundtno_matchtmatch_startR ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytset_ssh_config�s"			cCs�t}|d}t|�}dj||�}xDttd|��D]-}||j|�rD|||<t}PqDqDW|r�|j|d|�ndS(Nt=s	{0}="{1}"ii(RFR
RStreversedR#RRRERU(RVRWRXtnotfoundt	nameEqualR$ttextR ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytset_ini_config�s

R'cCsSd}|dk	rOx:|D]/}t|�dkr>||7}q||7}qWn|S(NR'i�(RR(tincomingtreplace_chartoutgoingRO((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytreplace_non_ascii
s

cCsrt|�rnt|�dkrnt|d�dkrnt|d�dkrnt|d�dkrn|d}n|S(s[
    bom is comprised of a sequence of three chars,0xef, 0xbb, 0xbf, in case of utf-8.
    iii�ii(tis_str_none_or_whitespaceR
R(RO((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt
remove_boms

cs|tjtj�dj�fd�t|�D��}dj||�}tjddkrl|jd�}nt	j	||�S(NR'c3s|]}tj��VqdS(N(trandomtchoice(t.0t_(t
collection(sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pys	<genexpr>$ss${0}${1}iisutf-8(
tstringt
ascii_letterstdigitsR(R#RStsystversion_infoRtcrypt(tpasswordtcrypt_idtsalt_lentsalt((RmsI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytgen_password_hash"s%cCs=d}x0|jd�D]}d|kr||7}qqW|S(NR's
s----(tsplit(tpem_strtbase64_bytestline((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytget_bytes_from_pem,s
cCsZddlm}|dkrDtjtjt|d���jd�Stjtj|��S(sT
    Compress a string, and return the base64 encoded result of the compression.

    This method returns a string instead of a byte array.  It is expected
    that this method is called to compress smallish strings, not to compress
    the contents of a file. The output of this method is suitable for
    embedding in log statements.
    i����(tPY_VERSION_MAJORisutf-8(tazurelinuxagent.common.versionR~tbase64t	b64encodetzlibtcompresstbytesR=(tsR~((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyR�4s	(cCsHddlm}|dkr;tjt|d��jd�Stj|�S(Ni����(R~isutf-8(RR~R�R�R�R=(R�R~((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyR�CscCs?ddlm}|dkr2tj|�jd�Stj|�S(Ni����(R~isutf-8(RR~R�t	b64decodeR=(R�R~((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyR�JscCsOddl}ddlm}|d dkrB|j|jd��S|j|�S(Ni����(t
PY_VERSIONiisutf-8(ii(tshlexRR�RyR(R�R�R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytsafe_shlex_splitQs
icCsit|�|}|dkr;d|t|�||}ndjttjdj|�|tj���S(NiR3R's[a-f0-9]{{{0}}}(R
R(R^treRRSt
IGNORECASE(R�twidthtr((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytswap_hexstringYs	cCs=d}t|�s9ddl}|j|jd��}n|S(s=
    Parse json string and return a resulting dictionary
    i����Ns 	
(Rtis_str_emptytjsontloadstrstrip(tjson_strRR�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt
parse_jsones
cCs(|dkp't|�dkp'|j�S(Ni(RR
tisspace(R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyRgrscCst|�pt|jd��S(Ns 	
(RgR�(R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyR�vscCs:tj�}x!|D]}|j|j��qW|j�S(s�
    Compute a cryptographic hash of a list of strings

    :param string_list: The strings to be hashed
    :return: The cryptographic hash (digest) of the strings in the order provided
    (thashlibtsha1tupdateRtdigest(tstring_listt	sha1_hashtitem((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pythash_stringszs
cCs�idd6dd6d	d6dd6}||krLtdj|j����nyt|�}Wntk
r{td��nXt|||�S(NiR�it	kilobytest	megabytest	gigabytessUnit must be one of {0}s$Value must be convertible to a floatiii@(t
ValueErrorRStkeystfloatt	TypeErrorRN(tunittvaluetunits((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytformat_memory_value�s"
sutf-8cCs�ddlm}|dks.t|�tkr2|S|dkr�y*t|t�r]|j|�St|�SWq�tk
r�t|�SXnt|d|�S(s�
    This function takes the string and converts it into the corresponding encoded ustr if its not already a ustr.
    The encoding is utf-8 by default if not specified.
    Note: ustr() is a unicode object for Py2 and a str object for Py3.
    :param s: The string to convert to ustr
    :param encoding: Encoding to use. Utf-8 by default
    :return: Returns the corresponding ustr string. Returns None if input is None.
    i����(R~itencodingN(	RR~RR:Rt
isinstanceR�R=t	Exception(R�R�R~((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pytstr_to_encoded_ustr�s

cCs�d}tjddkr1tj�\}}}n	|j}t|�d}|dksutjddkr�||kr�|d7}n1|djtjdt	|�d|d|��7}|S(	Niis
s[Traceback not available]R'tetypeR�ttb(
RRqRrtexc_infot
__traceback__RR(t	tracebacktformat_exceptionR:(t	exceptionteRlR�tmsg((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyR��s	+
1(4R�RsR�RiR�RnRLRqR�txml.dom.minidomtdomRR�tazurelinuxagent.common.futureRRRRRRRRR!R%R&R*R+R/R6RDRRIRJRPR\RbRfRhRxR}R�R�R�R�R�R�RgR�R�R�R�R�(((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/utils/textutil.pyt<module>s^	

	
	
	
								%