Ë
    x[h,  ã                   ó0  — d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dlm	Z	m
Z
 dZ ej                  e«      Z e	j                  d«      d„ «       Z e	j                  d«      d„ «       Zed	d
fd„Zed	d
fd„Zd„ Z e	j                  d«      d„ «       Zefd„Zy)é    N)Ú	b64decodeÚ	b64encode)ÚperformanceÚutili¤  zBase64 decodingc                 ó^   — t        | «      }	 |j                  d«      S # t        $ r |cY S w xY w)z‹base64 decode data

    :param source: a bytes or str to decode
    :return: base64 as a decoded str if utf-8 encoded, otherwise bytes
    úutf-8)r   ÚdecodeÚUnicodeDecodeError)ÚsourceÚdecodeds     ú9/usr/lib/python3/dist-packages/cloudinit/atomic_helper.pyÚb64dr      s6   € ô ˜Ó€GðØ�~‰~˜gÓ&Ð&øÜò ØŠðús   � ž,«,zBase64 encodingc                 óx   — t        | t        «      s| j                  d«      } t        | «      j	                  d«      S )zdbase64 encode data

    :param source: a bytes or str to decode
    :return: base64 encoded str
    r   )Ú
isinstanceÚbytesÚencoder   r	   )r   s    r   Úb64er      s2   € ô �fœeÔ$Ø—‘˜wÓ'ˆÜ�VÓ×#Ñ# GÓ,Ð,ó    ÚwbFc                 ó|   — t        j                  d| › �«      5  t        | ||||«      cddd«       S # 1 sw Y   yxY w)zCopen filename in mode omode, write content, set permissions to modezWriting N)r   ÚTimedÚ_write_file)ÚfilenameÚcontentÚmodeÚomodeÚpreserve_modes        r   Ú
write_filer   *   sB   € ô
 
×	Ñ	˜X h ZÐ0Ó	1ñ JÜ˜8 W¨d°E¸=ÓI÷J÷ Jò Jús   ™2²;c           
      ó²  — |r5	 t        j                  | «      }t        j                  |j                  «      }d }	 t         j
                  j                  | «      }t        j                  |«       t        j                  |d|¬«      }t        j                  d| |j                  ||t        |«      «       |j                  |«       |j!                  «        t        j"                  |j                  |«       t        j$                  |j                  | «       y # t        $ r Y Œéw xY w# t&        $ r(}|�t        j(                  |j                  «       |‚d }~ww xY w)NF)ÚdirÚdeleter   zOAtomically writing to file %s (via temporary file %s) - %s: [%o] %d bytes/chars)ÚosÚstatÚS_IMODEÚst_modeÚOSErrorÚpathÚdirnamer   Ú
ensure_dirÚtempfileÚNamedTemporaryFileÚLOGÚdebugÚnameÚlenÚwriteÚcloseÚchmodÚrenameÚ	ExceptionÚunlink)	r   r   r   r   r   Ú	file_statÚtfr(   Úes	            r   r   r   3   s  € ñ ð	ÜŸ™ Ó)ˆIÜ—<‘< 	× 1Ñ 1Ó2ˆDð 
€BðÜ—'‘'—/‘/ (Ó+ˆÜ�‰˜Ô Ü×(Ñ(¨W¸UÈÔOˆÜ�	‰	ðàØ�G‰GØØÜ�‹Lô	
ð 	�‰�ÔØ
�‰Œ
Ü
�‰�—‘˜$ÔÜ
�	‰	�"—'‘'˜8Õ$øô) ò 	Ùð	ûô* ò Øˆ>Ü�I‰I�b—g‘gÔØˆûðús)   „4D »CD% Ä	D"Ä!D"Ä%	EÄ.#EÅEc                 óŠ   — 	 dj                  t        | «      «      S # t        $ r dj                  t        | «      «      cY S w xY w)z1Handler for types which aren't json serializable.z
ci-b64:{0}z)Warning: redacted unserializable type {0})Úformatr   ÚAttributeErrorÚtype)Ú_objs    r   Újson_serialize_defaultr>   U   sC   € ðNØ×"Ñ"¤4¨£:Ó.Ð.øÜò NØ:×AÑAÄ$ÀtÃ*ÓMÒMðNús   ‚ œ#AÁAzDumping jsonc                 ó>   — t        j                  | dddt        ¬«      S )z%Return data in nicely formatted json.é   T)ú,z: )ÚindentÚ	sort_keysÚ
separatorsÚdefault)ÚjsonÚdumpsr>   )Údatas    r   Ú
json_dumpsrI   ]   s$   € ô �:‰:ØØØØÜ&ôð r   c                 ó8   — t        | t        |«      dz   d|¬«      S )Nú
Úw)r   r   )r   rI   )r   rH   r   s      r   Ú
write_jsonrM   i   s%   € äØÜ�4Ó˜4ÑØØô	ð r   )rF   Úloggingr"   r#   r*   Úbase64r   r   Ú	cloudinitr   r   Ú
_DEF_PERMSÚ	getLoggerÚ__name__r,   Útimedr   r   r   r   r>   rI   rM   © r   r   ú<module>rV      sÆ   ðó Û Û 	Û Û ß 'ç 'à€
Ø€g×Ñ˜Ó!€ð €×ÑÐ$Ó%ñ
ó &ð
ð €×ÑÐ$Ó%ñ-ó &ð-ð '¨dÀ%óJð '¨dÀ%óòDNð €×Ñ�>Ó"ñó #ðð %/ô r   