B
    `                 @   s<  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZdd Z	dd Z
dd Zdd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Ze  dd Zejdde jd d!e jd"d!d"d#d$e jd%d&d'd(e jd)d*d+d(e jd,d-d.d(e jd/d0d1d(e jd2d3d4d(d5d6 ZdS )7    Nc             C   s*   |   r&td|  tjd td d S )NzAlready exists: )file   )existsprintsysstderrexit)target r
   [/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pgwui_develop/pgwui.pyvalidate_target!   s    r   c             C   s   | d| d S )NTEMPLATE
short_name)replace)settingsnamer
   r
   r   transform_name'   s    r   c             C   s   | j }|dkp|dkS )Nz.makz.makish)suffix)entryr   r
   r
   r   
renderable+   s    r   c             C   s.   t |s|jdkrt| |jS t| |jS d S )Nz.ish)r   r   r   stemr   )r   r   r
   r
   r   transform_file_name0   s    r   c             C   s\   yt jj|djf | S    td| tjd tt j  tjd t	d Y nX d S )N)textzError rendering: )r   r   )
makotemplateTemplaterenderr   r   r   
exceptionsZtext_error_templater   )r   r   contentr
   r
   r   r   7   s    r   c             C   s   |  dd ddS )Nz$ {z${z %% %)r   )r   r
   r
   r   make_renderable@   s    r    c             C   s2   |  }t|r.t| ||}|jdkr.t|}|S )Nz.makish)	read_textr   r   r   r    )r   r   r   r
   r
   r   produce_contentD   s    
r"   c             C   s(   t | t|| }|t|| d S )N)pathlibPathr   
write_textr"   )r	   r   r   r   r
   r
   r   deliver_fileM   s    r&   c          	   C   sR   t | t||j }|  t| }x|D ]}t||| q0W W d Q R X d S )N)r#   r$   r   r   mkdirosscandirdeliver_entry)r	   r   r   direntriesZsubentryr
   r
   r   deliver_dirR   s
    
r-   c             C   s,   |  rt| || nt| |t| d S )N)is_dirr-   r&   r#   r$   )r	   r   r   r
   r
   r   r*   Z   s    r*   c          	   C   s<   |    t| }x|D ]}t| || qW W d Q R X d S )N)r'   r(   r)   r*   )r	   r   template_pathr,   r   r
   r
   r   traverse_templatesa   s    
r0   c          	   C   sB   t  0}t| ttd}t| || t  W d Q R X d S )Nr   )tempfileTemporaryDirectorypkg_resourcesset_extraction_pathresource_filename__name__r0   cleanup_resources)r	   r   Ztmpdirr/   r
   r
   r   deliver_targeth   s
    

r8   c             C   s   | d krdS | S )N.r
   )pathr
   r
   r   path_or_defaultp   s    r;   c               C   s   d S )Nr
   r
   r
   r
   r   pgwuiv   s    r<   ax  

When PATH is omitted it defaults to the current directory.

When an option is not supplied its value is prompted for.


component
    The name of the component, usually starting with 'PGWUI_'.
    Case is significant.  Generally, the first letter of each word
    is capitalized.


short-name
  The name of the component without the "PGWUI_" prefix, in lower case.
  Used as the default route (with a "/" prepended) and in variable
  names, etc.


summary
    Short description to go into setup.py.  Should conform to the
    Python Packaging Authority Specifications for a summary:
    https://packaging.python.org/specifications/core-metadata/#summary


author-name
   The name of the author.
   https://packaging.python.org/specifications/core-metadata/#author


author-email
   The email of the author.
   https://packaging.python.org/specifications/core-metadata/#author-email)epilogr:   FT)r   Z	file_okayZdir_okay)requiredtypez--componentz8Name of new component, in mixed case, with PGWUI_ prefixz$name of new component, in mixed case)prompthelpz--short-namez5Lower case component name, with PGWUI_ prefix removedz4lower case component name with PGWUI_ prefix removedz	--summaryz"Short description of new componentz"short description of new componentz--author-namezName of authorzname of authorz--author-emailzEmail of authorzemail of authorc             C   s2   t t| |}t| t||||||d dS )zProduce, in the PATH directory, a directory of code containing
    the basic elements of a PGWUI component.  PGWUI components are packaged
    as independent Python distributions (packages).
    )	componentr   summaryauthor_nameauthor_emailN)r#   r$   r;   r   r8   )r:   rB   r   rC   rD   rE   r	   r
   r
   r   cookiecutter{   s    @rF   )ZclickZmako.exceptionsr   Zmako.templater(   r#   r3   r   r1   r   r   r   r   r   r    r"   r&   r-   r*   r0   r8   r;   groupr<   commandargumentr$   optionrF   r
   r
   r
   r   <module>   s^   		!