ó  fâNc@sáddlZddlZddlZddlZddlZddlZddlZddlZddlj Z de fd„ƒYZ de fd„ƒYZ de fd„ƒYZ de fd „ƒYZd e fd „ƒYZdS( iÿÿÿÿNtCfgFilecBs’eZdZded„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(s~ Solaris configuration file editor... make it easier to modify Solaris line-oriented configuration files from actions t#c Cs)||_||_||_t|_g|jƒD])}|dd|dd|df^q1}|jƒg|D]} | d^qq|_td„|Dƒƒ|_ t j |ƒ|_ td„|jDƒƒ|_ t|tƒrï|g|_n ||_i|_t|jƒt|jƒks%t‚dS(Niiicss#|]}|d|dfVqdS(iiN((t.0te((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys 8scss|]}|dfVqdS(iN((Rtn((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys ;s(tfilenamet separatortcontinuation_linestFalset needswritingtitemstsortt column_namestdicttdefault_valuestretcompiletcomment_regexpt max_lengthst isinstancetstrtkeystindextsettAssertionError( tselfRRR Rt comment_matchRtvtlR((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt__init__-s    <    cCs d|j|j|j|jfS(NsCfgFile(%s):%s:%s:%s(RRR R(R((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt__str__FscCs|jS(N(R (R((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pytgetcolumnnamesJscCs|jj|ƒS(N(Rtmatch(Rtline((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt iscommentlineMscCs|j|jƒS(N(tsplitR(RR!((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt splitlinePscCs]g|jD](}|j|d|j|dg^q }|jƒg|D]}|d^qIS(sm given self, return list of lines to be printed. default impl preserves orignal + insertion orderiii(RR (RRtlines((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt getfilelinesSs8 cs`tjj|jƒr\t|jƒ}d}x|D]}d}x7|jrv|ddkrv|d7}||jƒ7}q@W|jdƒ}|j|ƒr®|d|f|j |ns(tostpathtexistsRtopenRtnexttrstripR"tNoneRR$tlenR R tzipttupleRtcloseRR (RtfiletlinenoR!tlinecnttcols((R(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pytreadfile[s&  2 csD|jjt‡fd†|jDƒƒdƒ}|r<|dSiSdS(Nc3s|]}ˆ|VqdS(N((RR'(ttemplate(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys wsi(RtgetR2RR/(RR9tval((R9s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pytgetvaluevs.cst‡fd†ˆjDƒƒS(sK returns dictionary of default string values - ignores other types c3s8|].}tˆj|tƒr|ˆj|fVqdS(N(RRR(Rti(R(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys €s(R R(R((Rs2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pytgetdefaultvalues}scsn|jt‡fd†|jDƒƒjƒ}x.|jD]#}|ˆkr6ˆ|||‡sN(RR2RtcopyR tsetvalue(RR9torigtname((R9s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt updatevalue„s , csex~ˆjD]s}|ˆkr ˆj|d kr?td|‚q}tˆj|ƒriˆj|ƒˆ|›sic3s|]}ˆd|VqdS(iN((RR'(RA(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys Ÿsc3s |]}ˆj|dVqdS(iN(R(RR'(R(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys ¡siic3s|]}ˆ|VqdS(N((RR'(R9(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys ¥sN( R RR/t RuntimeErrortcallableRR:R2Rtmaxt valuetostrtTrueR (RR9tfieldR5R!((RARR9s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyR@s$  . & &/cs0|jt‡fd†|jDƒƒ=t|_dS(Nc3s|]}ˆ|VqdS(N((RR'(R9(s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pys ªs(RR2RRHR (RR9((R9s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt removevalue©s#cCs2d|jjg|jD]}d||^qƒS(s! print out values in file format s%s(RtjoinR (RR9tkey((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyRG­s cCsÎ|js dStj|jƒ}tjdtjj|jƒƒ}tj|ddƒ}|d}tj ||j ƒtj ||j |j ƒx|jƒD]}||IJq™W|jƒtj||jƒdS(Ntdiritwi(R R)tstatRttempfiletmkstempR*tdirnametfdopentchmodtst_modetchowntst_uidtst_gidR&R3trename(RtstttempdataR4RBR((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyt writefile´s !  (t__name__t __module__t__doc__RRRRR"R$R&R8R<R>RCR@RJRGR\(((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyR)s           t PasswordFilecBseZdZed„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„ZRS(shManage the passwd and shadow together. Note that insertion/deletion of +/- fields isn't supportedcCsOttjj|dƒdid$d6d%d6d&d 6d'd 6d(d6d)d6d*d6dddƒ|_tjdtjƒƒj }ttjj|dƒdi d+d6d,d6d|fd6d-d6d.d6d/d6d0d6d1d 6d2d"6dddƒ|_ ||_ t j tjj|j d#ƒƒ|_ |r+|jƒn|jƒ|jƒ|jjd R{Ru(Rta((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyR>'scCs|jjƒdS(N(RwRy(R((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyRy,scCs|jjƒdS(N(Rwtunlock(R((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyR…/s(R]R^R_RRRR<RCR@RJRzRR8R\RƒR>RyR…(((s2/usr/lib/python2.7/vendor-packages/pkg/cfgfiles.pyR`És $           t GroupFilecBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s manage the group filecCsz||_tj|tjj|jƒdƒdidd6dd6dd 6dd 6dd d ƒ|jƒ|j ƒ|j d s         iO&