Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/landscape/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/config.cpython-310.pyc
o

���c�0�@s�ddlmZddlmZddlmZddlZddlZddlZddl	m
Z
mZddlm
ZddlmZddd	�ZGd
d�de�ZGdd
�d
e�Zddd�ZdS)�)�absolute_import)�	getLogger)�OptionParserN)�	ConfigObj�ConfigObjError)�
StringType)�clicCs2d}|dur
|d�|�7}|jddd||d�dS)z>Add common config-related CLI options to the given arg parser.zUUse config from this file (any command line options override settings from the file).Nz (default: {!r})z-cz--config�FILE)�metavar�default�help)�format�
add_option)�parser�filename�cfgfilehelp�r�6/usr/lib/python3/dist-packages/landscape/lib/config.py�add_cli_optionss
�rc@s"eZdZiZddd�Zdd�ZdS)�ConfigSpecOptionParserNcCst�||�dS�N)r�__init__)�self�unsaved_optionsrrrrszConfigSpecOptionParser.__init__cOs4tj|g|�Ri|��}tt|��t|���|Sr)rr�print�dir�get_opt_string)r�args�kwargs�optionrrrr sz!ConfigSpecOptionParser.add_optionr)�__name__�
__module__�__qualname__�_config_spec_definitionsrrrrrrrs
rcs�eZdZdZdZdZdZdZdZdZ	dd�Z
dd�Zdd	�Zd#d
d�Z
�fdd
�Zdd�Zd$dd�Zdd�Zdd�Zdd�Zd#dd�Zdd�Zd%dd�Zdd �Zd!d"�Z�ZS)&�BaseConfigurationaSBase class for configuration implementations.

    @cvar required_options: Optionally, a sequence of key names to require when
        reading or writing a configuration.
    @cvar unsaved_options: Optionally, a sequence of key names to never write
        to the configuration file.  This is useful when you want to provide
        command-line options that should never end up in a configuration file.
    @cvar default_config_filenames: A sequence of filenames to check when
        reading or writing a configuration.

    Default values for supported options are set as in make_parser.
    NrcCsFi|_g|_i|_d|_i|_|��|_|jj��|_	|jj�
�dSr)�_set_options�_command_line_args�_command_line_options�_config_filename�_config_file_options�make_parser�_parser�defaults�copy�_command_line_defaults�clear�rrrrr=s
zBaseConfiguration.__init__cCs�|j|j|j|jfD]}||vr||}nq
|j�d|�dd��r&d}nt|��t|t	�rE|j�
d|�dd��}|durE|�d|�}|S)a�Find and return the value of the given configuration parameter.

        The following sources will be searched:
          - The attributes that were explicitly set on this object,
          - The parameters specified on the command line,
          - The parameters specified in the configuration file, and
          - The defaults.

        If no values are found and the parameter does exist as a possible
        parameter, C{None} is returned.

        Otherwise C{AttributeError} is raised.
        z--�_�-N)r%r'r)r.r+�
has_option�replace�AttributeError�
isinstance�
basestring�
get_option�
convert_value)r�name�options�valuerrrr�__getattr__Is"��
zBaseConfiguration.__getattr__cCs8|��}|j��|_|j��|_|j|_|j��|_|S)zX
        Return a new configuration object, with the same settings as this one.
        )�	__class__r%r-r'r(r))r�configrrr�cloneiszBaseConfiguration.clonecCs$z|�|�WSty|YSw)z5Return the value of the C{name} option or C{default}.)r=r5)rr:rrrr�getts
�zBaseConfiguration.getcs.|�d�rtt|��||�dS||j|<dS)z�Set a configuration parameter.

        If the name begins with C{_}, it will only be set on this object and
        not stored in the configuration file.
        r1N)�
startswith�superr$�__setattr__r%)rr:r<�r>rrrD{s
zBaseConfiguration.__setattr__cCs|�|j�dS)zhReload options using the configured command line arguments.

        @see: L{load_command_line}
        N)�loadr&r0rrr�reload�szBaseConfiguration.reloadFcCs�|�|�|jr|jg}d}n|j}|}|D]}tj�|�r,t�|tj�r,|�|�nq|sCt	|�dkr<d|d}nd}t
�|�|��|j
D]}t||�s^t
�d|�dd�|f�qJd	S)
a
        Load configuration data from command line arguments and a config file.

        @param accept_nonexistent_default_config: If True, don't complain if
            default configuration files aren't found

        @raise: A SystemExit if the arguments are bad.

        F�z#error: config file %s can't be readrz#error: no config file could be readzBerror: must specify --%s or the '%s' directive in the config file.r1r2N)�load_command_liner?�default_config_filenames�os�path�isfile�access�R_OK�load_configuration_file�len�sys�exit�_load_external_options�required_options�getattrr4)rr�!accept_nonexistent_default_config�config_filenames�
allow_missing�config_filename�messagerrrrrF�s:

�
���


���zBaseConfiguration.loadcCsdS)z<Hook for loading options from elsewhere (e.g. for --import).Nrr0rrrrT�sz(BaseConfiguration._load_external_optionscCs$||_|j�|�d}t|�|_dS)z4Load configuration data from the given command line.rN)r&r+�
parse_args�varsr')rr�valuesrrrrI�sz#BaseConfiguration.load_command_linecCs6||_|��}z	||j|_WdStyYdSw)z�Load configuration data from the given file name.

        If any data has already been set on this configuration object,
        then the old data will take precedence.
        N)r(�_get_config_object�config_sectionr)�KeyError)rr�
config_objrrrrP�s�z)BaseConfiguration.load_configuration_filec
Csl|p|��}zt|dddd�}W|Sty5}zt�}|�d�|t|���|j}WYd}~|Sd}~ww)z�Create a L{ConfigObj} consistent with our preferences.

        @param config_source: Optional readable source to read from instead of
            the default configuration file.
        FT)�list_values�raise_errors�write_empty_valueszERROR at {}: {}N)�get_config_filenamerrr�warnr
�strr?)r�alternative_config�
config_sourcerb�e�loggerrrrr_�s����z$BaseConfiguration._get_config_objectcCs�|��}|��}|j|vri||j<|j��}|�|j�|�|j�||j}|��D]1\}}|dkr]||j	vr]||j
�|�krY||jvrY||jvrY|||jvrX||j|=q,|||<q,|||j<||_|�
�dS)a�Write back configuration to the configuration file.

        Values which match the default option in the parser won't be saved.

        Options are considered in the following precedence:

          1. Manually set options (C{config.option = value})
          2. Options passed in the command line
          3. Previously existent options in the configuration file

        The filename picked for saving configuration options is the one
        returned by L{get_config_filename}.
        r?N)rfr_r`r)r-�updater'r%�itemsrr.rAr�write)rrrb�all_options�sectionr:r<rrrro�s*





��
zBaseConfiguration.writecCst|jd�}t�|||�|S)z�Parser factory for supported options.

        @return: An OptionParser preset with options that all
            programs commonly accept. These include
              - config
              - data_path
        )�version)rrrrr)r�cfgfile�datadirrrrrr*szBaseConfiguration.make_parsercCsN|jr|jS|jr|jS|jr%|jD]
}t�|tj�r|Sq|jdSdS)z�Pick the proper configuration file.

        The picked filename is:
          1. C{self.config}, if defined
          2. The last loaded configuration file, if any
          3. The first filename in C{self.default_config_filenames}
        rN)r?r(rJrKrNrO)r�potential_config_filerrrrf%s
�
z%BaseConfiguration.get_config_filenamecCs|jS)zWGet currently loaded command line options.

        @see: L{load_command_line}
        )r'r0rrr�get_command_line_options8sz*BaseConfiguration.get_command_line_optionsr)F)NN)r r!r"�__doc__rrrUrrJ�default_data_dirr`rr=r@rArDrGrFrTrIrPr_ror*rfrv�
__classcell__rrrErr$'s.
 

.


-r$cCsHz|j}Wntyd}Ynw|dur"tj�tj�tjd��}|S)z�Return the directory path where the client binaries are.

    If the config is None, it doesn't have a "bindir" attribute, or its
    value is None, then sys.argv[0] is returned.
    Nr)�bindirr5rKrL�dirname�abspathrR�argv)r?rzrrr�
get_bindir@s
�r~r)�
__future__r�loggingr�optparserrK�os.pathrR�	configobjrr�twisted.python.compatrr7�
landscape.librrr�objectr$r~rrrr�<module>s



Spamworldpro Mini