B
    Ø‹d>  ã               @   sX   d Z ddlZddlZddlZddddddœZe e¡addd	„Zdd
d„Zddd„Z	dS )z&
Module for configuration management

é    NÚ ÚINFOZ345600ZRS256)Úlog_fileÚ	log_levelZcache_lifetimeZcache_locationZdefault_algc             C   s:  t | tƒr"t t¡at | g¡ n8t | tjƒr4| an&| dkrZtdƒ t t¡at 	d¡ n t
 d¡}t dd¡ržt dd¡}|dkr¬| t
jj|ddd¡ n| t
 ¡ ¡ t dd	¡}|d
krÎ| t
j¡ nh|dkrä| t
j¡ nR|dkrú| t
j¡ n<|dkr| t
j¡ n$|dkr*| t
j¡ n| t
j¡ dS )zÇ
    Set the configuration of SciTokens library

    :param config: config may be: A full path to a ini configuration file,
        a ConfigParser instance, or None, which will use all defaults.
    NzUsing built-in defaultsÚ	scitokensr   r   i €é   )ÚmaxBytesÚbackupCountr   ÚDEBUGr   ÚWARNINGÚERRORÚCRITICAL)Ú
isinstanceÚstrÚconfigparserÚConfigParserÚCONFIG_DEFAULTSÚconfigurationÚreadÚRawConfigParserÚprintÚadd_sectionÚloggingÚ	getLoggerÚ
has_optionÚgetÚ
addHandlerÚhandlersÚRotatingFileHandlerÚStreamHandlerÚsetLevelr
   r   r   r   r   )ÚconfigÚloggerr   r   © r#   úc/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/scitokens/utils/config.pyÚ
set_config   s6    	





r%   c          
   C   sR   ~yt  d| ¡S  tjtjfk
rL } z| tkr8t|  S |‚W dd}~X Y nX dS )z¨
    Get the configuration value for key

    :param str key: The key in the configuration to retreive
    :returns: The value in the configuration, or the default
    r   N)r   r   r   ÚNoOptionErrorÚNoSectionErrorr   )ÚkeyÚdefaultZnoer#   r#   r$   r   G   s    r   c             C   s   t t| |ƒƒS )z«
    Get an integer from the configuration.

    :param str key: The key in the configuration to retreive
    :returns: The value in the configuration, or the default
    )Úintr   )r(   r)   r#   r#   r$   Úget_int[   s    r+   )N)N)N)
Ú__doc__r   r   Úlogging.handlersr   r   r   r%   r   r+   r#   r#   r#   r$   Ú<module>   s   

0
