
y X"                 @   s]  d  d l  Z  d  d l m Z e  j d d  d1 k Z e  j d2 k Z d d   Z d d	   Z e j r d
 d   Z	 d d   Z
 d  d l Z d d   Z e j j Z n- d d   Z	 d d   Z
 d  d l Z e j Z d d   Z e rXd  d l Z e j Z e j Z e j Z e j Z e j Z e j Z e j Z e j Z e j Z e j Z d d   Z nd  d l Z d  d l  Z  d  d l! Z! Gd d   d e"  Z Gd d   d e"  Z Gd d   d e"  Z Gd d   d e"  Z Gd d   d e"  Z Gd  d!   d! e"  Z Gd" d#   d# e"  Z Gd$ d%   d% e"  Z Gd& d'   d' e"  Z Gd( d)   d) e"  Z i e e j# 6e e j$ 6e e j% 6e e j& 6e e j' 6e e j( 6e e j) 6e e j* 6e e j+ 6e e j, 6e e j- 6e e j. 6e e j/ 6e e j0 6e e j1 6Z2 d* d   Z e rId  d+ l3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 d, d- d. d/  Z: n d  d0 l; m: Z: d S)3    N)six         c             C   s   d d l  m } d d l m } m } m } m } | |   } | |  } | | |   d } y( | | | g  \ }	 }
 \ } } } Wn' t k
 r t d j	 |    Yn X| |	 |
 f S)zLReturn True if the extension is .pyc, False if .py
    and None if otherwiser   )find_module)realpathdirnamebasenamesplitextz4Cannot find config file. Path maybe incorrect! : {0})
impr   os.pathr   r   r	   r
   ImportErrorIOErrorformat)fnamer   r   r   r	   r
   filepathdirpathmodule_namefileobjfullpath_Zpytype r   @/home/ubuntu/projects/ifolica/build/gunicorn/gunicorn/_compat.py_check_if_pyc	   s    "(	r   c       	      C   s   d d l  m } m } t |   \ } } } z | j   } Wd | j   X| | k r} d d l } | j | d d   } n6 | | k r t | | d  } n t	 d j
 |    | S)z. Returns the code object, given a python file r   )PY_COMPILED	PY_SOURCEN   execz!Input file is unknown format: {0})r   r   r   r   readclosemarshalloadscompile	Exceptionr   )	Zpyfiler   r   resultr   r   datar    Zcode_objr   r   r   _get_codeobj   s    r&   c             G   sO   |  j  d  r t |   } n! t t |  d  j   |  d  } t j | |  S)Nz.pycrbr   )endswithr&   r"   openr   r   exec_)r   argscoder   r   r   	execfile_C   s    !r-   c             C   s#   t  |  t j  r |  St |  d  S)Nlatin1)
isinstancer   	text_typestr)br   r   r   bytes_to_strJ   s    r3   c             C   s   t  |   j d  S)Nzlatin-1)_unquote_to_bytesdecode)stringr   r   r   unquote_to_wsgi_strQ   s    r7   c             G   s2   |  j  d  r% t j t |   |  St |  |  S)z@ Overriding PY2 execfile() implementation to support .pyc files z.pyc)r(   r   r*   r&   execfile)r   r+   r   r   r   r-   W   s    c             C   s    t  |  t  r |  j d  S|  S)Nzutf-8)r/   unicodeencode)sr   r   r   r3   ]   s    c             C   sb   | | k r d  S| | } | |  j    } t j | | t |  d  rM |  j n t j   d  d  S)N__traceback__r   )r+   r   reraisehasattrr<   sysexc_info)excmappingkeyZnew_err_clsZnew_errr   r   r   _wrap_errorg   s    
rD   c             O   s   |  | |   S)Nr   )funcr+   kwr   r   r   
wrap_error   s    rG   c               @   s   e  Z d  Z d S)BlockingIOErrorN)__name__
__module____qualname__r   r   r   r   rH      s   rH   c               @   s   e  Z d  Z d S)BrokenPipeErrorN)rI   rJ   rK   r   r   r   r   rL      s   rL   c               @   s   e  Z d  Z d S)ChildProcessErrorN)rI   rJ   rK   r   r   r   r   rM      s   rM   c               @   s   e  Z d  Z d S)ConnectionRefusedErrorN)rI   rJ   rK   r   r   r   r   rN      s   rN   c               @   s   e  Z d  Z d S)InterruptedErrorN)rI   rJ   rK   r   r   r   r   rO      s   rO   c               @   s   e  Z d  Z d S)ConnectionResetErrorN)rI   rJ   rK   r   r   r   r   rP      s   rP   c               @   s   e  Z d  Z d S)ConnectionAbortedErrorN)rI   rJ   rK   r   r   r   r   rQ      s   rQ   c               @   s   e  Z d  Z d S)PermissionErrorN)rI   rJ   rK   r   r   r   r   rR      s   rR   c               @   s   e  Z d  Z d S)FileNotFoundErrorN)rI   rJ   rK   r   r   r   r   rS      s   rS   c               @   s   e  Z d  Z d S)ProcessLookupErrorN)rI   rJ   rK   r   r   r   r   rT      s   rT   c             O   s   y |  | |   SWn t  j t t f k
 r } z@ t | d  rW t | t | j  n  t | t | j    WYd d } ~ XnN t	 j k
 r } z+ | j
 r t | t | j
 d  n    WYd d } ~ Xn Xd S)z
        Wrap socket.error, IOError, OSError, select.error to raise new specialized
        exceptions of Python 3.3 like InterruptedError (PEP 3151).
        winerrorNr   )socketerrorr   OSErrorr>   rD   
_MAP_ERRNOrU   errnoselectr+   )rE   r+   rF   rA   r   r   r   rG      s    	)_parse_cacheMAX_CACHE_SIZEclear_cache_splitnetlocSplitResultscheme_chars Tc             C   s  t  |  } |  | | t |   t |  f } t j | d  } | rI | St t  t k re t   n  d } } } |  j d  } | d k r7|  d |  d k r|  d |  j   } |  | d d  }  |  d d  d k r;t	 |  d  \ } }  d	 | k rd
 | k s)d
 | k r;d	 | k r;t
 d   q;n  | rhd |  k rh|  j d d  \ }  } n  d |  k r|  j d d  \ }  } n  t | | |  | |  }	 |	 t | <|	 Sx |  d |  D] }
 |
 t k rPqqW|  | d d  } | st d d   | D  r7|  d |  j   | } }  q7n  |  d d  d k rt	 |  d  \ } }  d	 | k rzd
 | k sd
 | k rd	 | k rt
 d   qn  | rd |  k r|  j d d  \ }  } n  d |  k r|  j d d  \ }  } n  t | | |  | |  }	 |	 t | <|	 S)a"  Parse a URL into 5 components:
        <scheme>://<netloc>/<path>?<query>#<fragment>
        Return a 5-tuple: (scheme, netloc, path, query, fragment).
        Note that we don't break the components up in smaller bits
        (e.g. netloc is a single string) and we don't expand % escapes.Nrb   :r   http   r   z//[]zInvalid IPv6 URL#?c             s   s   |  ] } | d  k Vq d S)
0123456789Nr   ).0cr   r   r   	<genexpr>   s    zurlsplit.<locals>.<genexpr>)booltyper\   getlenr]   r^   findlowerr_   
ValueErrorsplitr`   ra   any)urlschemeallow_fragmentsrC   cachednetlocqueryfragmentivrl   restr   r   r   urlsplit   sV    !

 #
r   )r   )r   r   )r   r   )<r?   Zgunicornr   version_infoZPY26ZPY33r   r&   PY3r-   r3   urllib.parseurllibr7   parseunquote_to_bytesr4   unquoterD   builtinsrH   rL   rM   rN   rP   rO   rQ   rR   rS   rT   rG   rZ   r[   rV   rX   ZEACCESEAGAINZEALREADYECHILDECONNABORTEDZECONNREFUSED
ECONNRESETZEINPROGRESSEINTRENOENTEPERMEPIPEZ	ESHUTDOWNEWOULDBLOCKZESRCHrY   urlparser\   r]   r^   r_   r`   ra   r   Zgunicorn.six.moves.urllib.parser   r   r   r   <module>   s~   %		
										













.8