ó Üœ^c@sdZdZdZddlZddlZddlZddlmZejdkr–ddl m Z m Z m Z mZmZd e fd „ƒYZn@dd l m Z m Z mZmZe je _d „Zee _d „ZeeƒZdZdgZde fd„ƒ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(sDecorator 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 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ƒ|ddSxh|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| ||tƒ||<}nX|sV|j|ƒdSi}xG|jƒD]9\}}|j|ƒ ri|dkri||||R tpropertyR+RXR\RYRqRrtTrueRdRNR(((sC/usr/lib/python2.7/site-packages/fail2ban/client/configparserinc.pyR$_s&  9   "    <(ii(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.pyts$   ("