https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/fail2ban/client/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/fail2ban/client/__pycache__/configparserinc.cpython-310.pyc
o

;s*bL3�@s�dZdZdZddlZddlZddlZddlmZejdkr4ddl	m
ZmZm
Z
mZmZGd	d
�d
e�Znddl	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)�GPL�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	s\|r*t|vr,|��}||d<|�||||�tt|�j||||||g|�Ri|��SdSdS�N�__name__)r
�copy�_map_section_options�superr�_interpolate_some)	�self�parser�option�accum�rest�section�map�args�kwargs��	__class__��A/usr/lib/python3/dist-packages/fail2ban/client/configparserinc.pyr6s
����z,BasicInterpolationWithName._interpolate_some)r
�
__module__�__qualname__�__doc__r�
__classcell__rrrrr(s
r)�SafeConfigParserrr	r
cOs0|�||||�|j|||||g|�Ri|��S�N)r�_cp_interpolate_some)rrrrrrrrrrrrFs rcCsNg}|D] }|�|�tj�|�dd}||vr$tj�|�r$|�|�q|S)z,Expands config files with local extension.
	rz.local)�append�os�path�splitext�isfile)�	filenames�newFilenames�filename�	localnamerrr�_expandConfFilesWithLocalLs

�r/��SafeConfigParserWithIncludescs�eZdZdZdZe�d�Ze�d�Ze�d�Z	e
jdkr$d#�fdd	�	Znd#d
d	�Zdifdd
�Z
dd�Zedd��Zdd�Zgfdd�Zgfdd�Zdd�Zdd�Zd$dd�Zd$dd �Zd#d!d"�Z�ZS)%r1a
	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

	�INCLUDESz^([\w\-]+)/([^\s>]+)$z%\(([\w\-]+/([^\)]+))\)sz
^(\w+)(\?.+)$�rrNcs:|��}t�|d<d|d<tt|�j|i|��||_dS)N�
interpolation�;�inline_comment_prefixes)rrrr1�__init__�
_cfg_share�r�share_configrrrrrr7�s

��
z%SafeConfigParserWithIncludes.__init__cOs"tj|g|�Ri|��||_dSr$)r#r7r8r9rrrr7�s
FcCs�d}d|vrtj�|�}|rV|�d�}|�d�}|��}|dkr'd||f}n	|dkr.|fnd}|D]#}z
|j|||d	�}	|	WSttfyU}
zWYd}
~
q2d}
~
ww|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�known�KNOWN/�default)�DEFAULT)�raw)rA�vars)r1�SECTION_OPTNAME_CRE�search�group�lower�getr
r	)rrrrArB�sopt�sec�opt�seclwr�v�errr�get_ex�s(


��z#SafeConfigParserWithIncludes.get_exc

CsVd|vsd|vr
dSd}tj�|�}|sdS|D]�\}}||vr�|dt|��}	|	��}
|
dkrrd}|
dkrNz|jd||}Wn1tyMd}Yn'wzz|j|	}	Wn
ty`YWqw|	|}Wn
tyqd}Ynwd}|r�z|j|}Wn	ty�Yqwd}z|||<Wqz	||jd|<Wn	||j|<YYqq|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"
		r;z%(rNr?r=r>r<)	r1�SECTION_OPTSUBST_CRE�findall�lenrF�	_sections�KeyError�	_defaults�_maps)
rrrr�defaults�rplcmnt�soptreprHrJrIrK�usedefrLrrrr�s\������*z1SafeConfigParserWithIncludes._map_section_optionscC�|jSr$)r8�rrrrr:�sz)SafeConfigParserWithIncludes.share_configcCs�t}|jrIdt|t�s
|nd�|�}|j�|d�\}}|dur8||jd�}|j|dd�}||f|j|<||fSt��t	krEt�
t	d|�||fS|�}|j|dd�}||fS)Nzinc:�)NN)r:F)�get_includesz    Shared file: %s)r1r8�
isinstance�list�joinrG�read�logSys�getEffectiveLevel�logLevel�log)rr-�SCPWI�hashv�cfg�irrr�_getSharedSCPWI�s��z,SafeConfigParserWithIncludes._getSharedSCPWIcCs�t|t�s|g}t|�}|jr6dd�|�}|j�|�}|dur4g}|D]
}||�||�7}q$||j|<|Sg}|D]
}||�||�7}q:|S)Nz	inc-path:r\)r^r_r/r8r`rG�2_SafeConfigParserWithIncludes__getIncludesUncached)rr+�seenrg�
fileNamesFullr-rrr�_getIncludess 

z)SafeConfigParserWithIncludes._getIncludesc
Cs$t}z|�|�\}}|sgWSWnty-}zt�d||f�gWYd}~Sd}~wwtj�|�}dgfdgfg}|j|�	�vr�|D]=\}	}
|	|�
|j�vr�|�|j|	�}|�d�D]$}tj�
|�rh|}
ntj�||�}
|
|vrtq]||g}|
|�|
|�7}
q]qE|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': %sN�before�after�
rr<)r1rj�UnicodeDecodeErrorrb�errorr'r(�dirname�SECTION_NAME�sections�optionsrG�split�isabsr`rn)r�resourcerlrfrrirM�resourceDir�newFiles�option_name�option_list�newResources�newResource�r�srrr�__getIncludesUncacheds6���
�z2SafeConfigParserWithIncludes.__getIncludesUncachedcCrZr$)rTr[rrr�get_defaults7�z)SafeConfigParserWithIncludes.get_defaultscCrZr$)rRr[rrr�get_sections:r�z)SafeConfigParserWithIncludes.get_sectionsTcCsLz|j|}Wntyt|��w|r t|���t|j�BSt|���S)z�Return a list of option names for the given section name.

		Parameter `withDefault` controls the include of names from section `[DEFAULT]`
		)rRrSr
�set�keysrTr_)rr�withDefault�optsrrrrw=s�z$SafeConfigParserWithIncludes.optionsc
s�t|t�s|g}g}|r||�|�7}n|}|sgSt�d|�|s(t|�dkr�g}|��}|��}|D]�}|�|�\}}	|	r�||	7}|�	|���|���
�D]e\}
�tj�
|
�}|r�|��\}
}����z�d=Wn	tytYnwt����D]
}��|�}
|
�||<q{|�|
�}t|t�r�|�d|
t�fdd�t|�
��D��d�|�	��qP���||
<qPq4|St��tkr�t�td|d	�tjd
kr�tj||dd�St�||�S)
Nz  Loading files: %sr<r
r>csg|]
}|d�vr|�qS)rr)�.0ri�r�rr�
<listcomp>xsz5SafeConfigParserWithIncludes.read.<locals>.<listcomp>�z    Reading file: %srr3zutf-8)�encoding)r^r_rnrb�inforQr�r�rj�update�itemsr1�CONDITIONAL_RE�match�groupsrrSr��poprG�dict�
merge_section�iterrcrdre�sys�version_infor#ra)rr+r]rm�ret�alld�allsr-rhri�n�cond�krL�s2rr�rraLsZ

�



��
z!SafeConfigParserWithIncludes.readc	Cs�|��}z||}Wntyt�||<}Ynw|s$|�|�dSi}|��D]\}}|�|�s=|dkr=||||<q*|�|�dSr)r�rSr�r�r��
startswith)	rrrw�prefr�rI�skr�rLrrrr��s�
�z*SafeConfigParserWithIncludes.merge_sectionr$)T)r
rr r!ru�re�compilerCrOr�r�r�r7rNr�propertyr:rjrnrkr�r�rwrar�r"rrrrr1_s*




	9
"

=)�
__author__�
__copyright__�__license__r'r�r��helpersrr��configparserrr#rrr	r
rrr%r/r
rbrd�__all__r1rrrr�<module>s&


https://t.me/RX1948 - 2025