HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib/python3.6/site-packages/fail2ban/client/__pycache__/configparserinc.cpython-36.opt-1.pyc
3

TB(dL3�@s�dZdZdZddlZddlZddlZddlmZejdkrhddl	m
ZmZm
Z
mZmZGd	d
�d
e�Zn.ddl	mZm
Z
mZmZeje_dd
�Zee_dd�Zee�ZdZdgZGdd�de�ZdS)z0Yaroslav Halchenko, Serg G. Brester (aka sebres)zHCopyright (c) 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)ZGPL�N�)�	getLogger�)�ConfigParser�BasicInterpolation�InterpolationMissingOptionError�
NoOptionError�NoSectionErrorcs eZdZdZ�fdd�Z�ZS)�BasicInterpolationWithNamea�Decorator to bring __name__ interpolation back.

		Original handling of __name__ was removed because of
		functional deficiencies: http://bugs.python.org/issue10489

		commit v3.2a4-105-g61f2761
		Author: Lukasz Langa <lukasz@langa.pl>
		Date:	Sun Nov 21 13:41:35 2010 +0000

		Issue #10489: removed broken `__name__` support from configparser

		But should be fine to reincarnate for our use case
		c	sR|rNt|krN|j�}||d<|j||||�tt|�j||||||f|�|�SdS)N�__name__)r�copy�_map_section_options�superr
�_interpolate_some)	�self�parser�option�accum�rest�section�map�args�kwargs)�	__class__��%/usr/lib/python3.6/configparserinc.pyr6s
z,BasicInterpolationWithName._interpolate_some)r�
__module__�__qualname__�__doc__r�
__classcell__rr)rrr
(s
r
)�SafeConfigParserrrr	cOs*|j||||�|j|||||f|�|�S)N)r
�_cp_interpolate_some)rrrrrrrrrrrrFsrcCsRg}xH|D]@}|j|�tjj|�dd}||kr
tjj|�r
|j|�q
W|S)z,Expands config files with local extension.
	rz.local)�append�os�path�splitext�isfile)�	filenamesZnewFilenames�filenameZ	localnamerrr�_expandConfFilesWithLocalLs

r)��SafeConfigParserWithIncludescs�eZdZdZdZejd�Zejd�Zejd�Z	e
jd$krHd%�fd	d
�	Zn
d&dd
�Zdifd
d�Z
dd�Zedd��Zdd�Zgfdd�Zgfdd�Zdd�Zdd�Zd'dd�Zd(d d!�Zd)d"d#�Z�ZS)*r+a
	Class adds functionality to SafeConfigParser to handle included
	other configuration files (or may be urls, whatever in the future)

	File should have section [includes] and only 2 options implemented
	are 'files_before' and 'files_after' where files are listed 1 per
	line.

	Example:

[INCLUDES]
before = 1.conf
         3.conf

after = 1.conf

	It is a simple implementation, so just basic care is taken about
	recursion. Includes preserve right order, ie new files are
	inserted to the list of read configs before original, and their
	includes correspondingly so the list should follow the leaves of
	the tree.

	I wasn't sure what would be the right way to implement generic (aka c++
	template) so we could base at any *configparser class... so I will
	leave it for the future

	ZINCLUDESz^([\w\-]+)/([^\s>]+)$z%\(([\w\-]+/([^\)]+))\)sz
^(\w+)(\?.+)$rrNcs6|j�}t�|d<d|d<tt|�j||�||_dS)NZ
interpolation�;Zinline_comment_prefixes)rr
rr+�__init__�
_cfg_share)r�share_configrr)rrrr-�s

z%SafeConfigParserWithIncludes.__init__cOstj|f|�|�||_dS)N)r r-r.)rr/rrrrrr-�sFcCs�d}d|krtjj|�}|r�|jd�}|jd�}|j�}|dkrNd||f}n|dkr\|fnd}xH|D]@}y|j|||d	�}	|	Sttfk
r�}
zWYdd}
~
XqfXqfW|j||||d
�}	|	S)z�Get an option value for a given section.
		
		In opposite to `get`, it differentiate session-related option name like `sec/opt`.
		N�/�r�knownzKNOWN/�default�DEFAULT)�raw)r5�vars)r4)r+�SECTION_OPTNAME_CRE�search�group�lower�getr	r)rrrr5r6�sopt�sec�opt�seclwr�v�errr�get_ex�s$


z#SafeConfigParserWithIncludes.get_exc
&Csvd|ksd|krdSd}tjj|�}|s,dS�xB|D�]8\}}||kr4|dt|��}	|	j�}
|
dkr�d}|
dkr�y|jd||}Wq�tk
r�d}Yq�Xq�y2y|j|	}	Wntk
r�w4YnX|	|}Wq�tk
r�d}Yq�Xnd}|�r&y|j|}Wntk
�r$w4YnXd}y|||<Wq4y||jd|<Wn||j|<YnXYq4Xq4W|S)	z�
		Interpolates values of the section options (name syntax `%(section/option)s`).

		Fallback: try to wrap missing default options as "default/options" resp. "known/options"
		r0z%(rNr3r2zKNOWN/r1)	r+�SECTION_OPTSUBST_CRE�findall�lenr:�	_sections�KeyError�	_defaultsZ_maps)
rrrrZdefaultsZrplcmntZsoptrepr<r>r=r?Zusedefr@rrrr
�sPz1SafeConfigParserWithIncludes._map_section_optionscCs|jS)N)r.)rrrrr/�sz)SafeConfigParserWithIncludes.share_configcCs�t}|jr�dt|t�s|ndj|�}|jj|d�\}}|dkrj||jd�}|j|dd�}||f|j|<q�tj�t	kr�tj
t	d|�n|�}|j|dd�}||fS)Nzinc:�)r/F)�get_includesz    Shared file: %s)NN)r+r.�
isinstance�list�joinr;�read�logSys�getEffectiveLevel�logLevel�log)rr(�SCPWI�hashv�cfg�irrr�_getSharedSCPWI�sz,SafeConfigParserWithIncludes._getSharedSCPWIcCs�t|t�s|g}t|�}|jrpddj|�}|jj|�}|dkrlg}x|D]}||j||�7}qJW||j|<|Sg}x|D]}||j||�7}qzW|S)Nz	inc-path:rI)rKrLr)r.rMr;�2_SafeConfigParserWithIncludes__getIncludesUncached)rr'�seenrT�
fileNamesFullr(rrr�_getIncludess 



z)SafeConfigParserWithIncludes._getIncludescCs$t}y|j|�\}}|sgSWn2tk
rP}ztjd||f�gSd}~XnXtjj|�}dgfdgfg}|j|j	�k�rx�|D]~\}	}
|	|j
|j�kr�|j|j|	�}xV|jd�D]H}tjj
|�r�|}
ntjj||�}
|
|kr�q�||g}|
|j|
|�7}
q�Wq�W|dd|g|ddS)z�
		Given 1 config resource returns list of included files
		(recursively) with the original one as well
		Simple loops are taken care about
		z#Error decoding config file '%s': %sNZbefore�after�
rr1)r+rW�UnicodeDecodeErrorrO�errorr#r$�dirname�SECTION_NAMEZsections�optionsr;�split�isabsrMr[)rZresourcerYrSrrVrAZresourceDirZnewFilesZoption_nameZoption_listZnewResourcesZnewResource�r�srrrZ__getIncludesUncacheds.
z2SafeConfigParserWithIncludes.__getIncludesUncachedcCs|jS)N)rH)rrrr�get_defaults7sz)SafeConfigParserWithIncludes.get_defaultscCs|jS)N)rF)rrrr�get_sections:sz)SafeConfigParserWithIncludes.get_sectionsTcCsRy|j|}Wntk
r*t|��YnX|rFt|j��t|j�BSt|j��S)z�Return a list of option names for the given section name.

		Parameter `withDefault` controls the include of names from section `[DEFAULT]`
		)rFrGr	�set�keysrHrL)rrZwithDefaultZoptsrrrrb=sz$SafeConfigParserWithIncludes.optionscs�t|t�s|g}g}|r(||j|�7}n|}|s4gStjd|�|sRt|�dk�r�g}|j�}|j�}�x|D�]}|j|�\}}	|	rn||	7}|j	|j��x�|j�j
�D]�\}
�tjj
|
�}|�r&|j�\}
}�j��y
�d=Wntk
r�YnXx,t�j��D]}�j|�}
|
�||<�qW|j|
�}t|t��rt|jd|
t�fdd�t|j
��D��d�|j	��q��j�||
<q�WqnW|Stj�tk�r�tjtd|d	�tjdk�r�tj||dd
�Stj||�SdS)Nz  Loading files: %sr1rzKNOWN/csg|]}|d�kr|�qS)rr)�.0rV)rfrr�
<listcomp>xsz5SafeConfigParserWithIncludes.read.<locals>.<listcomp>�z    Reading file: %srrrzutf-8)�encoding)rr)rKrLr[rO�inforErgrhrW�update�itemsr+�CONDITIONAL_RE�match�groupsrrGrj�popr;�dict�
merge_section�iterrPrQrR�sys�version_infor rN)rr'rJrZ�retZalld�allsr(rUrV�nZcond�kr@�s2r)rfrrNLsT




"z!SafeConfigParserWithIncludes.readc	
Cs�|j�}y||}Wn"tk
r6t�||<}YnX|sJ|j|�dSi}x4|j�D](\}}|j|�rX|dkrX||||<qXW|j|�dS)Nr)rhrGrvrprq�
startswith)	rrrbZprefr|r=Zskr~r@rrrrw�s
z*SafeConfigParserWithIncludes.merge_section)rr)N)N)T)T)N)rrrrra�re�compiler7rCrrryrzr-rBr
�propertyr/rWr[rXrgrhrbrNrwrrr)rrr+_s&



	
9"

=)r)�
__author__Z
__copyright__Z__license__r#r�ryZhelpersrrzZconfigparserrr rrrr	r
rr!r)rrOrQ�__all__r+rrrr�<module>s$