o
    hW                  	   @   s   d dl Z d dlZd dlmZ d dlZd dlZd dlmZ d dlmZ dd Z	dd Z
d	d
 Z		ddeeef dededefddZdddZdd Zdd Ze jdddZdS )    N)Path)Union)mockc                 C   s   t dd|  S )Nz	[\s\r\n]+ )resubstripresult r   h/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/mako/testing/helpers.pyflatten_result
   s   r   c              	   C   s    dd t dt dd| D S )Nc                 S   s    g | ]}|  d kr|  qS  r   .0xr   r   r   
<listcomp>   s
    z result_lines.<locals>.<listcomp>\r?\nz +r   )r   splitr   r	   r   r   r   result_lines   s   r   c                 C   s   dd t d| D S )Nc                 S   s   g | ]
}|  d kr|qS r   r   r   r   r   r   r      s    z$result_raw_lines.<locals>.<listcomp>r   )r   r   r	   r   r   r   result_raw_lines   s   r   TFfilespecmake_absolutecheck_existsreturnc                 C   s6   t | }|r|j|d}|r| std|  |S )N)strictzNo file or directory at )r   resolveexistsFileNotFoundError)r   r   r   pathr   r   r   	make_path   s   r"   c                 C   sH   t  }|rt t}| |   W d    d S 1 sw   Y  d S )N)
contextlibnullcontextsuppressr    unlink)r!   
missing_okcmr   r   r   _unlink_path'   s   

"r)   c                 C   s&   t | }t|dd |jdd |S )NT)r'   )exist_ok)pathlibr   r)   mkdir)pathspecr!   r   r   r   replace_file_with_dir1   s   
r.   c                 C   s:   t | d}|d W d    | S 1 sw   Y  | S )Nwz*
i am an artificial template just for you
)openwrite)r   fr   r   r   file_with_template_code8   s   
r3      c                 c   sP    t   | d  }td}||j _d V  W d    d S 1 s!w   Y  d S )Ni  zmako.codegen.time)timer   patchreturn_value)hoursrewoundcodegen_timer   r   r   rewind_compile_timeB   s   "r;   )TF)F)r4   )r#   r+   r   r   r5   typingr   unittestr   r   r   r   strboolr"   r)   r.   r3   contextmanagerr;   r   r   r   r   <module>   s4    




