MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/usr/lib/python2.4/site-packages/mx/Misc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/lib/python2.4/site-packages/mx/Misc/ConfigFile.pyc
mņ
›KX;c@s/dZdkZdkZdkZdkZdkZdkZdkZdkZ	dk
lZdkZdZ
deifd„ƒYZeidƒZeied„Zdfd	„ƒYZd
efd„ƒYZdefd
„ƒYZdefd„ƒYZdefd„ƒYZeieieed„Zeieieed„Zdefd„ƒYZeZeZ defd„ƒYZ!e!Z"e!Z#defd„ƒYZ$de!fd„ƒYZ%defd„ƒYZ&defd„ƒYZ'd efd!„ƒYZ(d"efd#„ƒYZ)d$e'fd%„ƒYZ*d&e&fd'„ƒYZ+d(e'fd)„ƒYZ,d*e&fd+„ƒYZ-d,e*fd-„ƒYZ.d.efd/„ƒYZ/d0e/fd1„ƒYZ0d2e0fd3„ƒYZ1d4efd5„ƒYZ2d6efd7„ƒYZ3d8efd9„ƒYZ4d:efd;„ƒYZ5d<efd=„ƒYZ6d>efd?„ƒYZ7d@efdA„ƒYZ8dBefdC„ƒYZ9dDeifdE„ƒYZ:dFe:fdG„ƒYZ;eidHƒZ<eidIƒZ=dJfdK„ƒYZ>e?dLjoQdMe:fdN„ƒYZ@dOZAdkBZBeBiCeAƒZDe>e@ƒZEeEiFeDƒndS(Psė	 ConfigFile -- Interface to simple template based configuration files.

    The format of these files is as follows:

    globalvar = 2

    [ABC]
    a = 1
    b = abc.html
    c = text with spaces

    [DEF]
    a = 2
    b = a + 3
    c = a string

    Entries in square brackets indicate new subsections. Global
    variables may be set prior to starting any subsection. Emtpy lines
    and lines starting with '#' (comments) are ignored. Indentation is
    not necessary; lines can start at any column.

    Entries may span multiple lines by using '' continuations
    at the line ends, e.g.

    [Continuation]
    a = first line        second line

    The lines are stripped of any white space before removing the
    trailing '' and concatenating them. Comment lines are removed as
    well.

    To parse these files, a template in form of a class including
    subclasses (identifying the subsections) must be given to the
    reader. This template defines which sections and attributes are
    known. All others are rejected.  A sample template for the above
    looks like this:

    from mx.Misc.ConfigFile import *
    class Template(ConfigNamespace):

        global = IntegerEntry()

        class ABC(ConfigSection):
            a = IntegerEntry('0')
            b = StringEntry('default.html')
            c = StringEntry()

        class DEF(ConfigSection):
            a = IntegerEntry('0')
            b = EvalEntry('0')
            c = StringEntry('default value')

    The main class representing the global namespace of the ini file
    must have ConfigNamespace as baseclass. It may contain any number
    of ConfigSection subclasses each defining parsed attributes. 

    The ini file may only contain entries defined in this template.
    In case an unkown section is found, the main class is looked up
    for a ConfigSection subclass with name 'DefaultSection'. This
    section object is then taken as template for a new section
    of the given name.

    The same feature is available for attributes in sections. In case
    a given attribute is not found in the templates, the section's
    'DefaultAttribute' attribute is deepcopied and the used as
    attribute template.

    Needs mxTools to be installed.

    XXX Add support for long strings (including embedded control
        characters and spanning multiple lines)

    Copyright (c) 2000, Marc-Andre Lemburg; All Rights Reserved.
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.

N(sfreezeitErrorcBstZRS(N(t__name__t
__module__(((t6/usr/lib/python2.4/site-packages/mx/Misc/ConfigFile.pyRYss"(?:\$([a-zA-Z0-9._]+)|\${([^}]*)})cCs|xu|i|ƒ}	|	pPn|	iƒ}||dp|ddƒ}|d}|i
|dƒ}|djo<|i
|dƒ}|djotii
|dƒ}q­nxH|dD]<}yt||ƒ}Wqøtj
otd|‚qøXqøW|	iƒ\}
}t|tƒo=|}
|
itjo|
i|
i||ƒn|
i}n||
 t|ƒ||}qW|S(sś Expands all variables of the form $var or ${var} using
        the dictionaries locals,globals,os.environ in that order
        as database.

        Default value is the empty string, just like for shell
        environment variables.
        
    iit.tsattribute "%s" undefinedN(t	shell_vartsearchttexttmtgroupstgtsplittvarpathtvarnametlocalstgettNonetvaluetglobalstostenvirontattrtgetattrtAttributeErrorRtspantltrt
isinstancetEntrytentrytNotGiventparsetdefaulttstr(RRRRRR
RRRR	RRRR((Rtexpand_vars`s8



!RcBsbtZdZeZdZeeefZ	ed„Z
d„Zei
ed„Zd„Zd„ZRS(sŁ Converts the value to another datatype depending on the
        .converters attribute.

        Each of those functions is applied to the value. The first one
        to not raise an exception succeeds.
        
    RcCs|tj	o
||_ndS(N(R!Rtself(R$R!((Rt__init__Ÿs
cCs†|it|ƒ||ƒ}xB|iD]1}y||ƒ}PWq%t	i
ƒd}q%Xq%W|‚d}|i
|||ƒ|_}|S(s¬ Parse text according to the namespace dictionaries
            locals and globals.

            Sets self.value and returns the parsed value as well.
            
        iN(R$tpre_processR"RRRt
converterst	converterRtsystexc_infotlastexcRtpost_process(R$RRRR+R(R((RR ¤s
cCs|||ƒ||ƒS(sˆ Preprocess the text value.

            Default behaviour is to strip the text and then
            apply variable expansion.

        N(R#tstripRRR(R$RRRR-R#((RR&ŗs	cCs|S(sŠ Postprocess the value after conversion has been
            applied.

            The default behaviour is to leave it as it is.
        N(R(R$RRR((RR,ĘscCs7|itjo|i|ihhƒnt|iƒS(sŽ Return a stringified version of self.value.

            The default value is parsed in case no value has yet been
            set.

        N(R$RRR R!R"(R$((Rt__str__Ļs(RRt__doc__RRR!tinttfloatR"R'R%R tstringR-R#R&R,R.(((RR‹s			tIntegerEntrycBstZdZefZRS(s' Converts the value to an integer.
    (RRR/R0R'(((RR3Żst
FloatEntrycBstZdZefZRS(s$ Converts the value to a float.
    (RRR/R1R'(((RR4ćstNumericEntrycBstZdZeefZRS(s8 Converts the value to a number (integer or float).
    (RRR/R0R1R'(((RR5éstStringEntrycBstZdZefZRS(s% Converts the value to a string.
    (RRR/R"R'(((RR6ļscCs||||dƒƒS(Nt,(tmapR-RR(RR-RR8ttuple((Rt
comma_listõscCs||||ƒƒS(N(R8R-RR(RR-RR8R9((Rtspaced_listūst
TupleEntrycBs tZdZefZd„ZRS(sŪ Converts the value to a tuple of strings.

        value must be a string with entries separated by ','. Entries
        are split at each occurance of ',' and then stripped of
        surrounding spaces.
        
    cCs
t|ƒS(N(R9R(R$RRR((RR,s(RRR/R:R'R,(((RR<s	t	ListEntrycBstZdZefZRS(sŚ Converts the value to a list of strings.

        value must be a string with entries separated by ','. Entries
        are split at each occurance of ',' and then stripped of
        surrounding spaces.
        
    (RRR/R:R'(((RR=stSpacedTupleEntrycBstZdZefZRS(sŲ Converts the value to a tuple of strings.

        value must be a string with entries separated by
        whitespace. Entries are split at each occurance of whitespace;
        surrounding spaces is removed.

    (RRR/R;R'(((RR>#stSpacedListEntrycBstZdZefZRS(s× Converts the value to a list of strings.

        value must be a string with entries separated by
        whitespace. Entries are split at each occurance of whitespace;
        surrounding spaces is removed.

    (RRR/R;R'(((RR?.st	FileEntrycBstZdZefZRS(s! Entry field for an OS file.
    (RRR/R"R'(((RR@9st	PathEntrycBs tZdZefZd„ZRS(sV Entry field for an OS path.

        Paths will always end with os.sep if given.
    cCs0|o%|dtijo|ti}n|S(Ni’’’’(RRtsep(R$RRR((RR,Gs(RRR/R"R'R,(((RRA?s	tAbsoluteFileEntrycBs tZdZefZd„ZRS(sm Entry field for an absolute OS pathname.

        The pathname will always start with os.sep if given.

    cCs0|o%|dtijoti|}n|S(Ni(RRRB(R$RRR((RR,Vs(RRR/R"R'R,(((RRCMs	tAbsolutePathEntrycBs tZdZefZd„ZRS(sq Entry field for an absolute OS path.

        The pathname will always start and end with os.sep if given.

    cCsY|oN|dtijoti|}n|dtijo|ti}qUn|S(Nii’’’’(RRRB(R$RRR((RR,es(RRR/R"R'R,(((RRD\s	tRelativePathEntrycBs#tZdZed„Zd„ZRS(sŌ Entry field for relative paths.
    
        The path stored is the result of joining the given parameter
        with a basepath. basepath is subject to variable expansion at
        parsing time.
        
    cCs||_ti||ƒdS(N(tbasepathR$RAR%R!(R$RFR!((RR%ws	cCs"tiit|i||ƒ|ƒS(N(	RtpathtjoinR#R$RFRRR(R$RRR((RR,|s(RRR/RR%R,(((RREnstRelativeFileEntrycBs#tZdZed„Zd„ZRS(sį Entry field for relative pathnames to files.
    
        The path stored is the result of joining the given parameter
        with a basepath. basepath is subject to variable expansion at
        parsing time.
        
    cCs||_ti||ƒdS(N(RFR$RAR%R!(R$RFR!((RR%‰s	cCs"tiit|i||ƒ|ƒS(N(	RRGRHR#R$RFRRR(R$RRR((RR,Žs(RRR/RR%R,(((RRI€stExistingPathEntrycBstZdZd„ZRS(sl Checks value to point to an existing OS path.

        Raises an exception if the path does not exist.
    cCsT|o%|dtijo|ti}ntii|ƒptd|‚n|S(Ni’’’’snon existing path "%s"(RRRBRGtexistsR(R$RRR((RR,˜s
(RRR/R,(((RRJ’stExistingFileEntrycBstZdZd„ZRS(si Checks value to point to an existing file.

        Raises an exception if the file does not exist.
    cCs1|ptii|ƒotd|‚n|S(Nsnon existing file "%s"(RRRGRKR(R$RRR((RR,¦s(RRR/R,(((RRL stExistingRelativePathEntrycBstZdZd„ZRS(sŹ Entry field for relative paths.
    
        The path stored is the result of joining the given parameter
        with a basepath.  Raises an exception if the path does not
        exist.
        
    cCsLtiit|i||ƒ|ƒ}tii	|ƒpt
d|‚n|S(Nsnon existing path "%s"(RRGRHR#R$RFRRRRKR(R$RRR((RR,µs$(RRR/R,(((RRM¬stURLEntrycBstZdZd„ZRS(s Entry field for URLs.

        The field takes a default value as argument. 

        Needs mxHTMLTools to be installed.

    cCsdkl}|i|ƒS(N(s	HTMLTools(tmxt	HTMLToolstURLR(R$RRRRP((RR,Ås
(RRR/R,(((RRN¼stRelativeURLEntrycBs&tZdZded„Zd„ZRS(sĢ Entry field for relative URLs.

        A base URL can be set which is then urljoined with the
        value given. The field also takes a default value.

        Needs mxHTMLTools to be installed.

    RcCs||_ti||ƒdS(N(tbaseurlR$R6R%R!(R$RSR!((RR%Ōs	cCs,dkl}|it|i||ƒ|ƒS(N(s	HTMLTools(	RORPturljoinR#R$RSRRR(R$RRRRP((RR,Łs
(RRR/RR%R,(((RRRŹs	tAbsoluteURLEntrycBstZdZd„ZRS(sŗ Entry field for absolute URLs.

        A base URL can be set which is then urljoined with the
        value given. The field also takes a default value as second
        argument.
    cCs7ti||||ƒ}|iptd|‚n|S(Nsneed an absolute URL: "%s"(	RRR,R$RRRturltabsoluteR(R$RRRRV((RR,ēs
(RRR/R,(((RRUßst	DateEntrycBstZdZd„ZRS(s› Date entry field.

        The value is stored using a DateTime instance. A time part is
        ignored.

        Needs mxDateTime to be installed.

    cCsdkl}||ƒS(N(sDateFromString(tmx.DateTime.ParsertDateFromStringR(R$RRRRZ((RR,ųs
(RRR/R,(((RRXīs	t
DateTimeEntrycBstZdZd„ZRS(s€ Date/time entry field.

        The value is stored using a DateTime instance.

        Needs mxDateTime to be installed.

    cCsdkl}||ƒS(N(sDateTimeFromString(RYtDateTimeFromStringR(R$RRRR\((RR,s
(RRR/R,(((RR[żst	TimeEntrycBstZdZd„ZRS(s  Time entry field.

        The value is stored using a DateTimeDelta instance. A date
        part is ignored.

        Needs mxDateTime to be installed.

    cCsdkl}||ƒS(N(sTimeFromString(RYtTimeFromStringR(R$RRRR^((RR,s
(RRR/R,(((RR]s	tDateTimeDeltaEntrycBstZdZd„ZRS(s‹ Date/time delta entry field.

        The value is stored using a DateTimeDelta instance.

        Needs mxDateTime to be installed.

    cCsdkl}||ƒS(N(sDateTimeDeltaFromString(RYtDateTimeDeltaFromStringR(R$RRRR`((RR,#s
(RRR/R,(((RR_stRelativeDateTimeEntrycBstZdZd„ZRS(s‘ Relative date/time entry field.

        The value is stored using a RelativeDateTime instance.

        Needs mxDateTime to be installed.

    cCsdkl}||ƒS(N(sRelativeDateTimeFromString(RYtRelativeDateTimeFromStringR(R$RRRRb((RR,1s
(RRR/R,(((RRa(st	EvalEntrycBstZdZed„ZRS(s  Allows simple calculations to be done using the
        current locals (the symbols defined in the class
        where the entry is located) and globals.

    cCs||||ƒ|_|iS(N(tevalRRRR$R(R$RRRRd((RR =s(RRR/RdR (((RRc6st
SafeEvalEntrycBstZdZed„ZRS(sÅ Allows simple calculations to be done using the
        current locals (the symbols defined in the class
        where the entry is located) and globals.

        Builtins are not available.

    cCs||||ƒ|_|iS(N(trevalRRRR$R(R$RRRRf((RR Ms(RRR/RfR (((RReDst	DictEntrycBstZdZd„ZRS(s± Allows the construction of a Python dictionary.

        The entries value is taken as list of key: value pairs which
        are evaluated in the current locals (the symbols defined in
        the class where the entry is located) and globals.

        Parsing is left to the Python interpreter. The needed curly
        brackets {} are added by the parsing method.

        Sample:

        dict = 'a': (1,2,3), 'b': (3,4,5)

    cCs$td|d||ƒ|_|iS(Nt{t}(RdRRRR$R(R$RRR((RR ds(RRR/R (((RRgTstConfigNamespacecBsŒtZdZdZeeieiei	ei
feieiei
eieifeieid„Zd„Zd„Zd„Zd„ZRS(NcCs|i}t|ƒ|i}|i|iƒxģ|iƒD]Ž\}}|d djo||=nt
|ƒ}	|	|jo2|djo!t
|tƒo|ƒ||<qq9|	|jo||=q9|	|joq9y||ƒ||<Wq9tij
o}
td||
f‚q9Xq9WdS(Nis_ tDefaultSections,namespace entry "%s" could not be copied: %s(R$t	__class__tclassobjtfreezet__dict__tdicttupdatetitemstnametobjttypetobjtypet	ClassTypet
issubclasst
ConfigSectiont	del_typest
skip_typestdeepcopytcopyterrortwhyR(R$RR{RzR|RwRtRsRmRvRRp((RR%xs(	
	



cCshg}|i}xR|iiƒD]A\}}|d djp
|djoqn|||fƒqW|S(Nit_RktDefaultAttributetbaseobj(sDefaultSectionsDefaultAttributeR‚(RrtappendR$Rotktv(R$RrR„RƒR…((Rt_items³s	cCsbg}|i}xL|iiƒD];\}}|d djp
|djoqn||ƒqW|S(NiR€RkRR‚(sDefaultSectionsDefaultAttributesbaseobj(RrRƒR$RoR„R…(R$RrR„RƒR…((Rt_keys¾s	cCsbg}|i}xL|iiƒD];\}}|d djp
|djoqn||ƒqW|S(NiR€RkRR‚(sDefaultSectionsDefaultAttributesbaseobj(RrRƒR$RoR„R…(R$RrR„RƒR…((Rt_valuesÉs	cCsZh}|i|iƒx=|iƒD]/}|d djp
|djo||=q#q#W|S(NiR€RkRR‚(sDefaultSectionsDefaultAttributesbaseobj(tdRqR$RotkeysR„(R$R„R‰((Rt_dictionaryŌs
(RRRRkRRttypest
ModuleTypetIntTypet
StringTypetNoneTypetFunctionTypetUnboundMethodTypet
MethodTypetBuiltinFunctionTypetBuiltinMethodTypeR}R|RwR%R†R‡RˆR‹(((RRjksT;			RycBstZRS(N(RR(((RRyßss\[([a-zA-Z_][a-zA-Z_0-9]*)\]s'([a-zA-Z_][a-zA-Z_0-9]*)[ 	]*=[ 	]*(.*)t
ConfigFilecBsMtZdZeZd„Zeiei	ei
d„Zei
eid„ZRS(s? Configuration file reader.

        Takes a template (a ConfigNamespace subclass) as input which
        defines sections using classes. Sections may include instances
        of Entry as attributes. These are then used to process the
        file input.

        The template is (deep-)copied and placed into the instance
        variable .data (a ConfigNamespace instance) prior to reading
        the file. Section classes are replaced with ConfigSection
        instances.

        After successful reading the file, the configuration
        information is available through this variable.

        Errors are indicated by exceptions of type Error. These always
        have values (line_number, explanation) where line_number is 0
        for errors which do not refer to one specific line in the
        file.
        
    cCs||_|iƒdS(N(ttemplateR$treset(R$R—((RR%s	cCs|iƒ|_dS(sq Reset the object to its initial state.

            This initializes self.data to a template instance.

        N(R$R—tdata(R$R|RwR((RR˜s	c	CsĪh}d}|i}|}|i}|}d}t	o	dGHnxł|iƒ}
|d}|
pPn||
ƒ}
|
p|
ddjoqCnt	odt|
ƒGHn|}x¤|
ddjo’|iƒ}|d}|p|
d }
Pn||ƒ}|p|
d }
Pn|ddjoq“nt	od	t|ƒGHn|
d |}
q“Wt	od
t|
ƒGHnti|
ƒ}|o€|iƒd}t||dƒ}|djoA|io |iƒ}t|||ƒqųt|d|f‚n|i}qCnti|
ƒ}|oł|iƒ\}
}|i|
dƒ}|o|d|
}	n|
}	|djoD|i o#||i ƒ}t||
|ƒq²t|d
|	f‚ny|i"|||ƒWn7t|d|	t#i$ƒdt#i$ƒdff‚nX|i||
<qCnt	od|t|
ƒfGHqCqCWx‹|i%ƒD]}\}
}t'|t(ƒo|it)j	o|i||
<qĘy'|i"|i*||ƒ|i||
<WqĘtdd|
t+t#i$ƒdƒff‚qĘXqIt'|t,ƒoŅ|i}|
}xĄ|i%ƒD]®\}
}t'|t(ƒo’|it)j	o|i||
<q¾y'|i"|i*||ƒ|i||
<Wq¾dk-}|i.ƒtdd|
t+t#i$ƒdƒff‚q¾XqqWqIqIWdS(s} Read and parse the open file.

            The configuration is stored in the instance variable
            .data.

        RisReading config file:it#s read %si’’’’s\s read continuation %ss processing %ssunkown section "%s"Rsunkown attribute: "%s"s)invalid attribute value for "%s" (%s: %s)s(Ignoring invalid config file line %i: %ss4invalid default attribute value for global "%s" (%s)Ns3invalid default attribute value for local "%s" (%s)(/tcontexttsectionnameR$R™tsectionRoRRtlinenot_debugtfiletreadlinetlineR-treprtcurrent_linenotnextlinet
parse_sectiontmatchR	R
RRRktsetattrRt
parse_setattrRsRRRtattrnameRR|R R)R*RrRtRRRR!R"Ryt	tracebackt	print_exc(R$R R-R|RœRRRžR„RŖR¢R™RtRsR«R	RR›RRR¤((Rtreads¾				





	

4

1	
(RRR/RR™R%R}R|RŒRwRR˜R2R-R­(((RR–ēs
	t__main__tTemplatecBs[tZdkZedƒZedƒZdefd„ƒYZdefd„ƒYZ	eZ
RS(NiRtABCcBsPtZedƒZedƒZeƒZedƒZe	dƒZ
eddƒZRS(Nt0sdefault.htmlsa,bRs..R(
RRR3taR6tbtctStringTupleEntryR‰RJRGRER(((RR°²s	tDEFcBsktZedƒZedƒZedƒZeddƒZ	edƒZ
edƒZe
dƒZedƒZRS(NR±s
default values$ABC.btHOMERs
0:15:00.23(RRR3R²RcR³R6R“RER‰RtCommaTupleEntrytcontinuationRgt	databasesR]ttimeout(((RR¶¼s(RRR)R3t	globalvarR6RRyR°R¶Rk(((RRÆ©s	
sģ    # Luckily we don't have to pay attention to proper indentation
    # or whether strings have quotes or not... the template knows
    # what to do.

    globalvar = 2

    # New global attribute
    test = text

    [ABC]
    a = 1
    b = abc.html
    c = text with spaces
    d = heinz, kunz, philipp
    path = /tmp

    # A new attribute
    new = .cshrc

    [DEF]
    a = 2
    b = a + 3
    c = $PWD
    d = home

    continuation = first line, \
                   # Comment should not hurt
                   second line, \

                   # Invalid syntax:
                   third line \

    databases = 'iODBC': (sys,sys.exit,('c',1,2)), \
                'Adabas': (sys,sys.exit,('x','y','z'))

    [NewSection]
    a = 3

    (GR/R2R}treRŒt
exceptionsR)Rtmx.Tools.NewBuiltinsROtmx.ToolsRnt	NamespaceRŸt
StandardErrorRtcompileRRR#RR3R4R5R6R-R8R9R:R;R<RµRøR=tStringListEntrytCommaListEntryR>R?R@RARCRDRERIRJRLRMRNRRRURXR[R]R_RaRcReRgRjRyR¦R©R–RRÆRt	cStringIOtStringIOtftcfR­(;R<RĘRARÆR?RR;RĮRÉRnRøRUR@RXRÅRµRCRMRgRŸRLR½RIR–R6R4R=R:R¦RJR2RaR3R5RR)RERcR©RRR}R[RNRŒRjR]RyReRČR>RRRÄR#R_R¾RDRRO((Rt?Nsn?	
	+RtĄ
 )	

Anon7 - 2021