Spade
Mini Shell
�
�G�`c@s�dZdgZddlZddlZddlZddlZddlmZddl m
Z
mZmZde
fd��YZdS(sifcfg file
parsertifcfgi����N(tlog(tb2utu2btPY2cBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z RS(cCs)i|_g|_||_|j�dS(N(t_configt_deletedtfilenametclear(tselfR((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyt__init__#s cCsi|_g|_dS(N(RR(R ((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyR)s cCs|jj�dS(N(RR(R ((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pytcleanup-scCs|jj|j��S(N(Rtgettstrip(R tkey((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyR0scCsQt|j��}t|j��|j|<||jkrM|jj|�ndS(N(RR
RRtremove(R Rtvaluet_key((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pytset3scCsad}xD|jj�D]3\}}|r5|d7}n|d||f7}qWtr]t|�S|S(Nts
s%s=%s(RtitemsRR(R tsRR((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyt__str__9s
cCs�|j�yt|jd�}Wn,tk
rN}tjd|j|��nXxL|D]D}|sfPn|j�}t|�dksV|dd
kr�qVng|jdd�D]}|j�^q�}t|�dkr�qVnt|d�dkr1|dj d �r1|dj
d �r1|ddd
!|d<n|ddkrGqVn>|jj|d�dk r�tjd|j|j��qVn|d|j|d<qVW|j�dS(NtrsFailed
to load '%s': %siit#t;t=it"i����Rs%%s:
Duplicate option definition:
'%s'(RR(RtopenRt ExceptionRterrorR
tlentsplitt
startswithtendswithRRtNonetwarningtclose(R tftmsgtlinetxtpair((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pytreadBs2
"+&c Csst|j�dkrdSg}yJtjddddtjj|j�dtjj|j�dt �}Wn't
k
r�}tjd|��nXt }t }y"t
j|jdd d
d�}WnNt
k
r}tjj|j�rtjd|j|f��q�d}n�Xx�|D]�}|s)Pn|jd
�}t|�dkri|s�|jd�t}q�q|ddkr�t }|j|�|jd�q|jdd�}t|�dkr�t }|j|d�qn|dj�} |dj�}
t|
�dkr=|
jd�r=|
jd�r=|
dd!}
n| |kr�| |jkr�|j| |
kr�t }|jd| |j| f�t}n/| |jkr�t}nt }|j|d�|j| �qt}qWt|j�dkrWx^|jj�D]J\} }
| |kr$qn|s3t}n|jd| |
f�t}qWn|rj|j�n|j�|s�tj|j�dStjj|j�rytj|jd|j�Wqt
k
r�}tj|j�td|j|f��qXnytj |j|j�Wn<t
k
r[}tj|j�td|j|f��nXtj!|jd�dS(Nitmodetwttprefixs%s.tdirtdeletes!Failed
to open temporary file: %strttencodingsUTF-8sFailed to open
'%s': %ss
u
iRRiRi����u%s=%s
s%s.baksBackup of '%s' failed: %ssFailed to create
'%s':
%si�("RRttempfiletNamedTemporaryFiletostpathtbasenameRtdirnametFalseRRRtioRtexistsR#R
twritetTrueR
R!R"RtappendRR%Rtnametshutiltcopy2tIOErrortmovetchmod(R tdonet temp_fileR'tmodifiedtemptyR&R(tpRR((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyR<_s� ""
"
(
t__name__t
__module__R
RRRRRR+R<(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyR"s (t__doc__t__all__tos.pathR5R:R3R@tfirewall.core.loggerRtfirewall.functionsRRRtobjectR(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ifcfg.pyt<module>s