KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/root/usr/lib/python2.4/site-packages/iniparse/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/root/usr/lib/python2.4/site-packages/iniparse/config.pyo
mò
©«Fc@sLdZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s/Implements basic mechanisms for managing configuration information

* A NAMESPACE is a collection of values and other namepsaces
* A VALUE is a basic value, like 3.1415, or 'Hello World!'
* A NAME identifies a value or namespace within a namespace

The ConfigNamespace class is an abstract class that defines the
basic interface implemented by all config namespace objects.  Two
concrete implementations are included: BasicConfig and INIConfig.

Each is described in detail elsewhere.  However, here's an
example of the capabilities available:

Create config namespace and populate it:

    >>> n = BasicConfig()
    >>> n.playlist.expand_playlist = True
    >>> n.ui.display_clock = True
    >>> n.ui.display_qlength = True
    >>> n.ui.width = 150

Examine data:

    >>> print n.playlist.expand_playlist
    True
    >>> print n['ui']['width']
    150

    >>> print n
    playlist.expand_playlist = True
    ui.display_clock = True
    ui.display_qlength = True
    ui.width = 150

Delete items:

    >>> del n.playlist
    >>> print n
    ui.display_clock = True
    ui.display_qlength = True
    ui.width = 150

Convert it to ini format:

    >>> from iniparse import ini
    >>> i = ini.INIConfig()
    >>> i.import_config(n)

    >>> print i
    [ui]
    display_clock = True
    display_qlength = True
    width = 150
tConfigNamespacecBsYtZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d	„Z
RS(
NcCs
t|ƒS(N(tNotImplementedErrortkey(tselfR((t3/usr/lib/python2.4/site-packages/iniparse/config.pyt__getitem__@scCst||ƒ‚dS(N(RRtvalue(RRR((Rt__setitem__CscCst|ƒ‚dS(N(RR(RR((Rt__delitem__FscCstƒS(N(R(R((Rt__iter__IscCst|ƒ‚dS(N(Rtname(RR
((Rt
new_namespaceLscCs8y|i|ƒSWn tj
ot||ƒSnXdS(N(RRR
tKeyErrort	Undefined(RR
((Rt__getattr__OscCsUy+ti||ƒti|||ƒdSWn#tj
o|i||ƒnXdS(N(tobjectt__getattribute__RR
t__setattr__RtAttributeErrorR(RR
R((RRUscCsKy$ti||ƒti||ƒWn tj
o|i|ƒnXdS(N(RRRR
t__delattr__RR(RR
((RR]s
cCsx–|D]Ž}||}t|tƒody.||}t|tƒptdƒ‚nWn"tj
o|i	|ƒ}nX|i
|ƒq|||<qWdS(Nsvalue-namespace conflict(tnsR
Rt
isinstanceRRtmynst	TypeErrorRRt
import_config(RRR
RR((RRds

(t__name__t
__module__RRRR	RRRRR(((RR?s								R
cBs tZdZd„Zd„ZRS(sHelper class used to hold undefined names until assignment.
    
    This class helps create any undefined subsections when an
    assignment is made to a nested value.  For example, if the
    statement is "cfg.a.b.c = 42", but "cfg.a.b" does not exist yet.
    cCs*ti|d|ƒti|d|ƒdS(NR
t	namespace(RRRR
R(RR
R((Rt__init__zscCs#|ii|iƒ}|||<dS(N(RRRR
tobjR(RR
RR((RR~s(RRt__doc__RR(((RR
rs	tBasicConfigcBs_tZdZeZd„Zd„Zd„Zd„Zd„Z	dd„Z
d„Zd	„ZRS(
sZRepresents a collection of named values

    Values are added using dotted notation:

    >>> n = BasicConfig()
    >>> n.x = 7
    >>> n.name.first = 'paramjit'
    >>> n.name.last = 'oberoi'

    ...and accessed the same way, or with [...]:

    >>> n.x
    7
    >>> n.name.first
    'paramjit'
    >>> n.name.last
    'oberoi'
    >>> n['x']
    7

    The namespace object is a 'container object'.  The default
    iterator returns the names of values (i.e. keys).

    >>> l = list(n)
    >>> l.sort()
    >>> l
    ['name', 'x']

    Values can be deleted using 'del' and printed using 'print'.

    >>> n.aaa = 42
    >>> del n.x
    >>> print n
    aaa = 42
    name.first = paramjit
    name.last = oberoi

    Nested namepsaces are also namespaces:

    >>> isinstance(n.name, ConfigNamespace)
    True
    >>> print n.name
    first = paramjit
    last = oberoi

    Finally, values can be read from a file as follows:

    >>> from StringIO import StringIO
    >>> sio = StringIO('''
    ... # comment
    ... ui.height = 100
    ... ui.width = 150
    ... complexity = medium
    ... have_python
    ... data.secret.password = goodness=gracious me
    ... ''')
    >>> n = BasicConfig()
    >>> n.readfp(sio)
    >>> print n
    complexity = medium
    data.secret.password = goodness=gracious me
    have_python
    ui.height = 100
    ui.width = 150
    cCs
h|_dS(N(Rt_data(R((RRÌscCs|i|S(N(RR R(RR((RRÏscCs||i|<dS(N(RRR R(RRR((RRÒscCs|i|=dS(N(RR R(RR((RRÕscCs
t|iƒS(N(titerRR (R((RR	ØstcCsÃg}|iiƒ}|iƒx”|D]Œ}|i|}t|tƒo'|i	|i
dd||fƒƒq&|djo|i	d||fƒq&|i	d|||fƒq&Wdi
|ƒS(Ntprefixs%s%s.s%s%ss	%s%s = %ss
(tlinesRR tkeystsortR
RRRtappendt__str__R#tNonetjoin(RR#R
R%R$R((RR(Ûs

'
cCstƒ}||i|<|S(N(RRRR R
(RR
R((RRês	
c	Cs@x9to1|iƒ}|pPn|iƒ}|pqn|ddjoqn|iddƒ}t|ƒdjo|}d}n!|diƒ}|diƒ}|idƒ}|}xh|d D]\}y1||}t|tƒptd|ƒ‚nWqÉtj
o|i|ƒ}qÉXqÉW|||d<qWdS(Nit#t=it.iÿÿÿÿsvalue-namespace conflict(tTruetfptreadlinetlinetstriptsplittdatatlenR
R)Rtname_componentsRRtnRRRRR(	RR/R
R6R7RR1RR4((Rtreadfpïs6

(
RRRR)R RRRRR	R(RR8(((RR†sA						N(RRRR
R(RR
R((Rt?:s3

Anon7 - 2021