관리-도구
편집 파일: atomic_helper.cpython-39.pyc
a ����'�Dg,����������������������@���s����d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlmZmZ�d�dlm Z m Z �dZe�e �Ze �d�dd���Ze �d�d d ���Zeddfd d�Zeddfdd�Zdd��Ze �d�dd���Zefdd�ZdS�)�����N)� b64decode� b64encode)�performance�utili���zBase64 decodingc�����������������C���s0���t�|��}z|�d�W�S��ty*���|�Y�S�0�dS�)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-8N)r����decode�UnicodeDecodeError)�sourceZdecoded��r ����;/usr/lib/python3.9/site-packages/cloudinit/atomic_helper.py�b64d���s ����r���zBase64 encodingc�����������������C���s"���t�|�t�s|��d�}�t|���d�S�)zdbase64 encode data :param source: a bytes or str to decode :return: base64 encoded str r���)� isinstance�bytes�encoder���r���)r ���r ���r ���r����b64e���s���� r����wbFc�����������������C���sD���t��d|������ �t|�||||�W��d����S�1�s60����Y��dS�)zCopen filename in mode omode, write content, set permissions to modezWriting N)r���ZTimed�_write_file)�filename�content�mode�omode� preserve_moder ���r ���r���� write_file*���s����r���c����������� ��� ���C���s����|r2zt��|��}t�|j�}W�n�ty0���Y�n0�d�}zrt�j�|��}t�|��t j |d|d�}t�d|�|j ||t|���|�|��|����t��|j |��t��|j |���W�n<�ty��}�z$|d�ur�t��|j ��|�W�Y�d�}~n d�}~0�0�d�S�)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���Z ensure_dir�tempfileZNamedTemporaryFile�LOG�debug�name�len�write�close�chmod�rename� Exception�unlink) r���r���r���r���r���Z file_statZtfr!����er ���r ���r���r���3���s6���� � r���c�����������������C���s6���zd��t|���W�S��ty0���d��t|����Y�S�0�dS�)z1Handler for types which aren't json serializable.z ci-b64:{0}z)Warning: redacted unserializable type {0}N)�formatr����AttributeError�type)Z_objr ���r ���r����json_serialize_defaultU���s����r1���zDumping jsonc�����������������C���s���t�j|�dddtd�S�)z%Return data in nicely formatted json.����T)�,z: )�indentZ sort_keysZ separators�default)�json�dumpsr1���)�datar ���r ���r���� json_dumps]���s�����r9���c�����������������C���s���t�|�t|�d�d|d�S�)N� �w)r���r���)r���r9���)r���r8���r���r ���r ���r���� write_jsoni���s���� �r<���)r6���Zloggingr���r���r"����base64r���r���Z cloudinitr���r���Z _DEF_PERMSZ getLogger�__name__r#���Ztimedr���r���r���r���r1���r9���r<���r ���r ���r ���r����<module>���s(��� � � "