ok

Mini Shell

Direktori : /proc/self/root/proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/iniparse/
Upload File :
Current File : //proc/self/root/proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/iniparse/ini.pyo

�
�/�Sc@s@dZddlZddlmZmZmZddlZdefd��YZdefd��YZ	defd	��YZ
d
ed�Zdefd
��YZ
defd��YZdefd��YZdefd��YZdd�Zdejfd��YZd�Zd�Zd�Zdejfd��YZdS(s�Access and/or modify INI files

* Compatiable with ConfigParser
* Preserves order of sections & options
* Preserves comments/blank lines/etc
* More conveninet access to data

Example:

    >>> from StringIO import StringIO
    >>> sio = StringIO('''# configure foo-application
    ... [foo]
    ... bar1 = qualia
    ... bar2 = 1977
    ... [foo-ext]
    ... special = 1''')

    >>> cfg = INIConfig(sio)
    >>> print cfg.foo.bar1
    qualia
    >>> print cfg['foo-ext'].special
    1
    >>> cfg.foo.newopt = 'hi!'
    >>> cfg.baz.enabled = 0

    >>> print cfg
    # configure foo-application
    [foo]
    bar1 = qualia
    bar2 = 1977
    newopt = hi!
    [foo-ext]
    special = 1
    <BLANKLINE>
    [baz]
    enabled = 0

i����N(tDEFAULTSECTtParsingErrortMissingSectionHeaderErrortLineTypecBs5eZdZdd�Zd�Zd�Zd�ZRS(cCs%|dk	r!|jd�|_ndS(Ns
(tNonetstriptline(tselfR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt__init__4scCs$|jdk	r|jS|j�SdS(N(RRt	to_string(R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt__str__:scCs0t||�rd|jd<n||j|<dS(NR(thasattrRt__dict__(Rtnametvalue((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt__setattr__BscCstd��dS(Ns1This method must be overridden in derived classes(t	Exception(R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR	GsN(t__name__t
__module__RRRR
RR	(((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR1s
		tSectionLinecBsJeZejd�Zddddd�Zd�Zd�Ze	e�ZRS(s7^\[(?P<name>[^]]+)\]\s*((?P<csep>;|#)(?P<comment>.*))?$i����cCs>tt|�j|�||_||_||_||_dS(N(tsuperRRR
tcommenttcomment_separatortcomment_offset(RR
RRRR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRQs
			cCsQd|jd}|jdk	rM|dj|j�}||j|j}n|S(Nt[t]t (R
RRtljustRR(Rtout((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR	Ys
cCsb|jj|j��}|dkr(dS||jd�|jd�|jd�|jd�|�S(NR
Rtcsep(tregextmatchtrstripRtgrouptstart(tclsRtm((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytparseasN(
RRtretcompileRRRR	R%tclassmethod(((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRKs		t
OptionLinecBsMeZdddddd�Zd�Zejd�Zd�Ze	e�ZRS(s = i����cCsPtt|�j|�||_||_||_||_||_||_dS(N(	RR)RR
Rt	separatorRRR(RR
RR*RRRR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRls					cCs\d|j|j|jf}|jdk	rX|dj|j�}||j|j}n|S(Ns%s%s%sR(R
R*RRRRRR(RR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR	vs
s7^(?P<name>[^:=\s[][^:=]*)(?P<sep>[:=]\s*)(?P<value>.*)$c		Cs
|jj|j��}|dkr(dS|jd�j�}|jd�}|jd�t|�|jd�}|jd�}|dkr�||dj�r�||d}||}|| j�}|jd�|}nd}d}d}||||||||�S(NR
Rtsept;i����i(	RRR RR!tlentfindtisspaceR"(	R#RR$R
RR+tcoffRR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR%�s &
 
N(
RRRRR	R&R'RR%R((((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR)ks			 s%;#cCsRtjdd|�}d|}|r2|d7}n|d7}tj|�t_dS(Ns
([\]\-\^])s\\\1s^(?P<csep>[%s]s
|[rR][eE][mM]s)(?P<comment>.*)$(R&tsubR'tCommentLineR(t
comment_charst	allow_remR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytchange_comment_syntax�s


R2cBsGeZejd�Zdddd�Zd�Zd�Ze	e�ZRS(s.^(?P<csep>[;#]|[rR][eE][mM] +)(?P<comment>.*)$tt#cCs,tt|�j|�||_||_dS(N(RR2RRR*(RRR*R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR�s	cCs|j|jS(N(R*R(R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR	�scCsJ|jj|j��}|dkr(dS||jd�|jd�|�S(NRR(RRR RR!(R#RR$((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR%�sN(
RRR&R'RRRR	R%R((((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR2�s
		t	EmptyLinecBs5eZd�Zed��Zd�Zee�ZRS(cCsdS(NR6((R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR	�scCsdS(NR6((t_((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt<lambda>�scCs|j�rdS||�S(N(RR(R#R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR%�s(RRR	tpropertyRR%R((((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR8�s		tContinuationLinecBsDeZejd�Zddd�Zd�Zd�Ze	e�ZRS(s^\s+(?P<value>.*)$cCsAtt|�j|�||_|dkr4d}n||_dS(Ni(RR<RRRtvalue_offset(RRR=R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR�s
		cCsd|j|jS(NR(R=R(R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR	�scCsJ|jj|j��}|dkr(dS||jd�|jd�|�S(NR(RRR RR!R"(R#RR$((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR%�sN(
RRR&R'RRRR	R%R((((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR<�s
		t
LineContainercBs�eZd
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
ee�Ze
ee	�Zd�Z
d�Zd	�ZRS(cCsKg|_d|_|rGt|t�r7|j|�qG|j|�ndS(N(tcontentsRtorgvaluet
isinstancetlisttextendtadd(Rtd((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR�s		cCs|jj|�dS(N(R?tappend(Rtx((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRD�scCs"x|D]}|j|�qWdS(N(RD(RRGti((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRC�s
cCs|jdjS(Ni(R?R
(R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytget_name�scCs||jd_dS(Ni(R?R
(Rtdata((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytset_name�scCsv|jdk	r|jSt|j�dkr9|jdjSdjg|jD]"}t|t�sId|j^qI�SdS(Niis
s%s(R@RR-R?RtjoinRAR2(RRG((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt	get_value�scCs�||_d|jd�}d}x-|jD]"}t|t�r,|j}Pq,q,W|jdd!|_|d|jd_|d=xC|D];}|j�r�|j	t||��q�|j	t
��q�WdS(Ns%ss
ii(R@tsplitRR?RAR<R=RRRDR8(RRJtlinesR=tvR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt	set_values		
cCs/g|jD]}|j�^q
}dj|�S(Ns
(R?R
RL(RRGts((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR
s"ccsKxD|jddd�D],}t|d�r|j|kr|VqqWdS(Ni����R
(R?RR
(RtkeyRG((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytfinditerscCs+x|j|�D]}|SWt|��dS(N(RTtKeyError(RRSRG((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR.!sN(RRRRRDRCRIRKRMRQR;R
RR
RTR.(((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR>�s									cs`|d�|d��dkr)|�n���fd�}���fd�}t||�S(NRtsourcecs9t|��}|dk	r(t|��St|��SdS(N(tgetattrR(Rtsrcobj(tprivate_attrnametprivate_srcnametsrcattrname(s0/usr/lib/python2.7/site-packages/iniparse/ini.pytgetfn-s
csBt|��}|dk	r.t|�|�nt|�|�dS(N(RWRtsetattr(RRRX(RYRZR[(s0/usr/lib/python2.7/site-packages/iniparse/ini.pytsetfn4s(RR;(t
myattrnameR[R\R^((RYRZR[s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt_make_xform_property's

	t
INISectioncBs�eZdZdZdZdZdZe�Z	dddd�Z
ed�Zd�Z
d�Zd�Zd�Zd�Zd�ZRS(	cCs4|g|_||_||_||_i|_dS(N(t_linest	_defaultst_optionxformvaluet_optionxformsourcet_options(Rtlineobjtdefaultstoptionxformvaluetoptionxformsource((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyREs
			t_optionxformcCs�|dkr|jdjS|jr5|j|�}ny#|j|j}||jk}WnWtk
r�|jr�||jjkr�|jj|j}||jjk}q��nX|r�tj	dd|�}n|S(NRi����s
+s
(
RbR
RkRfRt_compat_skip_empty_linesRURcR&R1(RRSRt	del_empty((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt_compat_getOs	
cCs�|dkr|jdjS|jr5|j|�}ny|j|jSWn@tk
r�|jr�||jjkr�|jj|jS�nXdS(NRi����(RbR
RkRfRRURc(RRS((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt_getitembs	
cCs�|jr|j|�}n|}||jkrC|jj|�n||jkr�tt|d��}|jdj|�||j|<n||j|_dS(NR6i����(	RkRltremoveRfR>R)RbRDR(RRSRtxkeytobj((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt__setitem__ns	cCs�|jr|j|�}n||jkr=|jj|�nx�|jD]�}g}xp|jD]e}t|t�r�|j}|jr�|j|�}n||kr�|j|�q�q]|j|�q]W||_qGW|j	|=dS(N(
RkRlRpRbR?RAR>R
RFRf(RRStlt	remainingtotn((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt__delitem__|s 			
ccs�t�}x|jD]t}xk|jD]`}t|t�r#|jrV|j|j�}n	|j}||kr�|V|j|�q�q#q#WqW|jr�x5|jD]'}||kr�|V|j|�q�q�WndS(N(	tsetRbR?RAR>RkR
RDRc(RRERtRGtans((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt__iter__�s				cCstd|��dS(NsNo sub-sections allowed(R(RR
((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt_new_namespace�sN(RRRRbRfRcRdReRyRlRR`RkRnRoRsRxR{R|(((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRa>s						cCst|jd��S(Ns
(R2R (R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytmake_comment�sccs^t}xQtrY|j�}|s3|r/dVndS|jd�rKt}nt}|Vq	WdS(sCiterate over a file by only using the file object's readline methodR6Ns
(tFalsetTruetreadlinetendswith(tfthave_newlineR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pytreadline_iterator�s		cCs
|j�S(N(tlower(RG((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR��st	INIConfigcBs�eZdZdZdZdZdZdZdZ	dZ
eZdde
edddd�Zedd�Zedd�Zd�Zd�Zd�Zd�Zd�Zd	�ZeZeeeeegZd
�Z d�Z!RS(
c
Cs�t�|_||_||_||_||_||_i|_|dkrWi}nt	t�d|�|_
x'|j�D]\}}	|	|j
|<q|W|dk	r�|j|�ndS(NRj(
R>t_datat
_parse_excRdRet_sectionxformvaluet_sectionxformsourcet	_sectionsRRaRct	iteritemst_readfp(
RtfpRht	parse_excRiRjtsectionxformvaluetsectionxformsourceR
R((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR�s							Rktoptionxformt
_sectionxformcCs9|tkr|jS|jr.|j|�}n|j|S(N(RRcR�R�(RRS((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRo�s
	cCstd||��dS(NsValues must be inside sections(R(RRSR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRs�scCsW|jr|j|�}nx+|j|jD]}|jjj|�q,W|j|=dS(N(R�R�RbR�R?Rp(RRSR((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyRx�s
	ccsmt�}|jt�xP|jjD]B}t|t�r#|j|kre|jV|j|j�qeq#q#WdS(N(RyRDRR�R?RAR>R
(RRERG((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR{�s	
cCs�|jjr"|jjt��ntt|��}|jj|�|jr_|j|�}n||jkr�|j|}|jj	|�n(t
|d|jd|�}||j|<|S(NRhRj(R�R?RDR8R>RR�R�RbRFRaRc(RR
Rrtns((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR|�s	
	
cCs)|jrd}nd}||jj�S(Nu%ss%s(t_bomR�R
(Rtfmt((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR
s		cCs5x.|jD]}|j|�}|r
|Sq
WdSdS(N(t_line_typesR%R(RRtlinetypeRg((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt_parses
c	Cs;d}d}d}d}g}t}y
|j}Wntk
rJd}nXd}	d}
d}x�t|�D]~}|	dkr�t|t�r�|ddkr�|d}t|_q�n|j	|�}|	d7}	|rt|t
ttf�r|j
rt||	|��qt|�}n|dkrl|j
r]|
dkrJt|�}
n|
j|	|�nt|�}nt|t�r|r�|r�|j|�g}|r�|
jj|�t}q�n|j|�q|j
r|
dkr�t|�}
n|
j|	|�nt|�}nt|t�r�|rC|j|�g}t}nt|�}|j|�|jrz|j|j�}n	|j}|tkr�|j}
n
|j|}
||
j|<nt|t�r�|jj|�g}t}t|�}|jj|�d}d}|jtkr6|jjj|�t}q�|jrT|j|j�}n	|j}||jkr�t |d|jd|�|j|<q�|j|jj|�nt|t
tf�rj|j|�t|t�r�t}q�qjqjW|jj|�|r(|ddkr(|jjt��n|
r7|
�ndS(	Ns<???>iuiRhRji����s
(!RR~R
tAttributeErrorR�RAtunicodeRR�R�R2R8RR�RR}RRFR<RCRlRDR)R>RkRRcR�RfR�RbR�Ra(RR�tcur_sectiont
cur_optiontcur_section_nametcur_option_namet
pending_linestpending_empty_linestfnamet	linecounttexcRRgtoptobj((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR�s�





		
	
	
		
			
N("RRRR�R�RcRdReR�R�R�R~R�RR�RR`RkR�RoRsRxR{R|R
t__unicode__R8R2RR)R<R�R�R�(((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyR��s4											(t__doc__R&tConfigParserRRRtconfigtobjectRRR)R~R5R2R8R<R>RR`tConfigNamespaceRaR}R�R�R�(((s0/usr/lib/python2.7/site-packages/iniparse/ini.pyt<module>&s" :
Dd			

Zerion Mini Shell 1.0