ok

Mini Shell

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

�
���Kc@s�dZddlZddlmZmZmZmZmZmZm	Z	m
Z
ddlmZmZm
Z
mZddlZdefd��YZdefd��YZd	efd
��YZdefd��YZdS(
s(Compatibility interfaces for ConfigParser

Interfaces of ConfigParser, RawConfigParser and SafeConfigParser
should be completely identical to the Python standard library
versions.  Tested with the unit tests included with Python-2.3.4

The underlying INIConfig object can be accessed as cfg.data
i����N(tDuplicateSectionErrortNoSectionErrort
NoOptionErrortInterpolationMissingOptionErrortInterpolationDepthErrortInterpolationSyntaxErrortDEFAULTSECTtMAX_INTERPOLATION_DEPTH(tErrortInterpolationErrortMissingSectionHeaderErrortParsingErrortRawConfigParsercBs�eZded�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zdd�Zdd	�Z
d
�Zd�Zd�Zied
6ed6ed6ed6ed6ed6ed6ed6Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs:|tkrtd��ntjd|d|�|_dS(NsCustom dict types not supportedtdefaultstoptionxformsource(tdictt
ValueErrortinit	INIConfigtdata(tselfR
t	dict_type((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyt__init__scCs
|j�S(N(tlower(Rt	optionstr((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytoptionxform#scCs=i}|jj}x$|jD]}|j|�||<qW|S(N(Rt	_defaultst_optionst_compat_get(Rtdtsecobjtname((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR
&s
cCs
t|j�S(s3Return a list of section names, excluding [DEFAULT](tlistR(R((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytsections-scCsT|j�dkr"td|�n|j|�r@t|��n|jj|�dS(s�Create a new section in the configuration.

        Raise DuplicateSectionError if a section by the specified name
        already exists.  Raise ValueError if name is DEFAULT or any of
        its case-insensitive variants.
        tdefaultsInvalid section name: %sN(RRthas_sectionRRt_new_namespace(Rtsection((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytadd_section1s
	cCs
||jkS(s~Indicate whether the named section is present in the configuration.

        The DEFAULT section is not acknowledged.
        (R(RR%((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR#BscCs0||jkr t|j|�St|��dS(s9Return a list of option names for the given section name.N(RR R(RR%((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytoptionsIscCs�g}t|t�r!|g}nx\|D]T}yt|�}Wntk
rTq(nX|j|�|jj|�|j�q(W|S(s�Read and parse a filename or a list of filenames.

        Files that cannot be opened are silently ignored; this is
        designed so that you can specify a list of potential
        configuration file locations (e.g. current directory, user's
        home directory, systemwide directory), and all existing
        configuration files in the list will be read.  A single
        filename may also be given.
        (t
isinstancet
basestringtopentIOErrortappendRt_readfptclose(Rt	filenamest
files_readtfilenametfp((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytreadPs



cCs|jj|�dS(sLike read() but the argument must be a file-like object.

        The `fp' argument must have a `readline' method.  Optional
        second argument is the `filename', which if not given, is
        taken from fp.name.  If fp has no `name' attribute, `<???>' is
        used.
        N(RR-(RR2R1((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytreadfpgscCs||j|�st|��n|dk	rC||krC||}n|j|}||kri|j|�St||��dS(N(R#RtNoneRRR(RR%toptiontvarstvaluetsec((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytgetqs


cCs`||jkrPg}x4|j|D]%}|j||j||�f�q#W|St|��dS(N(RR,R:R(RR%tanstopt((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytitems}s#cCst|j||��S(N(tintR:(RR%R6((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytgetint�scCst|j||��S(N(tfloatR:(RR%R6((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytgetfloat�st1tyesttruetont0tnotfalsetoffcCsH|j||�}|j�|jkr7td|�n|j|j�S(NsNot a boolean: %s(R:Rt_boolean_statesR(RR%R6tv((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyt
getboolean�scCs5||jkr|j|}nt|��||kS(s=Check for the existence of a given option in a given section.(RR(RR%R6R9((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyt
has_option�scCs3||jkr#||j||<nt|��dS(sSet an option.N(RR(RR%R6R8((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytset�scCs|jt|j��dS(s?Write an .ini-format representation of the configuration state.N(twritetstrR(RR2((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyRO�scCsJ||jkr|j|}nt|��||krB||=dSdSdS(sRemove an option.iiN(RR(RR%R6R9((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyt
remove_option�scCs!|j|�stS|j|=tS(sRemove a file section.(R#tFalseRtTrue(RR%((s3/usr/lib/python2.7/site-packages/iniparse/compat.pytremove_section�s
N(t__name__t
__module__R5RRRR
R!R&R#R'R3R4R:R=R?RARSRRRJRLRMRNRORQRT(((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyRs*							
									t
ConfigDictcBs eZdZd�Zd�ZRS(s*Present a dict interface to a ini section.cCs||_||_||_dS(N(tcfgR%R7(RRXR%R7((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR�s		cCsMy#tj|j|j||j�SWn#ttfk
rHt|��nXdS(N(RR:RXR%R7RRtKeyError(Rtkey((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyt__getitem__�s#(RURVt__doc__RR[(((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyRW�s	tConfigParsercBs/eZedd�Zd�Zedd�ZRS(cCs�|tkr+|j|�r+t|��n|j|�}tj||||�}|r\|St|||�}|j||||�SdS(s�Get an option value for a given section.

        All % interpolations are expanded in the return values, based on the
        defaults passed into the constructor, unless the optional argument
        `raw' is true.  Additional substitutions may be provided using the
        `vars' argument, which must be a dictionary whose contents overrides
        any pre-existing defaults.

        The section DEFAULT is special.
        N(RR#RRRR:RWt_interpolate(RR%R6trawR7R8R((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR:�scCs�|}t}xd|rr|d8}d|krny||}Wqotk
rj}t||||jd��qoXqPqW|jd�dkr�t|||��n|S(Nis%(ii����(RRYRtargstfindR(RR%R6trawvalR7R8tdepthte((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR^�s	
 c	Cs&|tkr+|j|�r+t|��n|dkrMt|j|�}nMg}x1|j|D]"}||kra|j|�qaqaW|j|j��d|kr�|j	d�nt
|||�}|r�g|D]}|||f^q�Sg|D](}||j|||||�f^q�SdS(s�Return a list of tuples with (name, value) for each option
        in the section.

        All % interpolations are expanded in the return values, based on the
        defaults passed into the constructor, unless the optional argument
        `raw' is true.  Additional substitutions may be provided using the
        `vars' argument, which must be a dictionary whose contents overrides
        any pre-existing defaults.

        The section DEFAULT is special.
        RUN(RR#RR5R RR,textendtkeystremoveRWR^(RR%R_R7R'txRR6((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR=�s"N(RURVRRR5R:R^R=(((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR]�s	tSafeConfigParsercBsSeZejd�Zejd�Zd�Zd�Zejd�jZ	d�Z
RS(s
%\(([^)]+)\)ss%[^%]|%$cCs�t|t�std��n|jjd|�}|jj|�}|rjtd||j�f��nt	j
||||�dS(Nsoption values must be stringsts1invalid interpolation syntax in %r at position %d(R(R)t	TypeErrort
_interpvar_retsubt_badpercent_retsearchRtstartR]RN(RR%R6R8t	tmp_valuetm((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyRNscCs/g}|j|||||d�dj|�S(NiRj(t_interpolate_sometjoin(RR%R6RbR7tL((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyR^+scCs�|tkr!t|||��nx�|r�|jd�}|dkrV|j|�dS|dkr�|j|| �||}n|dd!}|dkr�|jd�|d}q$|dkr�|j|�}	|	dkr�t||d|��n|	jd�}
||	j�}y||
}Wn&t	k
rHt
||||
��nXd|krx|j||||||d�q�|j|�q$t||dt|���q$WdS(Nt%iiit(s'bad interpolation variable reference %rs+'%' must be followed by '%' or '(', found: (
RRRaR,t_interpvar_matchR5RtgrouptendRYRRstrepr(RR6taccumtrestR%tmapRctptcRrtvarRK((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyRs3sB	




	
(RURVtretcompileRlRnRNR^tmatchRxRs(((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyRis		(R\R�R]RRRRRRRRRR	R
RRtobjectRRWRi(((s3/usr/lib/python2.7/site-packages/iniparse/compat.pyt<module>s:	"�N

Zerion Mini Shell 1.0