B
    `#                 @   sL   d dl Z d dlZd dlZddgZG dd deZeeddZdd ZdS )    NDebugAppmake_debug_appc               @   s"   e Zd ZdZdddZdd ZdS )	r   z%The WSGI application used for testingNFc             C   s>   |r.t j|r.t|d}| | _|  n|| _|| _d S )Nrb)ospathisfileopenreadformclose	show_form)selfr
   r   fd r   X/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/webtest/debugapp.py__init__   s    


zDebugApp.__init__c             C   s\  t |}|jdkr<|jdkr<t jdd}| j|_|||S d|jkrNtdd|jkr|jd }t	j
s~t|t	js~|d}|jd	 | t|jd
d}g }| js4xBt| D ]2\}}	| |krt|	}	|td||	f  qW d|}
t|
t	js|
d}
|jrb|
t	d7 }
|
|j7 }
n.d}
x(|j D ]\}}	|
d||	f 7 }
qDW |d d dkr|jsd}
dtdfdtt|
fg}| js
xd|j D ]V\}}	|dr|tdd  }t|t	jrt|}| }||t|	f qW t  }||_ |j!"| |jdkrRt|
t	jrL|
d|_n|
|_|||S )Nz
/form.htmlGETz	text/html)content_typeerrorzException requestedZerrorlogutf8zwsgi.errorsstatusz200 OKz%s: %s
 latin1z-- Body ----------
z%s=%s
   )Z204Z304zContent-Typez
text/plainzContent-Lengthzheader-HEAD)#webobRequestZ	path_infomethodResponser
   bodyr   	ExceptionsixPY3
isinstancebinary_typeencodeenvironwritestrgetr   sorteditemsupperreprappendjoincontent_lengthbPOSTlen
startswith	text_typetitler   headersupdate)r   r&   Zstart_responsereqresplogr   partsnamevaluer   r7   header_namer   r   r   __call__   s`    








zDebugApp.__call__)NF)__name__
__module____qualname____doc__r   r@   r   r   r   r   r   
   s   
	z<html><body>
<form action="/form-submit" method="POST">
    <input type="text" name="name">
    <input type="submit" name="submit" value="Submit!">
</form></body></html>)r
   c             K   s
   t f |S )z~An application that displays the request environment, and does
    nothing else (useful for debugging and test purposes).
    )r   )Zglobal_confZ
local_confr   r   r   r   ]   s    )	r   r!   r   __all__objectr   r1   Z	debug_appr   r   r   r   r   <module>   s   L
