U
    ÓZj³  ã                   @   s’   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 ddlmZ dd	lmZ ej e	j¡G d
d„ deƒƒZdd„ ZdS )z$Certbot user-supplied configuration.é    N)Úparse)Ú	constants)Úerrors)Ú
interfaces)Úutil)Úmisc)Úosc                   @   sà   e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZed
d„ ƒZ	dd„ Z
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZed d!„ ƒZed"d#„ ƒZed$d%„ ƒZed&d'„ ƒZd(S ))ÚNamespaceConfiga|  Configuration wrapper around :class:`argparse.Namespace`.

    For more documentation, including available attributes, please see
    :class:`certbot.interfaces.IConfig`. However, note that
    the following attributes are dynamically resolved using
    :attr:`~certbot.interfaces.IConfig.work_dir` and relative
    paths defined in :py:mod:`certbot.constants`:

      - `accounts_dir`
      - `csr_dir`
      - `in_progress_dir`
      - `key_dir`
      - `temp_checkpoint_dir`

    And the following paths are dynamically resolved using
    :attr:`~certbot.interfaces.IConfig.config_dir` and relative
    paths defined in :py:mod:`certbot.constants`:

      - `default_archive_dir`
      - `live_dir`
      - `renewal_configs_dir`

    :ivar namespace: Namespace typically produced by
        :meth:`argparse.ArgumentParser.parse_args`.
    :type namespace: :class:`argparse.Namespace`

    c                 C   sV   t  | d|¡ tj | jj¡| j_tj | jj¡| j_tj | jj¡| j_t	| ƒ d S )NÚ	namespace)
ÚobjectÚ__setattr__r   ÚpathÚabspathr
   Ú
config_dirÚwork_dirZlogs_dirÚcheck_config_sanity)Úselfr
   © r   úX/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/certbot/configuration.pyÚ__init__-   s
    zNamespaceConfig.__init__c                 C   s   t | j|ƒS ©N)Úgetattrr
   )r   Únamer   r   r   Ú__getattr__7   s    zNamespaceConfig.__getattr__c                 C   s   t | j||ƒ d S r   )Úsetattrr
   )r   r   Úvaluer   r   r   r   :   s    zNamespaceConfig.__setattr__c                 C   s&   t  | jj¡}|j|j  dtjj¡S )zFile path based on ``server``.ú/)	r   Úurlparser
   ÚserverÚnetlocr   Úreplacer   Úsep)r   Úparsedr   r   r   Úserver_path=   s    zNamespaceConfig.server_pathc                 C   s   |   | j¡S r   )Úaccounts_dir_for_server_pathr#   ©r   r   r   r   Úaccounts_dirC   s    zNamespaceConfig.accounts_dirc                 C   s    t  |¡}tj | jjtj|¡S )z/Path to accounts directory based on server_path)	r   Z.underscores_for_unsupported_characters_in_pathr   r   Újoinr
   r   r   ZACCOUNTS_DIR)r   r#   r   r   r   r$   G   s    
  ÿz,NamespaceConfig.accounts_dir_for_server_pathc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   Z
BACKUP_DIRr%   r   r   r   Ú
backup_dirM   s    zNamespaceConfig.backup_dirc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZCSR_DIRr%   r   r   r   Úcsr_dirQ   s    zNamespaceConfig.csr_dirc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZIN_PROGRESS_DIRr%   r   r   r   Úin_progress_dirU   s    zNamespaceConfig.in_progress_dirc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZKEY_DIRr%   r   r   r   Úkey_dirY   s    zNamespaceConfig.key_dirc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZTEMP_CHECKPOINT_DIRr%   r   r   r   Útemp_checkpoint_dir]   s     ÿz#NamespaceConfig.temp_checkpoint_dirc                 C   s   t  | j¡}t| ƒ|ƒS r   )ÚcopyÚdeepcopyr
   Útype)r   Z_memoZnew_nsr   r   r   Ú__deepcopy__b   s    zNamespaceConfig.__deepcopy__c                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZARCHIVE_DIRr%   r   r   r   Údefault_archive_dirh   s    z#NamespaceConfig.default_archive_dirc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZLIVE_DIRr%   r   r   r   Úlive_dirl   s    zNamespaceConfig.live_dirc                 C   s   t j | jjtj¡S r   )r   r   r'   r
   r   r   ZRENEWAL_CONFIGS_DIRr%   r   r   r   Úrenewal_configs_dirp   s     ÿz#NamespaceConfig.renewal_configs_dirc                 C   s   t j | jjtj¡S )z>Path to directory with hooks to run with the renew subcommand.)r   r   r'   r
   r   r   ZRENEWAL_HOOKS_DIRr%   r   r   r   Úrenewal_hooks_diru   s    ÿz!NamespaceConfig.renewal_hooks_dirc                 C   s   t j | jtj¡S )z8Path to the pre-hook directory for the renew subcommand.)r   r   r'   r4   r   ZRENEWAL_PRE_HOOKS_DIRr%   r   r   r   Úrenewal_pre_hooks_dir{   s    
ÿz%NamespaceConfig.renewal_pre_hooks_dirc                 C   s   t j | jtj¡S )z;Path to the deploy-hook directory for the renew subcommand.)r   r   r'   r4   r   ZRENEWAL_DEPLOY_HOOKS_DIRr%   r   r   r   Úrenewal_deploy_hooks_dir�   s    
ÿz(NamespaceConfig.renewal_deploy_hooks_dirc                 C   s   t j | jtj¡S )z9Path to the post-hook directory for the renew subcommand.)r   r   r'   r4   r   ZRENEWAL_POST_HOOKS_DIRr%   r   r   r   Úrenewal_post_hooks_dir‡   s    
ÿz&NamespaceConfig.renewal_post_hooks_dirN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úpropertyr#   r&   r$   r(   r)   r*   r+   r,   r0   r1   r2   r3   r4   r5   r6   r7   r   r   r   r   r	      sD   













r	   c                 C   sF   | j | jkrt d | j¡¡‚| jjdk	rB| jjD ]}t |¡ q2dS )zÒValidate command line options and display error message if
    requirements are not met.

    :param config: IConfig instance holding user configuration
    :type args: :class:`certbot.interfaces.IConfig`

    z;Trying to run http-01 and https-port on the same port ({0})N)	Zhttp01_portZ
https_portr   ÚConfigurationErrorÚformatr
   Údomainsr   Zenforce_domain_sanity)ÚconfigÚdomainr   r   r   r   Ž   s    	ÿÿr   )r;   r-   Zzope.interfaceZzopeZsix.moves.urllibr   Zcertbotr   r   r   r   Zcertbot.compatr   r   Z	interfaceZimplementerZIConfigr   r	   r   r   r   r   r   Ú<module>   s   ~