%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/fail2ban/client/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/fail2ban/client/configparserinc.pyc

�
��&dc@sdZdZdZddlZddlZddlZddlmZejdkr�ddl	m
ZmZm
Z
mZmZd	efd
��YZn@ddl
mZm
Z
mZmZeje_d�Zee_d
�Zee�ZdZdgZdefd��YZdS(s0Yaroslav Halchenko, Serg G. Brester (aka sebres)sHCopyright (c) 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)tGPLi����Ni(t	getLoggeri(tConfigParsertBasicInterpolationtInterpolationMissingOptionErrort
NoOptionErrortNoSectionErrortBasicInterpolationWithNamecBseZdZd�ZRS(s�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	
Osm|rit|kri|j�}||d<|j||||�tt|�j||||||||�SdS(Nt__name__(Rtcopyt_map_section_optionstsuperRt_interpolate_some(	tselftparsertoptiontaccumtresttsectiontmaptargstkwargs((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR6s
(Rt
__module__t__doc__R(((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR(s
(tSafeConfigParserRRRcOs5|j||||�|j|||||||�S(N(R
t_cp_interpolate_some(R
RRRRRRR((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyRFscCspg}xc|D][}|j|�tjj|�dd}||kr
tjj|�r
|j|�q
q
W|S(s,Expands config files with local extension.
	is.local(tappendtostpathtsplitexttisfile(t	filenamestnewFilenamestfilenamet	localname((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyt_expandConfFilesWithLocalLs

itSafeConfigParserWithIncludescBs�eZdZdZejd�Zejd�Zejd�Ze	j
dkr]dd�Zndd�Ze
id	�Zd
�Zed��Zd�Zgd
�Zgd�Zd�Zd�Zed�Zed�Zdd�ZRS(s
	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

	tINCLUDESs^([\w\-]+)/([^\s>]+)$s%\(([\w\-]+/([^\)]+))\)ss
^(\w+)(\?.+)$iicOsI|j�}t�|d<d|d<tt|�j||�||_dS(Nt
interpolationt;tinline_comment_prefixes(R	RRR$t__init__t
_cfg_share(R
tshare_configRR((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR)�s


cOs tj|||�||_dS(N(RR)R*(R
R+RR((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR)�scCsd
}d|kr'tjj|�}n|r�|jd�}|jd�}|j�}|dkrvd||f}n|dkr�|fnd}xM|D]B}y |j||d|�}	|	SWq�ttfk
r�}
q�Xq�Wn|j||d|d	|�}	|	S(s�Get an option value for a given section.
		
		In opposite to `get`, it differentiate session-related option name like `sec/opt`.
		t/iitknownsKNOWN/tdefaulttDEFAULTtrawtvarsN(sDEFAULT(	tNoneR$tSECTION_OPTNAME_CREtsearchtgrouptlowertgetRR(R
RRR0R1tsopttsectopttseclwrtvte((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pytget_ex�s$
c
Cs�d|ksd|krdSd}tjj|�}|s>dSxh|D]`\}}||krE|t|� }	|	j�}
|
dkr!d}|
dkr�y|jd||}Wqtk
r�d}qXq'y6y|j|	}	Wntk
r�wEnX|	|}Wq'tk
rd}q'Xnd}|rXy|j|}WqXtk
rTqEqXXnd}y|||<Wq�y||jd|<Wq�||j|<q�Xq�XqEqEW|S(s�
		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,s%(iR.R-sKNOWN/i(	R$tSECTION_OPTSUBST_CREtfindalltlenR6t	_sectionstKeyErrort	_defaultst_maps(
R
RRRtdefaultstrplcmnttsoptrepR8R:R9R;tusedefR<((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR
�sP






cCs|jS(N(R*(R
((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR+�scCs�t}|jr�dt|t�s'|ndj|�}|jj|d�\}}|dkr�|d|j�}|j|dt�}||f|j|<q�t	j
�tkr�t	jtd|�q�n|�}|j|dt�}||fS(Nsinc:sR+tget_includess    Shared file: %s(NN(
R$R*t
isinstancetlisttjoinR7R2treadtFalsetlogSystgetEffectiveLeveltlogLeveltlog(R
R!tSCPWIthashvtcfgti((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyt_getSharedSCPWI�s	(	cCs�t|t�s|g}nt|�}|jr�ddj|�}|jj|�}|dkr�g}x$|D]}||j||�7}qnW||j|<n|Sg}x$|D]}||j||�7}q�W|S(Ns	inc-path:s(RKRLR#R*RMR7R2t2_SafeConfigParserWithIncludes__getIncludesUncached(R
RtseenRUt
fileNamesFullR!((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyt_getIncludess 	

cCs~t}y#|j|�\}}|s(gSWn+tk
rV}tjd||f�gSXtjj|�}dgfdgfg}|j|j	�kr_x�|D]�\}	}
|	|j
|j�kr�|j|j|	�}x|jd�D]k}tjj
|�r|}
ntjj||�}
|
|kr.q�n||g}|
|j|
|�7}
q�Wq�q�Wn|dd|g|ddS(s�
		Given 1 config resource returns list of included files
		(recursively) with the original one as well
		Simple loops are taken care about
		s#Error decoding config file '%s': %stbeforetafters
ii(R$RXtUnicodeDecodeErrorRPterrorRRtdirnametSECTION_NAMEtsectionstoptionsR7tsplittisabsRMR\(R
tresourceRZRTRRWR=tresourceDirtnewFilestoption_nametoption_listtnewResourcestnewResourcetrts((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyt__getIncludesUncacheds.	
$cCs|jS(N(RD(R
((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pytget_defaults7scCs|jS(N(RB(R
((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pytget_sections:scCs^y|j|}Wntk
r0t|��nX|rTt|j��t|j�BS|j�S(s�Return a list of option names for the given section name.

		Parameter `withDefault` controls the include of names from section `[DEFAULT]`
		(RBRCRtsettkeysRD(R
RtwithDefaulttopts((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyRd=s
c	sjt|t�s|g}ng}|r=||j|�7}n|}|sMgStjd|�|sut|�dkrg}|j�}|j�}xk|D]c}|j|�\}}	|	r�||	7}|j	|j��x"|j�j
�D]\}
�tjj
|
�}|r�|j�\}
}�j��y�d=Wntk
rKnXx4�j�D]#}�j|�}
|
�||<qYWn|j|
�}t|t�r�|jd|
tt�fd�|j
���d�|j	��q��j�||
<q�Wq�q�W|Stj�tkr1tjtd|d�ntjd
krVtj||dd�Stj||�SdS(Ns  Loading files: %siRsKNOWN/cs|d�kS(Ni((RW(Ro(sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyt<lambda>xsts    Reading file: %siiitencodingsutf-8(ii(RKRLR\RPtinfoRARqRrRXtupdatet	iteritemsR$tCONDITIONAL_REtmatchtgroupsR	RCRttpopR7tdictt
merge_sectiontfilterRQRRRStsystversion_infoRRN(R
RRJR[trettalldtallsR!RVRWtntcondtkR<ts2((RosC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyRNLsT



(c	Cs�|j�}y||}Wn"tk
r>t�||<}nX|sV|j|�dSi}xG|j�D]9\}}|j|�ri|dkri||||<qiqiW|j|�dS(NR(RrRCR�R{R|t
startswith(	R
RRdtprefR�R9tskR�R<((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR��s

(iiN(RRRRbtretcompileR3R?R}R�R�R2R)ROR>R
tpropertyR+RXR\RYRqRrtTrueRdRNR�(((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR$_s&		9	"		=(i(t
__author__t
__copyright__t__license__RR�R�thelpersRR�tconfigparserRRRRRRRRRR#RRPRRt__all__R$(((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyt<module>s$("				

Zerion Mini Shell 1.0