U
    La                     @   s   d dl Z d dlZd dlZd ZZeedeZdZ	dZ
dZdZG dd	 d	eZd
ZdddedddgdddddddddddddefddZdd Zdd Zdd Zdd  Zd!d" ZdS )#    Nz1.4.2z[.-]z2020-10-10 08:15:56Z
pypiserverz4A minimal PyPI server for use with pip/easy_install.z(https://github.com/pypiserver/pypiserverc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )ConfigurationzA
    .. see:: config-options: :func:`pypiserver.configure()`
    c                 K   s   t | | d S N)varsupdate)selfkwds r   7/tmp/pip-unpacked-wheel-8ds7z0ev/pypiserver/__init__.py__init__   s    zConfiguration.__init__c                 O   s   dt |  S )NzConfiguration(**%s))r   r   argskwargsr   r   r	   __repr__   s    zConfiguration.__repr__c                 O   s$   dd dd tt|  D  S )NzConfiguration:
%s
c                 s   s   | ]\}}d ||f V  qdS )z	%20s = %sNr   ).0kvr   r   r	   	<genexpr>   s   z(Configuration.__str__.<locals>.<genexpr>)joinsortedr   itemsr   r   r   r	   __str__   s    zConfiguration.__str__c                 C   s(   t |tr|nt|}t| | d S r   )
isinstancedictr   r   )r   propsdr   r   r	   r      s    zConfiguration.updateN)__name__
__module____qualname____doc__r
   r   r   r   r   r   r   r	   r      s
   r   autoz0.0.0.0i  Tr   Fmd5   stderrz9%(asctime)s|%(name)s|%(levelname)s|%(thread)d|%(message)sz%(bottle.request)sz
%(status)sz&%(body)s: %(exception)s 
%(traceback)sc                 C   s   t  S )a  
    Fetch default-opts with overridden kwds, capable of starting-up pypiserver.

    Does not validate overridden options.
    Example usage::

        kwds = pypiserver.default_config(<override_kwds> ...)
        ## More modifications on kwds.
        pypiserver.app(**kwds)``.

    Kwds correspond to same-named cmd-line opts, with '-' --> '_' substitution.
    Non standard args are described below:

    :param return_defaults_only:
            When `True`, returns defaults, otherwise,
            configures "runtime" attributes and returns also the "packages"
            found in the roots.
    :param root:
            A list of paths, derived from the packages specified on cmd-line.
            If `None`, defaults to '~/packages'.
    :param redirect_to_fallback:
            see :option:`--disable-fallback`
    :param authenticated:
            see :option:`--authenticate`
    :param password_file:
            see :option:`--passwords`
    :param log_file:
            see :option:`--log-file`
            Not used, passed here for logging it.
    :param log_frmt:
            see :option:`--log-frmt`
            Not used, passed here for logging it.
    :param callable auther:
            An API-only options that if it evaluates to a callable,
            it is invoked to allow access to protected operations
            (instead of htpaswd mechanism) like that::

                auther(username, password): bool

            When defined, `password_file` is ignored.
    :param host:
            see :option:`--interface`
            Not used, passed here for logging it.
    :param port:
            see :option:`--port`
            Not used, passed here for logging it.
    :param server:
            see :option:`--server`
            Not used, passed here for logging it.
    :param verbosity:
            see :option:`-v`
            Not used, passed here for logging it.
    :param VERSION:
            Not used, passed here for logging it.

    :return: a dict of defaults

    )locals)roothostportserverredirect_to_fallbackfallback_urlauthenticatedpassword_file	overwrite	hash_algo	verbositylog_fileZ
log_streamlog_frmtlog_req_frmtlog_res_frmtlog_err_frmtwelcome_fileZcache_controlZautherVERSIONr   r   r	   default_config%   s    Pr7   c                  K   sd   ddl m} tdt t dgd}tjdd tf | } |j	f | \}}||_
||_||j_|jS )z
    :param dict kwds: Any overrides for defaults, as fetched by
        :func:`default_config()`. Check the docstring of this function
        for supported kwds.
    r"   )core_app.zpypiserver._appN) r8   
__import__globalsr$   sysmodulespopr7   	configureconfigpackagesappmodule)r   r8   r9   rB   rC   r   r   r	   rD   x   s    
rD   c                 C   s    | d k	r| dkr|   dkS |S )Nr;   )nooff0false)lower)sdefaultr   r   r	   str2bool   s    rM   c                 C   s   |   S )z5Provide a generic strip method to pass as a callback.)strip)stringr   r   r	   
_str_strip   s    rP   c           
   	   K   s   dd }dd }dd }dt fdd	}d
d }t }||d| ||d| ||d|dd ||d|d|d ||d| dddddddddg	}|D ]}	|||	| qtf |S )z'Parse a paste config and return an app.c                 S   s   t ||d | | | |< d S r   )rM   r@   )confattrsdictr   r   r	   upd_conf_with_bool_item   s    z2paste_app_factory.<locals>.upd_conf_with_bool_itemc                 S   s    | |d }|d k	r|| |< d S r   )r@   rQ   rR   rS   valuer   r   r	   upd_conf_with_str_item   s    z1paste_app_factory.<locals>.upd_conf_with_str_itemc                 S   s$   | |d }|d k	r t|| |< d S r   )r@   intrU   r   r   r	   upd_conf_with_int_item   s    z1paste_app_factory.<locals>.upd_conf_with_int_item c                 S   s2   | |d }|r.ttd t|||| |< d S r   )r@   listfiltermapsplit)rQ   rR   rS   sepparsevaluesr   r   r	   upd_conf_with_list_item   s    z2paste_app_factory.<locals>.upd_conf_with_list_itemc                 S   s"   |   } | drtj| S | S )N~)rN   
startswithospath
expanduser)r%   r   r   r	   
_make_root   s    
z%paste_app_factory.<locals>._make_rootr-   r)   r+   )r_   r%   r   )r_   r`   r/   r*   r.   r4   r0   r1   r2   r3   r,   r5   )rP   r7   rD   )
Zglobal_configZ
local_confrT   rW   rY   rb   rh   cZ	str_itemsZstr_itemr   r   r	   paste_app_factory   s0    rj   c                 C   sH   |rDdddg}|D ] }| |r|d t|  }q|rD| || d S )Nz
z
r   )endswithlenlog)loggerlevelmsgZline_endingsler   r   r	   	_logwrite   s    

rr   )re   re_rer>   version__version__tupler^   __version_info__Z__updated__	__title____summary____uri__objectr   ZDEFAULT_SERVERr7   rD   rM   rP   rj   rr   r   r   r   r	   <module>   sJ   
S5