B
    è¹`B  ã               @   sŠ   d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm	Z	 d dl
mZmZ ejdfdd„ZG d	d
„ d
ƒZedkr†e eƒ p‚d ¡ dS )é    N)ÚITweens)Ú	bootstrapÚsetup_logging)Ú
parse_vars)ÚINGRESSÚMAINFc             C   s   t | |ƒ}| ¡ S )N)ÚPTweensCommandÚrun)ÚargvÚquietÚcommand© r   ú_/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pyramid/scripts/ptweens.pyÚmain   s    
r   c               @   sŠ   e Zd ZdZeje e¡ejdZ	e	j
ddddd e	j
dd	d
dd ejZeeƒZeeƒZddd„Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r   a{      Print all implicit and explicit tween objects used by a Pyramid
    application.  The handler output includes whether the system is using an
    explicit tweens ordering (will be true when the "pyramid.tweens"
    deployment setting is used) or an implicit tweens ordering (will be true
    when the "pyramid.tweens" deployment setting is *not* used).

    This command accepts one positional argument named "config_uri" which
    specifies the PasteDeploy config file to use for the interactive
    shell. The format is "inifile#name". If the name is left off, "main"
    will be assumed.  Example: "ptweens myapp.ini#main".

    )ÚdescriptionÚformatter_classÚ
config_uriú?Nz"The URI to the configuration file.)ÚnargsÚdefaultÚhelpÚconfig_varsÚ*r   zVariables required by the config file. For example, `http_port=%%(http_port)s` would expect `http_port=8080` to be passed here.Fc             C   s    || _ | j |dd … ¡| _d S )Né   )r   ÚparserÚ
parse_argsÚargs)Úselfr
   r   r   r   r   Ú__init__7   s    zPTweensCommand.__init__c             C   s"   ddl m} ||d}|j t¡S )Nr   )ÚConfigurator)Úregistry)Zpyramid.configr   r    ZqueryUtilityr   )r   r    r   Úconfigr   r   r   Ú_get_tweens;   s    
zPTweensCommand._get_tweensc             C   s   | j st|ƒ d S )N)r   Úprint)r   Úmsgr   r   r   ÚoutA   s    zPTweensCommand.outc             C   sˆ   d}|   |d ¡ |   |dtdƒ dtdƒ f ¡ |   |dtf ¡ x*t|ƒD ]\}\}}|   |||f ¡ qPW |   |dtf ¡ d S )Nz%-10s  %-65s)ÚPositionÚNameú-r&   r'   )r%   Úlenr   Ú	enumerater   )r   ÚchainÚfmtÚposÚnameÚ_r   r   r   Ú
show_chainE   s    "zPTweensCommand.show_chainc             C   s  | j js|  d¡ dS | j j}t| j jƒ}| j||d | j||d}|d }|  |¡}|d k	r|j}|rÎ|  d¡ |  d¡ |  d¡ |  d¡ |  	|j¡ |  d¡ |  d	¡ |  d¡ |  	| 
¡ ¡ n6|  d
¡ |  d¡ |  d¡ |  d¡ |  	| 
¡ ¡ dS )NzRequires a config file argumenté   )Zglobal_conf)Úoptionsr    zB"pyramid.tweens" config value set (explicitly ordered tweens used)Ú zExplicit Tween Chain (used)zImplicit Tween Chain (not used)zF"pyramid.tweens" config value NOT set (implicitly ordered tweens used)zImplicit Tween Chainr   )r   r   r%   r   r   r   r   r"   Úexplicitr0   Zimplicit)r   r   r   Úenvr    Ztweensr4   r   r   r   r	   N   s:    











zPTweensCommand.run)F)Ú__name__Ú
__module__Ú__qualname__r   ÚargparseÚArgumentParserÚtextwrapÚdedentÚRawDescriptionHelpFormatterr   Úadd_argumentÚsysÚstdoutÚstaticmethodr   r   r   r"   r%   r0   r	   r   r   r   r   r      s,   

	r   Ú__main__)r9   r?   r;   Zpyramid.interfacesr   Zpyramid.pasterr   r   Zpyramid.scripts.commonr   Zpyramid.tweensr   r   r
   r   r   r6   Úexitr   r   r   r   Ú<module>   s   c