U@Pc@sdZdZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl Z ddl Z ddlmZmZmZdZdZeedZeed Zeed Zeed Zeed Zeed ZeedZeedZeedZeedZeedZeedZ edZ!dZ"dZ#de j$fdYZ$de j%fdYZ%de j&e j'fdYZ&dej(fdYZde)fd YZ*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_ternary`, `validate_threshold`, `validate_colon_separated_string_list`, `validate_comma_separated_string_list`, `validate_dependency_file`. * `make_paths_absolute`. * SettingSpec manipulation: `filter_settings_spec`. treStructuredTextiN(t SUPPRESS_HELP(tlocale_encodingt ErrorOutputt ErrorStringcOsXx!|D]}t|j|dqWx-|jD]\}}t|j||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(tsetattrtvaluestNonetitems(toptiontopttvaluetparsertargstkwargst attributetkey((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytstore_multiple.s cCsMy|j|}Wn tk r5}|j|nX|jj||dS(sQ Read a configuration file during option processing. (Option callback.) N(tget_config_file_settingst ValueErrorterrorRtupdate(R R R R t new_settingsR((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytread_config_file:s cCsRytj|Wn:tk rMtd||fdtjdfnX|S(Ns$setting "%s": unknown encoding: "%s"i(tcodecstlookupt LookupErrorRtsystexc_info(tsettingR t option_parsert config_parsertconfig_section((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_encodingDs  cCsLytj|Wn4tk rGtd|dtjdfnX|S(Nsunknown encoding error handler: "%s" (choices: "strict", "ignore", "replace", "backslashreplace", "xmlcharrefreplace", and possibly others; see documentation for the Python ``codecs`` module)i(Rt lookup_errorRRRR(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_encoding_error_handlerNs cCsd|kru|jd\}}t|d|||||r[|j||d|q{t|j|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_handler(tsplitR#tsetRRR!(RR RRR tencodingthandler((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyt#validate_encoding_and_error_handler[s      cCsit|tr|Sy|j|jjSWn4tk rdtd|dtj dfnXdS(s|Check/normalize boolean settings: True: '1', 'on', 'yes', 'true' False: '0', 'off', 'no','false', '' sunknown boolean value: "%s"iN( t isinstancetbooltbooleanststriptlowertKeyErrorRRRR(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_booleanqs  cCsSt|ts|dkr|Sy|j|jjSWntk rN|SXdS(sCheck/normalize three-value settings: True: '1', 'on', 'yes', 'true' False: '0', 'off', 'no','false', '' any other value: returned as-is. N(R+R,RR-R.R/R0(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_ternarys  cCs+t|}|dkr'tdn|S(Nis(negative value; must be positive or zero(tintR(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_nonnegative_ints  cCsuyt|SWn`tk rpy|j|jSWqqttfk rltd|dtj dfqqXnXdS(Nsunknown threshold: %r.i( R3Rt thresholdsR/R0tAttributeErrorRRRR(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_thresholds  cCsGt|ts!|jd}n"|j}|j|jd|S(NR$(R+tlistR&tpoptextend(RR RRR tlast((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyt$validate_colon_separated_string_lists  cCsrt|ts|g}n|j}g|jdD]$}|jdr7|jd^q7}|j||S(sHCheck/normalize list arguments (split at "," and strip whitespace). u,u (R+R8R9R&R.R:(RR RRR R;tiR((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_comma_separated_lists   : cCs)|s dS|jdr|S|dSdS(Ns./t/(tendswith(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_url_trailing_slashs cCs9ytjj|SWntk r4tjjdSXdS(N(tdocutilstutilstDependencyListtIOErrorR(RR RRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_dependency_files cCsdt|||||}xE|D]=}tjj|}||krtd||fqqW|S(Ns$invalid class value %r (perhaps %r?)(R>RBtnodestmake_idR(RR RRR tclst normalized((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytvalidate_strip_classs    cCs|dkrtj}nx}|D]u}||kr"||}t|trrg|D]}t||^qT}n|rt||}n|||gid?d"6ed?6ddB6fdCdDgidEd(6d,d"6dFd.6dFdG6fdHdIgidEd(6d,d"6dJd.6fdKdLgidEd(6d&d"6fdMdNgid!d"6ddG6ed#6fdOdPgidQd(6d&d"6fdRdSgid!d"6dTd(6ddG6ed#6fdUdVgid&d"6dTd(6fdWdXgid!d"6ed#6fdYdZgid&d"6d[d(6fd\d]gid^d"6d_d(6d`d<6ed#6fdadbgid^d"6dcd(6d`d<6ed#6fdddedfgiedg6ddG6dhd(6did<6ed#6fdjdkdlgid,d"6dd.6dhd(6fdmdndogid,d"6d d.6dhd(6fdpdqgiedg6drd(6d dG6did<6ed#6fdsdtgid,d"6dd.6drd(6fdudvgiedg6dwd(6d dG6did<6ed#6fdxdygid!d"6ed#6fdzd{gid&d"6d|d(6fd}d~gidd(6dd<6fddgid!d"6ddG6ed#6fddgidd(6d&d"6fdddgidd<6ed#6fddgiddG6ed#6fdddgidd<6ddG6ed#6fddgiddG6ed#6fdeefddgidd<6edG6ed#6fdedgiedG6ed#6fdddgidd(6ddG6dd<6fddgidd<6ed#6ddG6fddgidd<6dd6d?d"6ed?6fdddgidd"6fdddgidd"6fedgiddG6fedgiddG6fedgid!d"6fedgid!d"6fedgid!d"6fedgid!d"6fedgid^d"6dd(6ed#6fedgid!d"6ff2fZidd6dd6dd6dd6ZdZdZdej ej!e j"jde j#fZ$ddddZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.RS(s 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. s/etc/docutils.confs./docutils.confs ~/.docutilss(info 1 warning 2 error 3 severe 4 none 5itinfoitwarningiRitsevereitnonet1tontyesttruet0tofftnotfalsetR(tasciitbackslashreplacesGeneral Docutils Optionss'Specify the document title as metadata.s--titles2Include a "Generated by Docutils" credit and link.s --generators-gt store_truetactionRxs"Do not include a generator credit.s--no-generatort store_falset generatorR{s2Include the date at the end of the document (UTC).s--dates-dt store_consts%Y-%m-%dtconstt datestampsInclude the time & date (UTC).s--times-ts%Y-%m-%d %H:%M UTCs'Do not include a datestamp of any kind.s--no-datestamps&Include a "View document source" link.s --source-links-ss3Use for a source link; implies --source-link.s --source-urlstmetavars-Do not include a "View document source" link.s--no-source-linktcallbackt source_linkt source_urlt callback_argss4Link from section headers to TOC entries. (default)s--toc-entry-backlinkst toc_backlinkstentrytdefaults0Link from section headers to the top of the TOC.s--toc-top-backlinksttops+Disable backlinks to the table of contents.s--no-toc-backlinkss6Link from footnotes/citations to references. (default)s--footnote-backlinkss/Disable backlinks from footnotes and citations.s--no-footnote-backlinkstfootnote_backlinkss0Enable section numbering by Docutils. (default)s--section-numberingt sectnum_xforms&Disable section numbering by Docutils.s--no-section-numberings/Remove comment elements from the document tree.s--strip-commentss6Leave comment elements in the document tree. (default)s--leave-commentststrip_commentssRemove all elements with classes="" from the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)s--strip-elements-with-classR\tstrip_elements_with_classesssRemove all classes="" attributes from elements in the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)s --strip-classt strip_classessReport system messages at or higher than : "info" or "1", "warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"s--reports-rtchoicest report_levelss4Report all system messages. (Same as "--report=1".)s --verboses-vs3Report no system messages. (Same as "--report=5".)s--quiets-qsdHalt execution at system messages at or above . Levels as in --report. Default: 4 (severe).s--haltt halt_levels6Halt at the slightest problem. Same as "--halt=info".s--strictsjEnable a non-zero exit status for non-halting system messages at or above . Default: 5 (disabled).s --exit-statustexit_status_levels3Enable debug-level system messages and diagnostics.s--debugs Disable debug output. (default)s --no-debugtdebugs-Send the output of system messages to .s --warningstwarning_streamss1Enable Python tracebacks when Docutils is halted.s --tracebacks%Disable Python tracebacks. (default)s--no-tracebackt tracebacksiSpecify the encoding and optionally the error handler of input text. Default: :strict.s--input-encodings-isslSpecify the error handler for undecodable characters. Choices: "strict" (default), "ignore", and "replace".s--input-encoding-error-handlertstricts^Specify the text encoding and optionally the error handler for output. Default: UTF-8:strict.s--output-encodings-osutf-8sSpecify error handler for unencodable output characters; "strict" (default), "ignore", "replace", "xmlcharrefreplace", "backslashreplace".s--output-encoding-error-handlersJSpecify text encoding and error handler for error output. Default: %s:%s.s--error-encodings-esSSpecify the error handler for unencodable characters in error output. Default: %s.s--error-encoding-error-handlers<Specify the language (as BCP 47 language tag). Default: en.s --languages-lt language_codetenss)Write output file dependencies to .s--record-dependenciess6Read configuration settings from , if it exists.s--configtstringttypes,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-attributetexpose_internalss--strict-visitort_disable_configt_sourcet _destinationt _config_filestgenerals+%%prog (Docutils %s [%s], Python %s, on %s)ic Osi|_g|_tjj|dtdddtjdd|||js^|j |_nt |j |_ |ft ||_ |j|j |j|pi|r|jd ry|j}Wn tk r}|j|nX|j|jndS(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(Rnt config_filesRhRRiRwRtTitledHelpFormatterRtversion_templateR8trelative_path_settingsR]t componentstpopulate_from_componentstset_defaults_from_dictRrtget_standard_config_settingsRRRl(RkRRrtread_config_filesR Rtconfig_settingsR((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRis$     c Cs`x#|D]}|dkrqn|j}|jj|jxtdt|dD]}|||d!\}}}|rtj|||}|j|n|}xW|D]O\} } } |j d| | | } | j ddkrd|j | j s,        cCsytjdjtj}Wntk r9|j}nXtjj}dtjkryddl}Wqt k rd}qXng|D]}|j r||^qS(s:Return list of config files, from environment or standard.tDOCUTILSCONFIGtHOMEiNcSs|S(N((tx((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytns( RLtenvironR&tpathsepR0tstandard_config_filesRRt expandusertpwdt ImportErrorR.(RkRtexpandRtf((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytget_standard_config_files]s    cCs=t}x-|jD]}|j|j||qW|S(N(RfRRR(RkR`tfilename((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRqs cCst}|j|||jj|jtjj|}i}t}x||j D]q}|siqWnx\t |j p{d|j fD];}||krqnd||<|j |j||qWqWWt|j|j||jS(sAReturns a dictionary containing appropriate config file settings.i((t ConfigParsertreadRR:t_filesRLRRtdirnameRfRR]tconfig_section_dependenciesR Rt get_sectionRSRlR(Rkt config_fileR RQtappliedR`Rtsection((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRws$    !cCs>|j|\|_|_t|j|j|j|_|S(s/Store positional arguments as runtime settings.(t check_argsRRRSRlRRR(RkRR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyt check_valuess cCsd}}|r7|jd}|dkr7d}q7n|rd|jd}|dkrdd}qdn|rz|jdn|r||kr|jdn||fS(NiRVsMaximum 2 arguments allowed.s_Do not specify the same file for both source and destination. It will clobber the source file.(RR9R(RkR tsourcet destination((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRs     cCs|jj|dS(N(RrR(RkRr((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRscCst|j}|j|_|S(s(Needed to get custom `Values` instances.(RfRrRR(RkRr((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytget_default_valuess cCsVx?|j|gD]-}x$|jD]}|j|kr!|Sq!WqWtd|dS(s 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. sNo option with dest == %r.N(t option_groupst option_listR{R0(RkR{RR ((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytget_option_by_dests  N(RR(R((/RtRuRvRR&tthreshold_choicesR5tTruetFalseR-RoRtstderrRRtdefault_error_encodingt$default_error_encoding_error_handlerR1RRKR7R*R#RFRRR<R^RRR RBt __version__t__version_details__RtplatformRRiRRRRRRRRR(((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRDsb   )&                                          RcBseeZidd6dd6dd6ZdZdZd Zd Zd Zd Zd Z dZ RS(spep_html writert stylesheettpep_stylesheettstylesheet_pathtpep_stylesheet_pathttemplatet pep_templates 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 , section "Old-Format Configuration Files". shUnable to read configuration file "%s": content not encoded as UTF-8. Skipping "%s" configuration file. cOs/tjj|||g|_t|_dS(N(tCPtRawConfigParserRiRRt_stderr(RkR R((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRis  cCs2t|ttfkr$|g}nx|D]}ytj|dd}Wntk r`q+nXyBtjdkrtj j |||ntj j |||Wn;t k r|j j|j||f|jq+nX|j|jj||jdr|j|n|j||q+WdS(Ntrsutf-8iitoptions(ii(RtstrtunicodeRtopenRERt version_infoRRtreadfpt read_filetUnicodeDecodeErrorRtwritetnot_utf8_errortcloseRR\t has_sectionthandle_old_configtvalidate_settings(Rkt filenamesRRtfp((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRs(      cCstj|jt|d|jd}|jdsG|jdnx|jD]\}}||jkr|j|\}}|j|s|j|qn d}|}|j ||sT|j |||qTqTW|j ddS(NiRR( twarningst warn_explicitt old_warningtConfigDeprecationWarningRRt add_sectionRt old_settingst has_optionR'tremove_section(RkRRRR RR((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRs c Cs%x|jD]}x|j|D]}y|j|}Wntk rRq#nX|jr|j||}y%|j|||d|d|}WnKtk r}td||t|||fdt j dfnX|j |||n|j r#|j ||j dq#q#Wq WdS(si Call the validator function and implement overrides on all applicable settings. RR sAError in config file "%s", section "[%s]": %s %s = %siN(tsectionsRRR0RxRR|RRRRRR'Ry( RkRRRRR R RR((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyRs(   ' cCs|jjddS(sW Transform '-' to '_' so the cmdline form of option names can be used. RVRW(R/R[(Rkt optionstr((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pyt optionxform"scCsLi}|j|rHx0|j|D]}|j||||RARFRKRSRNReRfRwRt SettingsSpecRtDeprecationWarningR(((s;/usr/local/lib/python2.7/site-packages/docutils/frontend.pytsH                   {v