a
    K56aý
  ã                   @   s¦   d dl Z d dlZd dlZddd„Zeƒ Ze je jB e jB Ze	e dƒrNee j
O Ze	e dƒrbee jO ZeZe	e dƒrzee jO Zdd	d
„Zdeddddfdd„Zdd„ ZdS )é    Nc                 C   s<   dg}| r|  | ¡ |r"|  |¡ |  t d¡¡ d |¡S )NZ	reportbugz%Y%m%d%H%M%S-ú-)ÚappendÚtimeÚstrftimeÚjoin)ÚpackageZextraZplist© r   ú5/usr/lib/python3/dist-packages/reportbug/tempfiles.pyÚtempfile_prefix   s    

r
   ÚO_NOINHERITÚ
O_NOFOLLOWÚO_BINARYúw+béÿÿÿÿc                 C   sT   d|v rt  | td¡}nt  | td¡}zt  |||¡W S    t  |¡ ‚ Y n0 d S )NÚbi€  )ÚosÚopenÚ_bin_openflagsÚ_text_openflagsÚfdopenÚclose)ÚfilenameÚmodeÚbufsizeÚfdr   r   r	   Úopen_write_safe6   s    
r   Ú Tzw+c           	      C   s*   t  | |||¡\}}t |||¡}||fS )N)ÚtempfileZmkstempr   r   )	ÚsuffixÚprefixÚdirÚtextr   r   Zfhr   r   r   r   r	   ÚTempFileE   s    r"   c                 C   s   t j | ¡rt  | ¡ dS )zé Clean up a temporary file.

        :parameters:
          `temp_filename`
            Full filename of the file to clean up.

        :return value:
            None

        Removes (unlinks) the named file if it exists.

        N)r   ÚpathÚexistsÚunlink)Ztemp_filenamer   r   r	   Úcleanup_temp_fileL   s    r&   )NN)r   r   )r   r   r   r
   ÚtemplateÚO_RDWRÚO_CREATÚO_EXCLr   Úhasattrr   r   r   r   r   r"   r&   r   r   r   r	   Ú<module>   s"   








ÿ
