m iEc@sdZdZdkZdkZdkZdkZdkZdkZdk Z dk Z ydk Z dk l Z Wn)e j odkZ dkl Z nXdZdZeedZeedZeedZeed Zeed Zeed Zeed Zeed ZeedZedZdZde ifdYZde ifdYZde ie i fdYZdeifdYZde!fdYZ"dS(s 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_threshold`, `validate_colon_separated_string_list`, `validate_dependency_file`. * `make_paths_absolute`. treStructuredTextN(s SUPPRESS_HELPcOsXx!|D]}t|i|dqWx-|iD]\}}t|i||q1WdS(s 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( targst attributetsetattrtparsertvaluestNonetkwargstitemstkeytvalue(toptiontoptR RRRRR ((t0/data/zmath/zope/lib/python/docutils/frontend.pytstore_multiple/s cCsOy|i|}Wn"tj o}|i|nX|ii||dS(sQ Read a configuration file during option processing. (Option callback.) N(Rtget_config_file_settingsR t new_settingst ValueErrorterrorRtupdate(R R R RRR((R tread_config_file;s cCsTyti|Wn<tj o0td||fdtidfnX|S(Ns$setting "%s": unknown encoding: "%s"i(tcodecstlookupR t LookupErrortsettingRtsystexc_info(RR t option_parsert config_parsertconfig_section((R tvalidate_encodingEs .cCsyti|Wn|tj o;|djo'td|dtidfqn7tj o*td|dtidfnX|S( Ntstricttignoretreplacetxmlcharrefreplaceseunknown encoding error handler: "%s" (choices: "strict", "ignore", "replace", or "xmlcharrefreplace")isunknown encoding error handler: "%s" (choices: "strict", "ignore", "replace", "backslashreplace", "xmlcharrefreplace", and possibly others; see documentation for the Python ``codecs`` module)(sstrictsignoresreplacesxmlcharrefreplace(Rt lookup_errorR tAttributeErrorRRRR(RR RRR((R tvalidate_encoding_error_handlerOs +(cCsd|jol|id\}}t|d|||||o|i ||d|qt |i |d|n|}t ||||||S(s 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. t:t_error_handlerN( R tsplittencodingthandlerR%RRRRtsetRRR(RR RRRR)R*((R t#validate_encoding_and_error_handlerbs     cCsot|tioXy|i|iiSWqktj o*t d|dt i dfqkXn|S(Nsunknown boolean value: "%s"i( t isinstanceR ttypest StringTypeRtbooleanststriptlowertKeyErrorRRRR(RR RRR((R tvalidate_booleanxs ,cCs-t|}|djotdn|S(Nis(negative value; must be positive or zero(tintR R(RR RRR((R tvalidate_nonnegative_ints  cCsyyt|SWndtj oXy|i|iSWquttfj o'td|dt i dfquXnXdS(Nsunknown threshold: %r.i( R5R RRt thresholdsR2R3R$RRRR(RR RRR((R tvalidate_thresholdscCsLt|tio|id}n#|i}|i|id|S(NR&(R-R R.R/R(tpoptlasttextend(RR RRRR:((R t$validate_colon_separated_string_lists  cCs3|pdSn!|ido|Sn |dSdS(Ns./t/(R tendswith(RR RRR((R tvalidate_url_trailing_slashs cCs>ytii|SWn#tj otiidSnXdS(N(tdocutilstutilstDependencyListR tIOErrorR(RR RRR((R tvalidate_dependency_filescCs|djoti}nx|D]}|i|os||}t |t i o.g}|D]}|t||qb~}n|ot||}n|||}tid||ii|fdtidfnXt|||n|iot||idqn|S(s Call the validator function on applicable settings and evaluate the 'overrides' option. Extends `optparse.Option.process`. s Error in option "%s": %s: %siN(RTRctprocessRVR R RRtresulttdestRRdR\t new_valuet ExceptionRtOptionValueErrorR_R`RRRRRe( RVR R RRRRgRRi((R Rfs  : (R`RaRTRctATTRSRf(((R Rcst OptionParserc7BstZdZdddgZdiZhdd<dd<d d <d d <d dd?ghd"d@<d@e <dAdBdCf verbatim for a "View document source" link; implies --source-link.s --source-urltmetavarss-Do not include a "View document source" link.s--no-source-linktcallbackt callback_argst source_linkt source_urlsYEnable backlinks from section headers to table of contents entries. This is the default.s--toc-entry-backlinkst toc_backlinkstentrytdefaultsJEnable backlinks from section headers to the top of the table of contents.s--toc-top-backlinksttops+Disable backlinks to the table of contents.s--no-toc-backlinkssXEnable backlinks from footnotes and citations to their references. This is the default.s--footnote-backlinkss/Disable backlinks from footnotes and citations.s--no-footnote-backlinkstfootnote_backlinkss5Enable Docutils section numbering (default: enabled).s--section-numberingt sectnum_xforms6Disable Docutils section numbering (default: enabled).s--no-section-numberingsERemove comment elements from the document tree (default: leave them).s--strip-commentssBLeave comment elements in the document tree (this is the default).s--leave-commentststrip_commentssSet verbosity threshold; report system messages at or higher than (by name or number: "info" or "1", warning/2, error/3, severe/4; also, "none" or "5"). Default is 2 (warning).s--reports-rtchoicest report_levelssNReport all system messages, info-level and higher. (Same as "--report=info".)s --verboses-vs>Do not report any system messages. (Same as "--report=none".)s--quiets-qsSet the threshold () at or above which system messages are converted to exceptions, halting execution immediately by exiting (or propagating the exception if --traceback set). Levels as in --report. Default is 4 (severe).s--haltt halt_levels@Same as "--halt=info": halt processing at the slightest problem.s--strictsEnable a non-zero exit status for normal exit if non-halting system messages (at or above ) were generated. Levels as in --report. Default is 5 (disabled). Exit status is the maximum system message level plus 10 (11 for INFO, etc.).s --exit-statustexit_status_levelsBReport debug-level system messages and generate diagnostic output.s--debugsHDo not report debug-level system messages or generate diagnostic output.s --no-debugtdebugs8Send the output of system messages (warnings) to .s --warningstwarning_streamssEnable Python tracebacks when halt-level system messages and other exceptions occur. Useful for debugging, and essential for issue reports.s --tracebacksaDisable Python tracebacks when errors occur; report just the error instead. This is the default.s--no-tracebackt tracebacksSpecify the encoding of input text. Default is locale-dependent. Optionally also specify the error handler for undecodable characters, after a colon (":"); default is "strict". (See "--intput-encoding-error-handler".)s--input-encodings-issSpecify the error handler for undecodable characters in the input. Acceptable values include "strict", "ignore", and "replace". Default is "strict". Usually specified as part of --input-encoding.s--input-encoding-error-handlerRsSpecify the text encoding for output. Default is UTF-8. Optionally also specify the error handler for unencodable characters, after a colon (":"); default is "strict". (See "--output-encoding-error-handler".)s--output-encodings-osutf-8sSpecify the error handler for unencodable characters in the output. Acceptable values include "strict", "ignore", "replace", "xmlcharrefreplace", and "backslashreplace" (in Python 2.3+). Default is "strict". Usually specified as part of --output-encoding.s--output-encoding-error-handlersSpecify the text encoding for error output. Default is ASCII. Optionally also specify the error handler for unencodable characters, after a colon (":"); default is "%s". (See "--output-encoding-error-handler".)s--error-encodings-etasciisSpecify the error handler for unencodable characters in error output. See --output-encoding-error-handler for acceptable values. Default is "%s". Usually specified as part of --error-encoding.s--error-encoding-error-handlers]Specify the language of input text (ISO 639 2-letter identifier). Default is "en" (English).s --languages-lt language_codetensspWrite dependencies (caused e.g. by file inclusions) to . Useful in conjunction with programs like "make".s--record-dependenciess6Read configuration settings from , if it exists.s--configttypetstrings,Show this program's version number and exit.s --versions-Vtversions Show this help message and exit.s--helps-hthelps --id-prefixs--auto-id-prefixtids--dump-settingss--dump-internalss--dump-transformss--dump-pseudo-xmls--expose-internal-attributetappendtexpose_internalss--strict-visitort_disable_configt_sourcet _destinationtgenerals%%prog (Docutils %s [%s])c Osh|_tii|dtdddtidd|||i p|i |_ nt |i |_ |ft||_|i|i|i|ph|oX|id oIy|i}Wn"tj o}|i|nX|i|indS(s `components` is a list of Docutils components each containing a ``.settings_spec`` attribute. `defaults` is a mapping of setting default overrides. t option_classtadd_help_optiont formattertwidthiNRN(RVR[RTRmRURcRtTitledHelpFormatterRRRtversion_templatetlisttrelative_path_settingsttuplet componentstpopulate_from_componentst set_defaultsR^tread_config_filestget_standard_config_settingstconfig_settingsRRRY(RVRR^RRRRR((R RUs"  c Cskx+|D]#}|djoqn|i}|ii|ixtdt|dD]}|||d!\}}}|o&t i|||}|i|n|}xY|D]Q\} } } |id| | | } | iddjod|i| i, section "Old-Format Configuration Files". cCst|titifjo |g}nxR|D]J}tii|||i do|i |n|i ||q3WdS(Ntoptions(Rt filenamesR.R/t UnicodeTypeRtCPRRRVt has_sectionthandle_old_configtvalidate_settingsR(RVRRR((R Rs cCsti|it|d|id}|idp|i dnx|i D]\}}|i i|o8|i |\}}|i|p|i |qn d}|}|i||p|i|||qVqVW|iddS(NiRR(twarningst warn_explicitRVt old_warningtConfigDeprecationWarningRRRRt add_sectionRR R t old_settingsRJRRt has_optionR+tremove_section(RVRR RR RR((R Rs   c Cs6x/|iD]!}x|i|D]}y|i|}Wntj o q#nX|i o|i ||dd}y%|i |||d|d|}WnPt j oD}td|||ii|||fdtidfnX|i|||n|io|i||idq#q#Wq WdS(si Call the validator function and implement overrides on all applicable settings. trawiRRsEError in config file "%s", section "[%s]": %s: %s %s = %siN(RVtsectionsRRRRRR R3RdRR RiRjRRRR_R`RRRR+Re( RVRRR RRR RRi((R Rs&  @ cCs|iiddS(sW Transform '-' to '_' so the cmdline form of option names can be used. Rt_N(t optionstrR2R!(RVR((R t optionxformscCsTh}|i|o:x7|i|D]"}|i||dd||