
"T`T                 @   sy   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d Z e j e  Z e d d d d  Z	 e d d  Z
 d S)	    Ni  wbFc             C   s$  | r@ y% t  j |   } t j | j  } Wn t k
 r? Yn Xd  } y t j d t  j j |   d d d |  } t	 j
 d |  | j | | t |   | j |  | j   t  j | j |  t  j | j |   WnG t k
 r} z' | d  k	 rt  j | j  |  WYd  d  } ~ Xn Xd  S)NdirdeleteFmodezOAtomically writing to file %s (via temporary file %s) - %s: [%o] %d bytes/chars)osstatS_IMODEst_modeOSErrortempfileNamedTemporaryFilepathdirnameLOGdebugnamelenwriteclosechmodrename	Exceptionunlink)filenamecontentr   omodepreserve_mode	file_stattfe r    9/usr/lib/python3/dist-packages/cloudinit/atomic_helper.py
write_file   s*    
r"   c             C   s2   t  |  t j | d d d d d d d d | S)	Nindent   	sort_keysT
r   wr   )r"   jsondumps)r   datar   r    r    r!   
write_json*   s    "r+   )r(   loggingr   r   r   Z
_DEF_PERMS	getLogger__name__r   r"   r+   r    r    r    r!   <module>   s   