ž §ÿfÁc@s\dZddlmZddlmZmZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddddd d d d d dddddgZdZdZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZGdd„deƒZGdd „d eƒZGdd „d eƒZGd d „d eƒZGd!d „d eƒZeƒZGd"d#„d#ƒZGd$d%„d%eƒZ Gd&d'„d'eƒZ!Gd(d)„d)eƒZ"Gd*d„deƒZ#Gd+d„de#ƒZ$Gd,d„de$ƒZ%Gd-d.„d.eƒZ&dS(/uÎConfiguration file parser. A configuration 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. 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, dict_type=_default_dict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True): Create the parser. When `defaults' is given, it is initialized into the dictionary or intrinsic defaults. The keys must be strings, the values must be appropriate for %()s string interpolation. When `dict_type' is given, it will be used to create the dictionary objects for the list of sections, for the options within a section, and for the default values. When `delimiters' is given, it will be used as the set of substrings that divide keys from values. When `comment_prefixes' is given, it will be used as the set of substrings that prefix comments in empty lines. Comments can be indented. When `inline_comment_prefixes' is given, it will be used as the set of substrings that prefix comments in non-empty lines. When `strict` is True, the parser won't allow for any section or option duplicates while reading from a single source (file, string or dictionary). Default is True. When `empty_lines_in_values' is False (default: True), each empty line marks the end of an option. Otherwise, internal empty lines of a multiline option are kept as part of the value. When `allow_no_value' is True (default: False), options without values are accepted; the value presented for these is None. 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, encoding=None) 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. read_file(f, filename=None) Read and parse one configuration file, given as a file object. The filename defaults to f.name; it is only used in error messages (if f has no `name' attribute, the string `' is used). read_string(string) Read configuration from a given string. read_dict(dictionary) Read configuration from a dictionary. Keys are section names, values are dictionaries with keys and values that should be present in the section. If the used dictionary type preserves order, sections and their keys will be added in order. Values are automatically converted to strings. get(section, option, raw=False, vars=None, fallback=_UNSET) 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. If `option' is a key in `vars', the value from `vars' is used. getint(section, options, raw=False, vars=None, fallback=_UNSET) Like get(), but convert value to an integer. getfloat(section, options, raw=False, vars=None, fallback=_UNSET) Like get(), but convert value to a float. getboolean(section, options, raw=False, vars=None, fallback=_UNSET) 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=_UNSET, raw=False, vars=None) If section is given, return a list of tuples with (name, value) for each option in the section. Otherwise, return a list of tuples with (section_name, section_proxy) for each section, including DEFAULTSECT. 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, space_around_delimiters=True) Write the configuration state in .ini format. If `space_around_delimiters' is True (the default), delimiters between keys and values are surrounded by spaces. i(uMutableMapping(u OrderedDictuChainMapNuNoSectionErroruDuplicateOptionErroruDuplicateSectionErroru NoOptionErroruInterpolationErroruInterpolationDepthErroruInterpolationSyntaxErroru ParsingErroruMissingSectionHeaderErroru ConfigParseruSafeConfigParseruRawConfigParseru DEFAULTSECTuMAX_INTERPOLATION_DEPTHuDEFAULTi cBs;|EeZdZdZddd„Zdd„ZeZdS(uErroru'Base class for ConfigParser exceptions.ucCs||_tj||ƒdS(N(umessageu Exceptionu__init__(uselfumsg((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__“s uError.__init__cCs|jS(N(umessage(uself((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__repr__—suError.__repr__N(u__name__u __module__u __qualname__u__doc__u__init__u__repr__u__str__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuError�s uErrorcBs&|EeZdZdZdd„ZdS(uNoSectionErroru2Raised when no section matches a requested option.cCs0tj|d|fƒ||_|f|_dS(NuNo section: %r(uErroru__init__usectionuargs(uselfusection((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__ s uNoSectionError.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuNoSectionError�scBs,|EeZdZdZdddd„ZdS(uDuplicateSectionErroruRaised when a section is repeated in an input source. Possible repetitions that raise this exception are: multiple creation using the API or in strict parsers when a section is found more than once in a single input file, string or dictionary. cCsÒt|ƒdg}|dk rxdt|ƒg}|dk rU|jdj|ƒƒn|jdƒ|j|ƒ|}n|jddƒtj|dj|ƒƒ||_ ||_ ||_ |||f|_ dS(Nu already existsuWhile reading from u [line {0:2d}]u : section iuSection u( urepruNoneuappenduformatuextenduinsertuErroru__init__ujoinusectionusourceulinenouargs(uselfusectionusourceulinenoumsgumessage((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__®s        uDuplicateSectionError.__init__N(u__name__u __module__u __qualname__u__doc__uNoneu__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuDuplicateSectionError¦scBs,|EeZdZdZdddd„ZdS(uDuplicateOptionErroruÖRaised by strict parsers when an option is repeated in an input source. Current implementation raises this exception only when an option is found more than once in a single file, string or dictionary. cCsêt|ƒdt|ƒdg}|dk r„dt|ƒg}|dk ra|jdj|ƒƒn|jdƒ|j|ƒ|}n|jddƒtj|dj|ƒƒ||_ ||_ ||_ ||_ ||||f|_ dS( Nu in section u already existsuWhile reading from u [line {0:2d}]u : option iuOption u(urepruNoneuappenduformatuextenduinsertuErroru__init__ujoinusectionuoptionusourceulinenouargs(uselfusectionuoptionusourceulinenoumsgumessage((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__Çs           uDuplicateOptionError.__init__N(u__name__u __module__u __qualname__u__doc__uNoneu__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuDuplicateOptionErrorÀscBs&|EeZdZdZdd„ZdS(u NoOptionErroru!A requested option was not found.cCs?tj|d||fƒ||_||_||f|_dS(NuNo option %r in section: %r(uErroru__init__uoptionusectionuargs(uselfuoptionusection((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__Þs    uNoOptionError.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyu NoOptionErrorÛscBs&|EeZdZdZdd„ZdS(uInterpolationErroru0Base class for interpolation-related exceptions.cCs8tj||ƒ||_||_|||f|_dS(N(uErroru__init__uoptionusectionuargs(uselfuoptionusectionumsg((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__és  uInterpolationError.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuInterpolationErroræscBs&|EeZdZdZdd„ZdS(uInterpolationMissingOptionErroruAA string substitution required a setting which was not available.cCsNd||||f}tj||||ƒ||_||||f|_dS(NuNBad value substitution: section: [%s] option : %s key : %s rawval : %s (uInterpolationErroru__init__u referenceuargs(uselfuoptionusectionurawvalu referenceumsg((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__ós  u(InterpolationMissingOptionError.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuInterpolationMissingOptionErrorðsuInterpolationMissingOptionErrorcBs|EeZdZdZdS(uInterpolationSyntaxErroruÏRaised when the source text contains invalid syntax. Current implementation raises this exception when the source text into which substitutions are made does not conform to the required syntax. N(u__name__u __module__u __qualname__u__doc__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuInterpolationSyntaxErrorÿscBs&|EeZdZdZdd„ZdS(uInterpolationDepthErroru0Raised when substitutions are nested too deeply.cCs?d|||f}tj||||ƒ|||f|_dS(NuSValue interpolation too deeply recursive: section: [%s] option : %s rawval : %s (uInterpolationErroru__init__uargs(uselfuoptionusectionurawvalumsg((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__ su InterpolationDepthError.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuInterpolationDepthErrorscBs_|EeZdZdZd d dd„Zedd„ƒZejdd„ƒZdd„Z d S( u ParsingErroru>Raised when a configuration file does not follow legal syntax.cCs}|r|rtdƒ‚n,| r8| r8tdƒ‚n|rG|}ntj|d|ƒ||_g|_|f|_dS(Nu:Cannot specify both `filename' and `source'. Use `source'.u%Required argument `source' not given.u"Source contains parsing errors: %r(u ValueErroruErroru__init__usourceuerrorsuargs(uselfusourceufilename((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__s    uParsingError.__init__cCstjdtddƒ|jS(uDeprecated, use `source'.uSThe 'filename' attribute will be removed in future versions. Use 'source' instead.u stackleveli(uwarningsuwarnuDeprecationWarningusource(uself((u1/opt/alt/python33/lib64/python3.3/configparser.pyufilename&s uParsingError.filenamecCs#tjdtddƒ||_dS(uDeprecated, user `source'.uSThe 'filename' attribute will be removed in future versions. Use 'source' instead.u stackleveliN(uwarningsuwarnuDeprecationWarningusource(uselfuvalue((u1/opt/alt/python33/lib64/python3.3/configparser.pyufilename0s cCs3|jj||fƒ|jd||f7_dS(Nu [line %2d]: %s(uerrorsuappendumessage(uselfulinenouline((u1/opt/alt/python33/lib64/python3.3/configparser.pyuappend:suParsingError.appendN( u__name__u __module__u __qualname__u__doc__uNoneu__init__upropertyufilenameusetteruappend(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyu ParsingErrors   cBs&|EeZdZdZdd„ZdS(uMissingSectionHeaderErroru@Raised when a key-value pair is found before any section header.cCsNtj|d|||fƒ||_||_||_|||f|_dS(Nu7File contains no section headers. file: %r, line: %d %r(uErroru__init__usourceulinenoulineuargs(uselfufilenameulinenouline((u1/opt/alt/python33/lib64/python3.3/configparser.pyu__init__Bs   u"MissingSectionHeaderError.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuMissingSectionHeaderError?scBsJ|EeZdZdZdd„Zdd„Zdd„Zdd „Zd S( u InterpolationuBDummy interpolation that passes the value through with no changes.cCs|S(N((uselfuparserusectionuoptionuvalueudefaults((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_getVsuInterpolation.before_getcCs|S(N((uselfuparserusectionuoptionuvalue((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_setYsuInterpolation.before_setcCs|S(N((uselfuparserusectionuoptionuvalue((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_read\suInterpolation.before_readcCs|S(N((uselfuparserusectionuoptionuvalue((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_write_suInterpolation.before_writeN(u__name__u __module__u __qualname__u__doc__u before_getu before_setu before_readu before_write(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyu InterpolationSs    u InterpolationcBsM|EeZdZdZejdƒZdd„Zdd„Zdd„Z d S( uBasicInterpolationu!Interpolation as implemented in the classic ConfigParser. The option values can contain format strings which refer to other values in the same section, or values in the 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. If a user needs to use a bare % in a configuration file, she can escape it by writing %%. Other % usage is considered a user error and raises `InterpolationSyntaxError'.u %\(([^)]+)\)scCs2g}|j||||||dƒdj|ƒS(Niu(u_interpolate_someujoin(uselfuparserusectionuoptionuvalueudefaultsuL((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_gettsuBasicInterpolation.before_getcCsY|jddƒ}|jjd|ƒ}d|krUtd||jdƒfƒ‚n|S(Nu%%uu%u1invalid interpolation syntax in %r at position %d(ureplaceu_KEYCREusubu ValueErrorufind(uselfuparserusectionuoptionuvalueu tmp_value((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_setys  uBasicInterpolation.before_setc CsÔ|tkr!t|||ƒ‚nx¬|rÏ|jdƒ}|dkrV|j|ƒdS|dkrŒ|j|d|…ƒ||d…}n|dd…} | dkrÈ|jdƒ|dd…}q$| dkr³|jj|ƒ} | dkr t||d|ƒ‚n|j| j dƒƒ} || j ƒd…}y|| } Wn't k rpt |||| ƒ‚YnXd| kr£|j |||| |||dƒqÌ|j| ƒq$t||d|fƒ‚q$WdS(Nu%iiiu(u'bad interpolation variable reference %ru/'%%' must be followed by '%%' or '(', found: %r(uMAX_INTERPOLATION_DEPTHuInterpolationDepthErrorufinduappendu_KEYCREumatchuNoneuInterpolationSyntaxErroru optionxformugroupuenduKeyErroruInterpolationMissingOptionErroru_interpolate_some( uselfuparseruoptionuaccumurestusectionumapudepthupucumuvaruv((u1/opt/alt/python33/lib64/python3.3/configparser.pyu_interpolate_some�sD            u$BasicInterpolation._interpolate_someN( u__name__u __module__u __qualname__u__doc__ureucompileu_KEYCREu before_getu before_setu_interpolate_some(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuBasicInterpolationcs    uBasicInterpolationcBsM|EeZdZdZejdƒZdd„Zdd„Zdd„Z d S( uExtendedInterpolationuyAdvanced variant of interpolation, supports the syntax used by `zc.buildout'. Enables interpolation between sections.u \$\{([^}]+)\}cCs2g}|j||||||dƒdj|ƒS(Niu(u_interpolate_someujoin(uselfuparserusectionuoptionuvalueudefaultsuL((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_get°su ExtendedInterpolation.before_getcCsY|jddƒ}|jjd|ƒ}d|krUtd||jdƒfƒ‚n|S(Nu$$uu$u1invalid interpolation syntax in %r at position %d(ureplaceu_KEYCREusubu ValueErrorufind(uselfuparserusectionuoptionuvalueu tmp_value((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_setµs  u ExtendedInterpolation.before_setcCs’|tkr!t|||ƒ‚nxj|r�|jdƒ}|dkrV|j|ƒdS|dkrŒ|j|d|…ƒ||d…}n|dd…} | dkrÈ|jdƒ|dd…}q$| dkrq|jj|ƒ} | dkr t||d|ƒ‚n| jdƒj dƒ} || j ƒd…}|} |} y™t | ƒdkrz|j | dƒ} || }nct | ƒdkrÄ| d} |j | dƒ} |j | | dd ƒ}nt||d |fƒ‚Wn9tttfk rt|||dj| ƒƒ‚YnXd|kra|j|| ||| t|j| dd ƒƒ|dƒqŠ|j|ƒq$t||d |fƒ‚q$WdS( Nu$iiiu{u'bad interpolation variable reference %ru:urawuMore than one ':' found: %ru-'$' must be followed by '$' or '{', found: %rT(uMAX_INTERPOLATION_DEPTHuInterpolationDepthErrorufinduappendu_KEYCREumatchuNoneuInterpolationSyntaxErrorugroupusplituendulenu optionxformugetuTrueuKeyErroruNoSectionErroru NoOptionErroruInterpolationMissingOptionErrorujoinu_interpolate_someudictuitems(uselfuparseruoptionuaccumurestusectionumapudepthupucumupathusectuoptuv((u1/opt/alt/python33/lib64/python3.3/configparser.pyu_interpolate_some½s\              u'ExtendedInterpolation._interpolate_someN( u__name__u __module__u __qualname__u__doc__ureucompileu_KEYCREu before_getu before_setu_interpolate_some(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuExtendedInterpolationªs   uExtendedInterpolationcBsS|EeZdZdZejdƒZdd„Zdd„Ze dd„ƒZ d S( uLegacyInterpolationu{Deprecated interpolation used in old versions of ConfigParser. Use BasicInterpolation or ExtendedInterpolation instead.u%\(([^)]*)\)s|.c Csã|}t}x©|r·|d8}|r³d|kr³tj|jd|ƒ}|jj||ƒ}y||}Wq´tk r¯} z!t|||| jdƒ‚WYdd} ~ Xq´XqPqW|rßd|krßt |||ƒ‚n|S(Niu%(uparseri( uMAX_INTERPOLATION_DEPTHu functoolsupartialu_interpolation_replaceu_KEYCREusubuKeyErroruInterpolationMissingOptionErroruargsuInterpolationDepthError( uselfuparserusectionuoptionuvalueuvarsurawvaludepthureplaceue((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_getùs"   /uLegacyInterpolation.before_getcCs|S(N((uselfuparserusectionuoptionuvalue((u1/opt/alt/python33/lib64/python3.3/configparser.pyu before_set suLegacyInterpolation.before_setcCs:|jdƒ}|dkr%|jƒSd|j|ƒSdS(Niu%%(%s)s(ugroupuNoneu optionxform(umatchuparserus((u1/opt/alt/python33/lib64/python3.3/configparser.pyu_interpolation_replaces  u*LegacyInterpolation._interpolation_replaceN( u__name__u __module__u __qualname__u__doc__ureucompileu_KEYCREu before_getu before_setu staticmethodu_interpolation_replace(u __locals__((u1/opt/alt/python33/lib64/python3.3/configparser.pyuLegacyInterpolationós   uLegacyInterpolationcsF|EeZdZdZdZdZdZeƒZe j ee j ƒZ e j ej ddƒe j ƒZe j ej ddƒe j ƒZe j dƒZidnd6dnd 6dnd 6dnd 6dod 6dod 6dod6dod6Zddpddqddrddnddndededredodd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zdrd'd(„Zdrd)d*„Zd+d,d-„Z d.d/d0„Z!drd1d2„Z"d3dod4drd5ed6d7„Z#d8d9„Z$d3dod4drd5ed:d;„Z%d3dod4drd5ed<d=„Z&d3dod4drd5ed>d?„Z'edodr‡fd@dA†Z(dBdC„Z)dDdE„Z*dFdG„Z+drdHdI„Z,dndJdK„Z-dLdM„Z.dNdO„Z/dPdQ„Z0dRdS„Z1dTdU„Z2dVdW„Z3dXdY„Z4dZd[„Z5d\d]„Z6d^d_„Z7d`da„Z8dbdc„Z9ddde„Z:dfdg„Z;dhdidjdidkdidldm„Z<‡S(suRawConfigParseru,ConfigParser that does not do interpolation.u¥ \[ # [ (?P
[^]]+) # very permissive! \] # ] u› (?P