³ò ¢l‡Jc@sjdZddkZddddddd d d d d ddg ZdZdZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZ defd„ƒYZ de fd„ƒYZ de fd„ƒYZ de fd„ƒYZ d efd„ƒYZd efd„ƒYZd fd„ƒYZd efd„ƒYZd efd „ƒYZdS(!s Configuration file parser. A setup file consists of sections, lead by a "[section]" header, and followed by "name: value" entries, with continuations and such in the style of RFC 822. The option values can contain format strings which refer to other values in the same section, or values in a special [DEFAULT] section. For example: something: %(dir)s/whatever would resolve the "%(dir)s" to the value of dir. All reference expansions are done late, on demand. Intrinsic defaults can be specified by passing them into the ConfigParser constructor as a dictionary. class: ConfigParser -- responsible for parsing a list of configuration files, and managing the parsed database. methods: __init__(defaults=None) create the parser and specify a dictionary of intrinsic defaults. The keys must be strings, the values must be appropriate for %()s string interpolation. Note that `__name__' is always an intrinsic default; its value is the section's name. sections() return all the configuration section names, sans DEFAULT has_section(section) return whether the given section exists has_option(section, option) return whether the given option exists in the given section options(section) return list of configuration options for the named section read(filenames) read and parse the list of named configuration files, given by name. A single filename is also allowed. Non-existing files are ignored. Return list of successfully read files. readfp(fp, filename=None) read and parse one configuration file, given as a file object. The filename defaults to fp.name; it is only used in error messages (if fp has no `name' attribute, the string `' is used). get(section, option, raw=False, vars=None) return a string value for the named option. All % interpolations are expanded in the return values, based on the defaults passed into the constructor and the DEFAULT section. Additional substitutions may be provided using the `vars' argument, which must be a dictionary whose contents override any pre-existing defaults. getint(section, options) like get(), but convert value to an integer getfloat(section, options) like get(), but convert value to a float getboolean(section, options) like get(), but convert value to a boolean (currently case insensitively defined as 0, false, no, off for False, and 1, true, yes, on for True). Returns False or True. items(section, raw=False, vars=None) return a list of tuples with (name, value) for each option in the section. remove_section(section) remove the given file section and all its options remove_option(section, option) remove the given option from the given section set(section, option, value) set the given option write(fp) write the configuration state in .ini format iÿÿÿÿNtNoSectionErrortDuplicateSectionErrort NoOptionErrortInterpolationErrortInterpolationDepthErrortInterpolationSyntaxErrort ParsingErrortMissingSectionHeaderErrort ConfigParsertSafeConfigParsertRawConfigParsert DEFAULTSECTtMAX_INTERPOLATION_DEPTHtDEFAULTi tErrorcBs)eZdZdd„Zd„ZeZRS(s'Base class for ConfigParser exceptions.tcCs||_ti||ƒdS(N(tmessaget Exceptiont__init__(tselftmsg((s/sys/lib/python/ConfigParser.pyRms cCs|iS(N(R(R((s/sys/lib/python/ConfigParser.pyt__repr__qs(t__name__t __module__t__doc__RRt__str__(((s/sys/lib/python/ConfigParser.pyRjs  cBseZdZd„ZRS(s2Raised when no section matches a requested option.cCs$ti|d|fƒ||_dS(NsNo section: %r(RRtsection(RR((s/sys/lib/python/ConfigParser.pyRys(RRRR(((s/sys/lib/python/ConfigParser.pyRvscBseZdZd„ZRS(s*Raised when a section is multiply-created.cCs!ti|d|ƒ||_dS(NsSection %r already exists(RRR(RR((s/sys/lib/python/ConfigParser.pyR€s(RRRR(((s/sys/lib/python/ConfigParser.pyR}scBseZdZd„ZRS(s!A requested option was not found.cCs0ti|d||fƒ||_||_dS(NsNo option %r in section: %r(RRtoptionR(RRR((s/sys/lib/python/ConfigParser.pyR‡s  (RRRR(((s/sys/lib/python/ConfigParser.pyR„scBseZdZd„ZRS(s0Base class for interpolation-related exceptions.cCs&ti||ƒ||_||_dS(N(RRRR(RRRR((s/sys/lib/python/ConfigParser.pyRs (RRRR(((s/sys/lib/python/ConfigParser.pyRstInterpolationMissingOptionErrorcBseZdZd„ZRS(sAA string substitution required a setting which was not available.cCs9d||||f}ti||||ƒ||_dS(NsNBad value substitution: section: [%s] option : %s key : %s rawval : %s (RRt reference(RRRtrawvalRR((s/sys/lib/python/ConfigParser.pyR˜s(RRRR(((s/sys/lib/python/ConfigParser.pyR•scBseZdZRS(sjRaised when the source text into which substitutions are made does not conform to the required syntax.(RRR(((s/sys/lib/python/ConfigParser.pyR¢scBseZdZd„ZRS(s0Raised when substitutions are nested too deeply.cCs-d|||f}ti||||ƒdS(NsSValue interpolation too deeply recursive: section: [%s] option : %s rawval : %s (RR(RRRRR((s/sys/lib/python/ConfigParser.pyR©s(RRRR(((s/sys/lib/python/ConfigParser.pyR¦scBs eZdZd„Zd„ZRS(s>Raised when a configuration file does not follow legal syntax.cCs*ti|d|ƒ||_g|_dS(Ns File contains parsing errors: %s(RRtfilenameterrors(RR((s/sys/lib/python/ConfigParser.pyR´s cCs3|ii||fƒ|id||f7_dS(Ns [line %2d]: %s(R tappendR(Rtlinenotline((s/sys/lib/python/ConfigParser.pyR!¹s(RRRRR!(((s/sys/lib/python/ConfigParser.pyR±s cBseZdZd„ZRS(s@Raised when a key-value pair is found before any section header.cCs<ti|d|||fƒ||_||_||_dS(Ns7File contains no section headers. file: %s, line: %d %r(RRRR"R#(RRR"R#((s/sys/lib/python/ConfigParser.pyRÀs  (RRRR(((s/sys/lib/python/ConfigParser.pyR½scBs7eZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z dd„Z d„Z d „Z d „Z d „Zd „Zhed <ed<ed<ed<ed<ed<ed<ed' is used. sN(tNonetnametAttributeErrorR8(RR<R((s/sys/lib/python/ConfigParser.pytreadfps  cCsÇ|i|ƒ}||ijoO|tjot|ƒ‚n||ijo|i|SqÃt||ƒ‚nV||i|jo|i||Sn/||ijo|i|Snt||ƒ‚dS(N(R'R$R RR%R(RRRtopt((s/sys/lib/python/ConfigParser.pytget s cCsˆy|i|}Wn6tj o*|tjot|ƒ‚nh}nX|iiƒ}|i|ƒd|jo |d=n|iƒS(NR(R$R0R RR%R/R1R&(RRtd2td((s/sys/lib/python/ConfigParser.pyR&0s     cCs||i||ƒƒS(N(RC(RRtconvR((s/sys/lib/python/ConfigParser.pyt_get=scCs|i|t|ƒS(N(RGtint(RRR((s/sys/lib/python/ConfigParser.pytgetint@scCs|i|t|ƒS(N(RGtfloat(RRR((s/sys/lib/python/ConfigParser.pytgetfloatCst1tyesttruetont0tnotfalsetoffcCsJ|i||ƒ}|iƒ|ijotd|‚n|i|iƒS(NsNot a boolean: %s(RCtlowert_boolean_statest ValueError(RRRtv((s/sys/lib/python/ConfigParser.pyt getbooleanIscCs |iƒS(N(RT(Rt optionstr((s/sys/lib/python/ConfigParser.pyR'OscCs| p |tjo |i|ƒ}||ijSnI||ijotSn1|i|ƒ}||i|jp ||ijSdS(s=Check for the existence of a given option in a given section.N(R R'R%R$tFalse(RRR((s/sys/lib/python/ConfigParser.pyt has_optionRscCsl| p |tjo |i}n4y|i|}Wntj ot|ƒ‚nX|||i|ƒ[^]]+)\]s9(?P