a }|gG @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddlm Z ddl mZ ddlm Z dd lmZ dd lmZ ddlmZ ddlmZ eeZG d d dejZG dd dZeddddZeedddZdS )z$Certbot user-supplied configuration. N)Any)Dict)List)Optional)parse)errors)util) constants)misc)osc @ s8 e Zd ZdZe Ze Ze Ze Z e Z dS )ArgumentSourcez;Enum for describing where a configuration argument was set.N)__name__ __module____qualname____doc__enumautoZCOMMAND_LINEZCONFIG_FILEDEFAULTZENV_VARRUNTIME r r 9/usr/lib/python3.9/site-packages/certbot/configuration.pyr s r c @ sx e Zd ZdZejddddZeee f ddddZ eed d dZeee f dd dZeddddZeeeee f dddZee dddZee ddddZeedddZejeddddZeee dddZejeddd dZeedd!d"Zejedd#d$d"Zeedd%d&Zejedd'd(d&Zeedd)d*Zejedd+d,d*Zeedd-d.Zeedd/d0Zeedd1d2Zeedd3d4Zeedd5d6Z eedd7d8Z!eedd9d:Z"eedd;d<Z#eedd=d>Z$eedd?d@Z%eeddAdBZ&ee'e ddCdDZ(eeddEdFZ)eeddGdHZ*eeddIdJZ+eee ddKdLZ,eeddMdNZ-eedOdPdQZ.eeddRdSZ/eeddTdUZ0eeddVdWZ1eeddXdYZ2eeddZd[Z3eedd\d]Z4eedd^d_Z5eedd`daZ6eeddbdcZ7e d dddedfZ8dS )gNamespaceConfiga Configuration wrapper around :class:`argparse.Namespace`. Please note that the following attributes are dynamically resolved using :attr:`~certbot.configuration.NamespaceConfig.work_dir` and relative paths defined in :py:mod:`certbot._internal.constants`: - `accounts_dir` - `in_progress_dir` - `temp_checkpoint_dir` And the following paths are dynamically resolved using :attr:`~certbot.configuration.NamespaceConfig.config_dir` and relative paths defined in :py:mod:`certbot._internal.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` N) namespacereturnc C sv | t | d| t | dd t | di tj| jj| j_tj| jj| j_tj| jj| j_t | d S )Nr _argument_sources_previously_accessed_mutables) object__setattr__r pathabspathr config_dirwork_dirZlogs_dir_check_config_sanity)selfr r r r __init__> s zNamespaceConfig.__init__)argument_sourcesr c C s t | d| dS )al Associate the NamespaceConfig with a dictionary describing where each of its arguments came from, e.g. `{ 'email': ArgumentSource.CONFIG_FILE }`. This is necessary for making runtime evaluations on whether an argument was specified by the user or not (see `set_by_user`). For an example of how to build such a dictionary, see `certbot._internal.cli.helpful.HelpfulArgumentParser._build_sources_dict` :ivar argument_sources: dictionary of argument names to their :class:`ArgumentSource` :type argument_sources: :class:`Dict[str, ArgumentSource]` r N)r r )r# r% r r r set_argument_sourcesL s z$NamespaceConfig.set_argument_sources)varr c C s ddl m} ddl m} ddlm} | jdu r6td||v rBdS |dv rx|| \}}|d krh|duS |d krx|duS || jv r| j| tj krt d|t| | dS | |g D ]*}| |rt d|| |g dS qdS ) ad Return True if a particular config variable has been set by the user (via CLI or config file) including if the user explicitly set it to the default, or if it was dynamically set at runtime. Returns False if the variable was assigned a default value. Raises an exception if `argument_sources` is not set. r )DEPRECATED_OPTIONS) VAR_MODIFIERS) selectionNzoNamespaceConfig.set_by_user called without an ArgumentSources dict. See NamespaceConfig.set_argument_sources().F) authenticator installerr+ r, zVar %s=%s (set by user).T)Z#certbot._internal.cli.cli_constantsr( r) Zcertbot._internal.pluginsr* r% RuntimeErrorZcli_plugin_requestsr r loggerdebuggetattrgetset_by_user)r# r' r( r) r* Zauthinstmodifierr r r r2 ^ s2 zNamespaceConfig.set_by_user)r c C s t | jS )zQ Returns a dictionary mapping all argument names to their values )varsr r# r r r to_dict s zNamespaceConfig.to_dict)namer c C s, | j dur(tj| j |<