
    g2                     ^    S SK r S SKrS SKrS SKJrJr  S SKJrJr  S SK	J
r
   " S S\
5      rg)    N)ABCMetaabstractmethod)Element
SubElement)GPParserc                       \ rS rSrSrSrSr " S S5      r " S S\5      r " S	 S
\5      r	 " S S\5      r
 " S S\5      r " S S\5      r " S S\5      r " S S\5      rS rS rS rS rSrg)GptTmplInfParser   Nzutf-16zutf-16lec                   ^    \ rS rSr\rS r\S 5       r\S 5       r	\S 5       r
\S 5       rSrg)	GptTmplInfParser.AbstractParam#   c                     / U l         g N
param_list)selfs    7/usr/lib/python3/dist-packages/samba/gp_parse/gp_inf.py__init__'GptTmplInfParser.AbstractParam.__init__&   s	     DO    c                     g r    r   lines     r   parse$GptTmplInfParser.AbstractParam.parse)       r   c                     g r   r   r   headerfps      r   write_section,GptTmplInfParser.AbstractParam.write_section-   r   r   c                     g r   r   r   
xml_parents     r   	build_xml(GptTmplInfParser.AbstractParam.build_xml1   r   r   c                     g r   r   r   sections     r   from_xml'GptTmplInfParser.AbstractParam.from_xml5   r   r   r   N)__name__
__module____qualname____firstlineno__r   __metaclass__r   r   r   r"   r'   r,   __static_attributes__r   r   r   AbstractParamr   #   s\    	! 
	 
	 
	 
	 
	 
	 
	 
	r   r4   c                   ,    \ rS rSrS rS rS rS rSrg)GptTmplInfParser.IniParam9   c                     UR                  S5      u  p#U R                  R                  UR                  5       UR                  5       45        g )N=splitr   appendstrip)r   r   keyvals       r   r   GptTmplInfParser.IniParam.parse<   s9    zz#HCOO""CIIK$'IIK$1 2r   c                     [        U R                  5      S:X  a  g UR                  SU-  5        U R                   H  u  p4UR                  U< SU< S35        M      g )Nr   [%s]
 = 
lenr   write)r   r    r!   key_outval_outs        r   r"   'GptTmplInfParser.IniParam.write_sectionD   sN    4??#)HH[6)*$(OO 7+24 5 %4r   c                     U R                    H5  u  p#[        US5      n[        US5      n[        US5      nX%l        X6l        M7     g )N	ParameterKeyValuer   r   text)r   r&   key_inival_inichildr>   values          r   r'   #GptTmplInfParser.IniParam.build_xmlL   sA    $(OO ":{; ."5'2"$
 %4r   c                     UR                  S5       HZ  nUR                  S5      R                  nUR                  S5      R                  nUc  SnU R                  R	                  X445        M\     g NrL   rM   rN    findallfindrP   r   r<   )r   r+   paramr>   rT   s        r   r,   "GptTmplInfParser.IniParam.from_xmlT   s[     5jj',,

7+00=E&&|4 6r   r   N	r.   r/   r0   r1   r   r"   r'   r,   r3   r   r   r   IniParamr6   9   s    	2	5	%	5r   r_   c                   ,    \ rS rSrS rS rS rS rSrg)GptTmplInfParser.RegParam]   c                 :    U R                   R                  U5        g r   )r   r<   r   s     r   r   GptTmplInfParser.RegParam.parse_   s    OO""4(r   c                     [        U R                  5      S:X  a  g UR                  SU-  5        U R                   H  nUR                  SU-  5        M     g )Nr   rB   z%s
rE   r   r    r!   r\   s       r   r"   'GptTmplInfParser.RegParam.write_sectiond   sF    4??#)HH[6)*U*+ )r   c                 f    U R                    H!  n[        US5      n[        US5      nX$l        M#     g )NrL   rN   rO   )r   r&   rR   rS   rT   s        r   r'   #GptTmplInfParser.RegParam.build_xmlk   s-    ??":{;"5'2$
 +r   c                     UR                  S5       H>  nUR                  S5      R                  nUc  SnU R                  R	                  U5        M@     g NrL   rN   rX   rY   )r   r+   r\   rT   s       r   r,   "GptTmplInfParser.RegParam.from_xmlq   sE     5

7+00=E&&u- 6r   r   Nr^   r   r   r   RegParamra   ]   s    	)
	,	%	.r   rm   c                   ,    \ rS rSrS rS rS rS rSrg)!GptTmplInfParser.PrivSIDListParamy   c                     UR                  S5      u  p#U R                  R                  UR                  5       UR                  S5       Vs/ s H  oDR                  5       PM     sn45        g s  snf )Nr9   ,r:   r   r   r>   r?   xs        r   r   'GptTmplInfParser.PrivSIDListParam.parse{   sS    zz#HCOO""CIIK8;		#$G1WWY$G$I J$Gs   A-
c                     [        U R                  5      S:X  a  g UR                  SU-  5        U R                   H/  u  p4SR                  U5      nUR                  U< SU< S35        M1     g )Nr   rB   rr   rC   rD   rF   r   rG   join)r   r    r!   rH   r?   rI   s         r   r"   /GptTmplInfParser.PrivSIDListParam.write_section   sU    4??#)HH[6)* $))C.7G<= !0r   c                     U R                    HM  u  p#[        US5      n[        US5      nX%l        U H$  n[        US5      nSUR                  S'   Xgl        M&     MO     g )NrL   rM   rN   TRUEuser_idr   r   rP   attribr   r&   rQ   sid_listrS   r>   rR   rT   s           r   r'   +GptTmplInfParser.PrivSIDListParam.build_xml   sY    %)__!":{; ."'G&ug6E.4ELL+!(J  (	 &5r   c                    UR                  S5       Hv  nUR                  S5      R                  n/ nUR                  S5       H%  nUR                  nUc  SnUR                  U5        M'     U R                  R                  X445        Mx     g rW   )rZ   r[   rP   r<   r   )r   r+   r\   r>   r   r?   rT   s          r   r,   *GptTmplInfParser.PrivSIDListParam.from_xml   sv     5jj',, ==1CHHE} "OOE* 2 &&7 6r   r   Nr^   r   r   r   PrivSIDListParamro   y   s    	J	>	)	8r   r   c                   ,    \ rS rSrS rS rS rS rSrg)!GptTmplInfParser.NameModeACLParam   c                    / SQnSnUS:w  af  US S S:X  a%  USS  nUR                  S5      nUS U X#'   XS-   S  nO0US S S:X  a  USS  nUS-  nOUR                  S5      nUS U X#'   XS  nUS:w  a  Mf  U R                  R                  U5        g )N)NNNr   rX      "rr   )r[   r   r<   )r   r   
parameterscurrent_argfindexs        r   r   'GptTmplInfParser.NameModeACLParam.parse   s    +JK"*8s?8D!YYs^F.27FmJ+
,D"1X_8D1$K "YYs^F.27FmJ+=D "*& OO"":.r   c                     [        U R                  5      S:X  a  g UR                  SU-  5        U R                   H   nUR                  S[        U5      -  5        M"     g )Nr   rB   z"%s",%s,"%s"
)rF   r   rG   tuplerf   s       r   r"   /GptTmplInfParser.NameModeACLParam.write_section   sK    4??#)HH[6)*,uU|;< )r   c                     U R                    H`  n[        US5      n[        US5      nUS   Ul        [        US5      nUS   Ul        [        US5      nSUR                  S'   US   Ul        Mb     g )NrL   rN   r   r   r{   acl   r}   )r   r&   name_mode_aclrS   rT   s        r   r'   +GptTmplInfParser.NameModeACLParam.build_xml   sr    !%":{;"5'2*1-
"5'2*1-
"5'2&,U#*1-
 "1r   c                     UR                  S5       H[  nUR                  S5       Vs/ s H!  o3R                  (       a  UR                  OSPM#     nnU R                  R                  U5        M]     g s  snf rk   )rZ   rP   r   r<   )r   r+   r\   rt   r   s        r   r,   *GptTmplInfParser.NameModeACLParam.from_xml   sW     5CH==QXCY ZCYa66r!9CY Z&&}5 6 Zs   (A2r   Nr^   r   r   r   NameModeACLParamr      s    	/2	=	.	6r   r   c                   ,    \ rS rSrS rS rS rS rSrg)#GptTmplInfParser.MemberSIDListParam   c                    UR                  S5      u  p#UR                  5       nU R                  R                  UR                  S5      UR                  S5       Vs/ s H  oDR                  5       PM     sn45        g s  snf )Nr9   __rr   )r;   r=   r   r<   rs   s        r   r   )GptTmplInfParser.MemberSIDListParam.parse   s`    zz#HC))+COO""CIIdO8;		#$G1WWY$G$I J$Gs   A>
c                     [        U R                  5      S:X  a  g UR                  SU-  5        U R                   H@  u  p4SR                  U5      nSR                  U5      nUR                  U< SU< S35        MB     g )Nr   rB   r   rr   rC   rD   rw   )r   r    r!   r>   r?   rH   rI   s          r   r"   1GptTmplInfParser.MemberSIDListParam.write_section   sb    4??#)HH[6)* OO**S/))C.7G<= ,r   c                    U R                    Hr  u  p#[        US5      n[        US5      nUS   Ul        US   UR                  S'   SUR                  S'   U H$  n[        US5      nSUR                  S'   Xgl        M&     Mt     g )	NrL   rM   r   r   member_typer{   r|   rN   r}   r   s           r   r'   -GptTmplInfParser.MemberSIDListParam.build_xml   s    %)__!":{; ."1:,3AJ

=)(.

9%'G&ug6E.4ELL+!(J  ( &5r   c                 >   UR                  S5       H  nUR                  S5      nUR                  S   n/ nUR                  S5       H%  nUR                  nUc  SnUR	                  U5        M'     U R
                  R	                  UR                  U/U45        M     g )NrL   rM   r   rN   rX   )rZ   r[   r~   rP   r<   r   )r   r+   r\   r>   r   r   r?   rT   s           r   r,   ,GptTmplInfParser.MemberSIDListParam.from_xml   s     5jj'!jj7 ==1CHHE} "OOE* 2 &&;(?'JK 6r   r   Nr^   r   r   r   MemberSIDListParamr      s    	J	>	)	Lr   r   c                   ,    \ rS rSrS rS rS rS rSrg)GptTmplInfParser.UnicodeParami  c                     g r   r   r   s     r   r   #GptTmplInfParser.UnicodeParam.parse	  r   r   c                 &    UR                  S5        g )Nz[Unicode]
Unicode=yes
rG   r   s      r   r"   +GptTmplInfParser.UnicodeParam.write_section  s    HH45r   c                     g r   r   r%   s     r   r'   'GptTmplInfParser.UnicodeParam.build_xml  r   r   c                     g r   r   r*   s     r   r,   &GptTmplInfParser.UnicodeParam.from_xml  r   r   r   Nr^   r   r   r   UnicodeParamr     s    		6		r   r   c                   ,    \ rS rSrS rS rS rS rSrg)GptTmplInfParser.VersionParami  c                     g r   r   r   s     r   r   #GptTmplInfParser.VersionParam.parse  r   r   c                 *    SnUR                  U5        g )Nz.[Version]
signature="$CHICAGO$"
Revision=1
r   )r   r    r!   outs       r   r"   +GptTmplInfParser.VersionParam.write_section  s    ICHHSMr   c                     g r   r   r%   s     r   r'   'GptTmplInfParser.VersionParam.build_xml!  r   r   c                     g r   r   r*   s     r   r,   &GptTmplInfParser.VersionParam.from_xml%  r   r   r   Nr^   r   r   r   VersionParamr     s    				r   r   c                 B   UR                  U R                  5      n[        R                  " SU R	                  5       4SU R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4S	U R                  5       4S
U R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4/5      U l        S nS nUR                  5        Hc  n[        R                  " SU5      nU(       a1  UR                  S5      nXpR                  ;   a  U R                  U   nMR  UR!                  U5        Me     g )NUnicodeVersionSystem AccessKerberos Policy
System LogSecurity LogApplication LogEvent AuditRegistry ValuesPrivilege RightsService General SettingRegistry KeysFile SecurityGroup Membershipz\[(.*)\]r   )decodeencodingcollectionsOrderedDictr   r   r_   rm   r   r   r   sections
splitlinesrematchgroupr   )r   contentsinf_filecurrent_param_parsercurrent_header_namer   r   header_names           r   r   GptTmplInfParser.parse)  sq   ??4==1#//**,-**,-t}}/1DMMO,dmmo.1T]]_-1 $"7"7"9:')>)>)@At4467t4467 $"9"9";<1
 $  $"'')DHH[$/E#kk!n--/+/==+E( !&&t, *r   c                     [         R                  " USU R                  5       nUR                  S5        U R                   H!  nU R                  U   R                  X25        M#     S S S 5        g ! , (       d  f       g = f)Nzwb+u   ﻿)codecsopenoutput_encodingrG   r   r"   )r   filenamefss       r   write_binaryGptTmplInfParser.write_binaryN  s_    [[5--/23GGI]]a ..q4 #/ / /s   AA//
A=c                    [        US5       n[        S5      nU R                   H;  n[        US5      nXER                  S'   U R                  U   R                  U5        M=     U R                  X25        S S S 5        g ! , (       d  f       g = f)NwbGptTmplInfFileSectionname)r   r   r   r   r~   r'   write_pretty_xml)r   r   r   rootsec_infr+   s         r   	write_xmlGptTmplInfParser.write_xmlW  sr    (D!Q+,D==$T95)0v&g&009	 ) !!$* "!!s   A(A>>
Bc                    [         R                  " SU R                  5       4SU R                  5       4SU R	                  5       4SU R	                  5       4SU R	                  5       4SU R	                  5       4SU R	                  5       4SU R	                  5       4S	U R                  5       4S
U R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4SU R                  5       4/5      U l	        UR                  S5       H.  nU R                  UR                  S      R                  U5        M0     g )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r_   rm   r   r   r   r   rZ   r~   r,   )r   r   r   s      r   load_xmlGptTmplInfParser.load_xmlf  s'   #//**,-**,-t}}/1DMMO,dmmo.1T]]_-1 $"7"7"9:')>)>)@At4467t4467 $"9"9";<1
 $ i(AMM!((6*+44Q7 )r   )r   )r.   r/   r0   r1   r   r   r   r4   r_   rm   r   r   r   r   r   r   r   r   r   r3   r   r   r   r	   r	      s    HH O ,"5= "5H.= .8'8= '8R36= 36j/L] /Lb}  } ""-J5
+8r   r	   )r   r   r   abcr   r   xml.etree.ElementTreer   r   samba.gp_parser   r	   r   r   r   <module>r      s'   (   	 ' 5 #\8x \8r   