3

T'ícґã@sÈdZdZddlZddlZddlZddlZddlZddlZddlmZej	d8krhddl
mZddlmZnddl
mZddlmZddlZddlZddlZdd	lmZmZmZmZej	d9kr¾eZd
d„Zdd
„Zd:dd„Zd;dd„Zd<dd„Zd=dd„Zd>dd„Zd?dd„Z d@dd„Z!dAdd„Z"dBdd„Z#dCd d!„Z$dDd"d#„Z%dEd$d%„Z&dFd&d'„Z'dGd(d)„Z(d*d+„Z)d,d-„Z*Gd.d/„d/ej+ƒZ+Gd0d1„d1ej,ƒZ,Gd2d3„d3ej-ej.ƒZ-Gd4d5„d5eƒZ
Gd6d7„d7e/ƒZ0dS)Hau
Command-line and common processing for Docutils front-end tools.

Exports the following classes:

* `OptionParser`: Standard Docutils command-line processing.
* `Option`: Customized version of `optparse.Option`; validation support.
* `Values`: Runtime settings; objects are simple structs
  (``object.attribute``).  Supports cumulative list settings (attributes).
* `ConfigParser`: Standard Docutils config file processing.

Also exports the following functions:

* Option callbacks: `store_multiple`, `read_config_file`.
* Setting validators: `validate_encoding`,
  `validate_encoding_error_handler`,
  `validate_encoding_and_error_handler`,
  `validate_boolean`, `validate_ternary`, `validate_threshold`,
  `validate_colon_separated_list`,
  `validate_comma_separated_list`,
  `validate_dependency_file`.
* `make_paths_absolute`.
* SettingSpec manipulation: `filter_settings_spec`.
ZreStructuredTextéN)Ú
SUPPRESS_HELPé)ÚRawConfigParser)Úgetcwd)Úgetcwdu)Úlocale_encodingÚ
SafeStringÚErrorOutputÚErrorStringcOsDx|D]}t|j|dƒqWx"|jƒD]\}}t|j||ƒq&WdS)zÀ
    Store multiple values in `parser.values`.  (Option callback.)

    Store `None` for each attribute named in `args`, and store the value for
    each key (attribute name) in `kwargs`.
    N)ÚsetattrÚvaluesÚitems)ÚoptionÚoptÚvalueÚparserÚargsÚkwargsÚ	attributeÚkey©rú5/tmp/pip-build-gk9425m9/docutils/docutils/frontend.pyÚstore_multiple8s
rcCsNy|j|ƒ}Wn,tk
r:}z|j|ƒWYdd}~XnX|jj||ƒdS)zQ
    Read a configuration file during option processing.  (Option callback.)
    N)Úget_config_file_settingsÚ
ValueErrorÚerrorrÚupdate)rrrrZnew_settingsrrrrÚread_config_fileDs
rcCs8ytj|ƒWn$tk
r2td||fƒ‚YnX|S)Nz$setting "%s": unknown encoding: "%s")ÚcodecsÚlookupÚLookupError)ÚsettingrÚ
option_parserÚ
config_parserÚconfig_sectionrrrÚvalidate_encodingNsr%cCs4ytj|ƒWn tk
r.td|ƒ‚YnX|S)Nz¿unknown encoding error handler: "%s" (choices: "strict", "ignore", "replace", "backslashreplace", "xmlcharrefreplace", and possibly others; see documentation for the Python ``codecs`` module))rÚlookup_errorr )r!rr"r#r$rrrÚvalidate_encoding_error_handlerWsr'cCsnd|krV|jdƒ\}}t|d||||ƒ|rB|j||d|ƒqZt|j|d|ƒn|}t|||||ƒ|S)zš
    Side-effect: if an error handler is included in the value, it is inserted
    into the appropriate place as if it was a separate setting/option.
    ú:Z_error_handler)Úsplitr'Úsetrrr%)r!rr"r#r$ÚencodingÚhandlerrrrÚ#validate_encoding_and_error_handlercs
r-cCsFt|tƒr|Sy|j|jƒjƒStk
r@td|ƒ‚YnXdS)z|Check/normalize boolean settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
    zunknown boolean value: "%s"N)Ú
isinstanceÚboolÚbooleansÚstripÚlowerÚKeyErrorr )r!rr"r#r$rrrÚvalidate_booleanys
r4cCsBt|tƒs|dkr|Sy|j|jƒjƒStk
r<|SXdS)zªCheck/normalize three-value settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
         any other value: returned as-is.
    N)r.r/r0r1r2r3)r!rr"r#r$rrrÚvalidate_ternary†sr5cCst|ƒ}|dkrtdƒ‚|S)Nrz(negative value; must be positive or zero)Úintr)r!rr"r#r$rrrÚvalidate_nonnegative_int”sr7cCsVyt|ƒStk
rPy|j|jƒSttfk
rJtd|ƒ‚YnXYnXdS)Nzunknown threshold: %r.)r6rÚ
thresholdsr2r3ÚAttributeErrorr )r!rr"r#r$rrrÚvalidate_threshold›sr:cCs2t|tƒs|jdƒ}n|jƒ}|j|jdƒƒ|S)Nr()r.Úlistr)ÚpopÚextend)r!rr"r#r$ÚlastrrrÚ$validate_colon_separated_string_list¥s

r?cCs:t|tƒs|g}|jƒ}dd„|jdƒDƒ}|j|ƒ|S)zHCheck/normalize list arguments (split at "," and strip whitespace).
    cSs g|]}|jdƒr|jdƒ‘qS)z 	
)r1)Ú.0Úirrrú
<listcomp>¹sz1validate_comma_separated_list.<locals>.<listcomp>ú,)r.r;r<r)r=)r!rr"r#r$r>r
rrrÚvalidate_comma_separated_list®s

rDcCs"|sdS|jdƒr|S|dSdS)Nz./ú/)Úendswith)r!rr"r#r$rrrÚvalidate_url_trailing_slash½s

rGcCs.ytjj|ƒStk
r(tjjdƒSXdS)N)ÚdocutilsÚutilsÚDependencyListÚIOError)r!rr"r#r$rrrÚvalidate_dependency_fileÆsrLcCsFt|||||ƒ}x0|D](}tjj|ƒ}||krtd||fƒ‚qW|S)Nz$Invalid class value %r (perhaps %r?))rDrHZnodesZmake_idr)r!rr"r#r$ÚclsÚ
normalizedrrrÚvalidate_strip_classÍs
rOc
CsÔt|||||ƒ}g}xº|D]²}y|jddƒ\}}WnFtk
rR|j|ƒwYn(tk
rxtd|jddƒƒ‚YnX|jƒ}|jdƒ}	t|	ƒdkrž|	}n t|ƒdkr¾td|jddƒƒ‚|j||fƒqW|S)z~Check/normalize a comma separated list of smart quote definitions.

    Return a list of (language-tag, quotes) string tuples.r(éz4Invalid value "%s". Format is "<language>:<quotes>".ÚasciiÚbackslashreplaceéz[Invalid value "%s". Please specify 4 quotes
    (primary open/close; secondary open/close).)rDr)r9ÚappendrÚencoder1Úlen)
r!rr"r#r$Z	lc_quotesÚitemÚlangÚquotesZmultichar_quotesrrrÚvalidate_smartquotes_localesÚs*


rZcsdˆdkrtƒ‰xP|D]H}||kr||}t|tƒrF‡fdd„|Dƒ}n|rTtˆ|ƒ}|||<qWdS)zÉ
    Interpret filesystem path settings relative to the `base_path` given.

    Paths are values in `pathdict` whose keys are in `keys`.  Get `keys` from
    `OptionParser.relative_path_settings`.
    Ncsg|]}tˆ|ƒ‘qSr)Úmake_one_path_absolute)r@Úpath)Ú	base_pathrrrBsz'make_paths_absolute.<locals>.<listcomp>)rr.r;r[)ZpathdictÚkeysr]rrr)r]rÚmake_paths_absoluteýs




r_cCstjjtjj||ƒƒS)N)Úosr\ÚabspathÚjoin)r]r\rrrr[sr[cOs’t|ƒ}x€tdt|ƒdƒD]l}g}xV||D]J}dd„|dDƒd}||krPq,||jƒkrl|j||ƒq,|j|ƒq,Wt|ƒ||<qWt|ƒS)aReturn a copy of `settings_spec` excluding/replacing some settings.

    `settings_spec` is a tuple of configuration settings with a structure
    described for docutils.SettingsSpec.settings_spec.

    Optional positional arguments are names of to-be-excluded settings.
    Keyword arguments are option specification replacements.
    (See the html4strict writer for an example.)
    ércSs*g|]"}|jdƒr|dd…jddƒ‘qS)z--rcNú-Ú_)Ú
startswithÚreplace)r@Z
opt_stringrrrrB$sz(filter_settings_spec.<locals>.<listcomp>rPr)r;ÚrangerVr^rTÚtuple)Ú
settings_specÚexcludergÚsettingsrAZnewoptsZopt_specÚopt_namerrrÚfilter_settings_specs

rnc@s0eZdZdZdd„Zdd„Zdd„Zdd	„Zd
S)ÚValuesz•
    Updates list attributes by extension rather than by replacement.
    Works in conjunction with the `OptionParser.lists` instance attribute.
    cOs:tjj|f|ž|Žt|dƒs*|jdkr6tjjƒ|_dS)NÚrecord_dependencies)ÚoptparseroÚ__init__ÚhasattrrprHrIrJ)Úselfrrrrrrr9s
zValues.__init__cCslt|tƒr|j}|jƒ}xD|jjƒD]6}t||ƒr$||kr$t||ƒ}|r$|||7}||=q$W|j|ƒdS)N)	r.roÚ__dict__ÚcopyÚlistsr^rsÚgetattrÚ
_update_loose)rtÚ
other_dictr"r!rrrrr@s


z
Values.updatecCs|j|jdS)z Return a shallow copy of `self`.)Údefaults)Ú	__class__ru)rtrrrrvLszValues.copycCs&t||dƒdkrt|||ƒt||ƒS)zUV.setdefault(n[,d]) -> getattr(V,n,d), also set D.n=d if n not in D or None.
        N)rxr)rtÚnameÚdefaultrrrÚ
setdefaultPszValues.setdefaultN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrrrvrrrrrro2s
roc@s$eZdZejjddgZdd„ZdS)ÚOptionÚ	validatorÚ	overridesc	Csžtjj|||||ƒ}|j}|rš|jr†t||ƒ}y|j|||ƒ}Wn8tk
rx}ztjd|t|ƒfƒ‚WYdd}~XnXt	|||ƒ|j
ršt	||j
dƒ|S)zœ
        Call the validator function on applicable settings and
        evaluate the 'overrides' option.
        Extends `optparse.Option.process`.
        zError in option "%s":
    %sN)rqr„ÚprocessÚdestr…rxÚ	ExceptionÚOptionValueErrorr
rr†)	rtrrrrÚresultr!Ú	new_valuerrrrr‡\s
"zOption.processN)r€rr‚rqr„ÚATTRSr‡rrrrr„Xsr„c8@s~eZdZdZdddgZdjƒZdddd	d
dœZddddd
d
d
d
d
dœ	Ze	e
jddƒpZepZdZ
dZddddgifdddgdedœfddgdddœfd d!d"gd#d$d%d&œfd'd(d)gd#d*d%d&œfd+d,gd#dd%d&œfd-d.d/gdedœfd0d1gd2d3ifd4d5gd6edÖd9œfd:d;gd<d#d=d=d>œfd?d@gd<d#dAdBœfdCdDgd<ddEœfdFdGgddedHœfdIdJgdKddEœfdLdMgddNdedOœfdPdQgddNdœfdRdSgdedœfdTdUgddVdœfdWdXgdYdZd[ed\œfd]d^gdYd_d[ed\œfd`dadbgeddcddedeœfdfdgdhgd#ddcd&œfdidjdkgd#d
dcd&œfdldmgednd	ddedoœfdpdqgd#ddnd&œfdrdsgedtd
ddedoœfdudvgdedœfdwdxgddydœfdzd{gd|d}d~œfdd€gddedHœfdd‚gdƒddEœfd„d…d†gd‡edˆœfd‰dŠgd‹edŒœfddŽdgd‡ded‘œfd’d“gd‹edŒœfd”e
efd•d–gd‡e
ed‘œfd—ed˜geedŒœfd™dšd›gdœddždŸœfd d¡gd}edd¢œfd£d¤gd}d¥d6ed¦œfd§d¨d©gdªd«ifd¬d­d®gdªd¯ifed°gd±d²ifed³gd±d´ifedµgdªdifed¶gdªdifed·gdªdifed¸gdªdifed¹gdYdºed»œfed¼gdªdiff2fZddddd½œZd×Zd¾Zd¿ejejr
dÀejpd²e
j jƒdÁe
j!fZ"fddfdÂdÄZ#dÄdńZ$dÆdDŽZ%dÈdɄZ&dÊd˄Z'dÌd̈́Z(dÎdτZ)dÐdфZ*dÒdӄZ+dÔdՄZ,dS)ØÚOptionParsera¢
    Parser for command-line and library use.  The `settings_spec`
    specification here and in other Docutils components are merged to build
    the set of command-line options and runtime settings for this process.

    Common settings (defined below) and component-specific settings must not
    conflict.  Short options are reserved for common settings, and components
    are restrict to using long options.
    z/etc/docutils.confz./docutils.confz~/.docutilsz(info 1 warning 2 error 3 severe 4 none 5rPrcrrSé)ÚinfoÚwarningrZsevereÚnoneTF)	Ú1ÚonÚyesÚtrueÚ0ÚoffÚnoÚfalseÚr+NrQrRzGeneral Docutils Optionsz'Specify the document title as metadata.z--titlez2Include a "Generated by Docutils" credit and link.z--generatorz-gÚ
store_true)Úactionr…z"Do not include a generator credit.z--no-generatorÚstore_falseÚ	generator)rrˆz2Include the date at the end of the document (UTC).z--datez-dÚstore_constz%Y-%m-%dZ	datestamp)rÚconstrˆzInclude the time & date (UTC).z--timez-tz%Y-%m-%d %H:%M UTCz'Do not include a datestamp of any kind.z--no-datestampz&Include a "View document source" link.z
--source-linkz-sz3Use <URL> for a source link; implies --source-link.z--source-urlÚmetavarz<URL>z-Do not include a "View document source" link.z--no-source-linkÚcallbackÚsource_linkÚ
source_url)rr£Ú
callback_argsz4Link from section headers to TOC entries.  (default)z--toc-entry-backlinksZ
toc_backlinksÚentry)rˆrr¡r~z0Link from section headers to the top of the TOC.z--toc-top-backlinksÚtop)rˆrr¡z+Disable backlinks to the table of contents.z--no-toc-backlinks)rˆrz6Link from footnotes/citations to references. (default)z--footnote-backlinks)rr~r…z/Disable backlinks from footnotes and citations.z--no-footnote-backlinksZfootnote_backlinksz0Enable section numbering by Docutils.  (default)z--section-numberingZ
sectnum_xform)rrˆr~r…z&Disable section numbering by Docutils.z--no-section-numberingz/Remove comment elements from the document tree.z--strip-commentsz6Leave comment elements in the document tree. (default)z--leave-commentsÚstrip_commentsz‹Remove all elements with classes="<class>" from the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z--strip-elements-with-classrTZstrip_elements_with_classesz<class>)rrˆr¢r…z”Remove all classes="<class>" attributes from elements in the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z
--strip-classZ
strip_classeszReport system messages at or higher than <level>: "info" or "1", "warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"z--reportz-rZreport_levelz<level>)Úchoicesr~rˆr¢r…z4Report all system messages.  (Same as "--report=1".)z	--verbosez-vz3Report no system messages.  (Same as "--report=5".)z--quietz-qzdHalt execution at system messages at or above <level>.  Levels as in --report.  Default: 4 (severe).z--haltZ
halt_level)rªrˆr~r¢r…z6Halt at the slightest problem.  Same as "--halt=info".z--strictzjEnable a non-zero exit status for non-halting system messages at or above <level>.  Default: 5 (disabled).z
--exit-statusZexit_status_levelz3Enable debug-level system messages and diagnostics.z--debugz Disable debug output.  (default)z
--no-debugÚdebugz-Send the output of system messages to <file>.z
--warningsÚwarning_streamz<file>)rˆr¢z1Enable Python tracebacks when Docutils is halted.z--tracebackz%Disable Python tracebacks.  (default)z--no-tracebackÚ	tracebackziSpecify the encoding and optionally the error handler of input text.  Default: <locale-dependent>:strict.z--input-encodingz-iz<name[:handler]>)r¢r…zlSpecify the error handler for undecodable characters.  Choices: "strict" (default), "ignore", and "replace".z--input-encoding-error-handlerÚstrict)r~r…z^Specify the text encoding and optionally the error handler for output.  Default: UTF-8:strict.z--output-encodingz-ozutf-8)r¢r~r…zŠSpecify error handler for unencodable output characters; "strict" (default), "ignore", "replace", "xmlcharrefreplace", "backslashreplace".z--output-encoding-error-handlerzJSpecify text encoding and error handler for error output.  Default: %s:%s.z--error-encodingz-ezSSpecify the error handler for unencodable characters in error output.  Default: %s.z--error-encoding-error-handlerz<Specify the language (as BCP 47 language tag).  Default: en.z
--languagez-lZ
language_codeÚenz<name>)rˆr~r¢z)Write output file dependencies to <file>.z--record-dependencies)r¢r…r~z6Read configuration settings from <file>, if it exists.z--configÚstring)r¢Útyperr£z,Show this program's version number and exit.z	--versionz-VrÚversionz Show this help message and exit.z--helpz-hÚhelpz--id-prefixr~r›z--auto-id-prefixÚidz--dump-settingsz--dump-internalsz--dump-transformsz--dump-pseudo-xmlz--expose-internal-attributeZexpose_internals)rrˆr…z--strict-visitor)Ú_disable_configÚ_sourceÚ_destinationÚ
_config_filesÚgeneralz(%%prog (Docutils %s%s, Python %s, on %s)z [%s]rcOsÖi|_g|_tjj|f|žtdtjdddœ|—Ž|jsB|j|_t	|j
ƒ|_
|ft|ƒ|_|j
|jƒ|j|ptiƒ|rÒ|jdrÒy|jƒ}Wn0tk
rÄ}z|jt|ƒƒWYdd}~XnX|j|jƒdS)z¶
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        NéN)Úwidth)Úoption_classÚadd_help_optionÚ	formatterrµ)rwÚconfig_filesrqrŽrrr„ÚTitledHelpFormatterr²Úversion_templater;Úrelative_path_settingsriÚ
componentsÚpopulate_from_componentsÚset_defaults_from_dictr{Úget_standard_config_settingsrrrru)rtrÃr{Zread_config_filesrrZconfig_settingsrrrrrrOs" zOptionParser.__init__c
CsþxÒ|D]Ê}|dkrq|j}|jj|jƒx¦tdt|ƒdƒD]’}|||d…\}}}|rrtj|||ƒ}|j|ƒn|}x@|D]8\}	}
}|j|
d|	i|—Ž}|j	dƒdkr|d|j
|j<q|W|jr:|j
j|jƒq:WqWx$|D]}|rÚ|jrÚ|j
j|jƒqÚWdS)aE
        For each component, first populate from the `SettingsSpec.settings_spec`
        structure, then from the `SettingsSpec.settings_defaults` dictionary.
        After all components have been processed, check for and populate from
        each component's `SettingsSpec.settings_default_overrides` dictionary.
        Nrrr³rrTT)rjrÂr=rhrVrqÚOptionGroupÚadd_option_groupÚ
add_optionÚgetrwrˆÚsettings_defaultsr{rZsettings_default_overrides)
rtrÃÚ	componentrjrAÚtitleÚdescriptionZoption_specÚgroupÚ	help_textÚoption_stringsrrrrrrÄos,


z%OptionParser.populate_from_componentscs€ytjdjtjƒ}Wntk
r0|j}YnXtjj‰dtjkrnyddl}Wnt	k
rldd„‰YnX‡fdd„|DƒS)	z:Return list of config files, from environment or standard.ZDOCUTILSCONFIGÚHOMErNcSs|S)Nr)ÚxrrrÚ<lambda>Ÿsz8OptionParser.get_standard_config_files.<locals>.<lambda>csg|]}|jƒrˆ|ƒ‘qSr)r1)r@Úf)ÚexpandrrrB sz:OptionParser.get_standard_config_files.<locals>.<listcomp>)
r`Úenvironr)Úpathsepr3Ústandard_config_filesr\Ú
expanduserÚpwdÚImportError)rtr¿rÛr)rÖrÚget_standard_config_filesŽs
z&OptionParser.get_standard_config_filescCs.tƒ}x"|jƒD]}|j|j|ƒ|ƒqW|S)N)rorÝrr)rtrlÚfilenamerrrrÆ¢sz)OptionParser.get_standard_config_settingscCs¦tƒ}|j||ƒ|jj|jƒtjj|ƒ}i}tƒ}xX|j	D]N}|sHq>xBt
|jpTfƒ|jfD](}||krnq`d||<|j
|j|ƒ|ƒq`Wq>Wt|j|j|ƒ|jS)zAReturns a dictionary containing appropriate config file settings.rP)ÚConfigParserÚreadr¿r=Ú_filesr`r\ÚdirnamerorÃriZconfig_section_dependenciesr$rÚget_sectionr_rurÂ)rtÚconfig_filerr]ZappliedrlrÌÚsectionrrrr¨s$z%OptionParser.get_config_file_settingscCs,|j|ƒ\|_|_t|j|jƒ|j|_|S)z/Store positional arguments as runtime settings.)Ú
check_argsr¶r·r_rurÂr¿r¸)rtrrrrrÚcheck_values½szOptionParser.check_valuescCshd}}|r"|jdƒ}|dkr"d}|r<|jdƒ}|dkr<d}|rJ|jdƒ|r`||kr`|jdƒ||fS)NrrdzMaximum 2 arguments allowed.z_Do not specify the same file for both source and destination.  It will clobber the source file.)r<r)rtrÚsourceZdestinationrrrræÄs



zOptionParser.check_argscCs|jj|ƒdS)N)r{r)rtr{rrrrÅÕsz#OptionParser.set_defaults_from_dictcCst|jƒ}|j|_|S)z(Needed to get custom `Values` instances.)ror{r¿r¸)rtr{rrrÚget_default_valuesØs
zOptionParser.get_default_valuescCsDx2|j|gD]"}x|jD]}|j|kr|SqWqWtd|ƒ‚dS)a
        Get an option by its dest.

        If you're supplying a dest which is shared by several options,
        it is undefined which option of those is returned.

        A KeyError is raised if there is no option with the supplied
        dest.
        zNo option with dest == %r.N)Ú
option_groupsÚoption_listrˆr3)rtrˆrÏrrrrÚget_option_by_destÞs


zOptionParser.get_option_by_dest)r¤r¥)r¬)-r€rr‚rƒrÙr)Zthreshold_choicesr8r0rxÚsysÚstderrrZdefault_error_encodingZ$default_error_encoding_error_handlerr4rrOr:r-r'rLrrr?rjrËrÂr$rHÚ__version__Z__version_details__r²ÚplatformrÁrrrÄrÝrÆrrçrærÅrérìrrrrrŽssf
















 rŽc@sPeZdZddddœZdZdZdd	„Zd
d„Zdd
„Zdd„Z	dd„Z
dd„ZdS)rßúpep_html writerÚ
stylesheetÚstylesheet_pathÚtemplate)Zpep_stylesheetZpep_stylesheet_pathZpep_templatea
The "[option]" section is deprecated.  Support for old-format configuration
files may be removed in a future Docutils release.  Please revise your
configuration files.  See <http://docutils.sf.net/docs/user/config.html>,
section "Old-Format Configuration Files".
zhUnable to read configuration file "%s": content not encoded as UTF-8.
Skipping "%s" configuration file.
cOs$tj|f|ž|Žg|_tƒ|_dS)N)rrrrár	Ú_stderr)rtrrrrrrrszConfigParser.__init__cCsèt|ƒttfkr|g}xÌ|D]Ä}ytj|ddƒ}Wntk
rHwYnXy,tjdkrftj	|||ƒntj
|||ƒWn4tk
rª|jj
|j||fƒ|jƒwYnX|jƒ|jj|ƒ|jdƒrÔ|j|ƒ|j||ƒqWdS)NÚrzutf-8rrÚoptions)rr)r±ÚstrÚunicoderÚopenrKríÚversion_inforÚreadfpÚ	read_fileÚUnicodeDecodeErrorrõÚwriteÚnot_utf8_errorÚcloserárTÚhas_sectionÚhandle_old_configÚvalidate_settings)rtÚ	filenamesr"rÞÚfprrrrà
s(



zConfigParser.readcCs¤tj|jt|dƒ|jdƒ}|jdƒs0|jdƒxd|jƒD]X\}}||jkrp|j|\}}|j|ƒsx|j|ƒnd}|}|j	||ƒs:|j
|||ƒq:W|jdƒdS)Nrr÷r¹)ÚwarningsÚ
warn_explicitÚold_warningÚConfigDeprecationWarningrãrÚadd_sectionr
Úold_settingsÚ
has_optionr*Úremove_section)rtrÞr÷rrrår!rrrr%s





zConfigParser.handle_old_configc	CsÜxÖ|jƒD]Ê}xÄ|j|ƒD]¶}y|j|ƒ}Wntk
rBwYnX|jrº|j||ƒ}y|j|||||d}Wn<tk
rª}z td||t|ƒ||fƒ‚WYdd}~XnX|j	|||ƒ|j
r|j	||j
dƒqWq
WdS)zi
        Call the validator function and implement overrides on all applicable
        settings.
        )r#r$zAError in config file "%s", section "[%s]":
    %s
        %s = %sN)Úsectionsr÷rìr3r…rÊr‰rr
r*r†)	rtrÞr"rår!rrrŒrrrrr7s(
zConfigParser.validate_settingscCs|jƒjddƒS)zW
        Transform '-' to '_' so the cmdline form of option names can be used.
        rdre)r2rg)rtÚ	optionstrrrrÚoptionxformSszConfigParser.optionxformcCs6i}|j|ƒr2x"|j|ƒD]}|j||ƒ||<qW|S)zf
        Return a given section as a dictionary (empty if the section
        doesn't exist).
        )rr÷rÊ)rtråZsection_dictrrrrrãYs

zConfigParser.get_sectionN)rñrò)rñró)rñrô)r€rr‚rr	rrrràrrrrãrrrrrßïs		rßc@seZdZdZdS)r
z3Warning for deprecated configuration file features.N)r€rr‚rƒrrrrr
esr
)rr)rr)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)N)1rƒZ
__docformat__r`Úos.pathrírrrqrrûÚconfigparserrrrßrrHZdocutils.utilsZdocutils.nodesZdocutils.utils.error_reportingrrr	r
rørùrrr%r'r-r4r5r7r:r?rDrGrLrOrZr_r[rnror„rŽZSettingsSpecÚDeprecationWarningr
rrrrÚ<module>sX


	







	

	


"
&~v