V!\c@s-dZdZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl Z ddl Z ddlmZmZmZmZdZdZeedZeed Zeed Zeed Zeed Zeed ZeedZeedZeedZeedZeedZ eedZ!eedZ"edZ#dZ$dZ%de j&fdYZ&de j'fdYZ'de j(e j)fdYZ(dej*fdYZd e+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 SafeStringt 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((s5/tmp/pip-install-usGedi/docutils/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((s5/tmp/pip-install-usGedi/docutils/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((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_encodingEs  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 RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_encoding_error_handlerOs 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 RR R!tencodingthandler((s5/tmp/pip-install-usGedi/docutils/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 RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_booleanrs  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/R0R1(RR RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_ternarys  cCs+t|}|dkr'tdn|S(Nis(negative value; must be positive or zero(tintR(RR RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_nonnegative_ints  cCsuyt|SWn`tk rpy|j|jSWqqttfk rltd|dtj dfqqXnXdS(Nsunknown threshold: %r.i( R4Rt thresholdsR0R1tAttributeErrorRRRR(RR RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_thresholds  cCsGt|ts!|jd}n"|j}|j|jd|S(NR%(R,tlistR'tpoptextend(RR RR R!tlast((s5/tmp/pip-install-usGedi/docutils/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,R9R:R'R/R;(RR RR R!R<tiR ((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_comma_separated_lists   : cCs)|s dS|jdr|S|dSdS(Ns./t/(tendswith(RR RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_url_trailing_slashs cCs9ytjj|SWntk r4tjjdSXdS(N(tdocutilstutilstDependencyListtIOErrorR(RR RR R!((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_dependency_files cCsdt|||||}xE|D]=}tjj|}||krtd||fqqW|S(Ns$Invalid class value %r (perhaps %r?)(R?RCtnodestmake_idR(RR RR R!tclst normalized((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_strip_classs    c Cst|||||}g}x|D]}y|jdd\}}WnMtk rj|j|q%n-tk rtd|jddnX|j}|jd} t| dkr| }n1t|dkrtd|jddn|j||fq%W|S(s~Check/normalize a comma separated list of smart quote definitions. Return a list of (language-tag, quotes) string tuples.R%iu4Invalid value "%s". Format is ":".tasciitbackslashreplaceis[Invalid value "%s". Please specify 4 quotes (primary open/close; secondary open/close).(R?R'R7tappendRtencodeR/tlen( RR RR R!t lc_quotestitemtlangtquotestmultichar_quotes((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytvalidate_smartquotes_localess*        cCs|dkrtj}nx}|D]u}||kr"||}t|trrg|D]}t||^qT}n|rt||}n|||tnewoptstopt_spect opt_stringtopt_name((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytfilter_settings_specs ( tValuescBs)eZdZdZdZdZRS(s Updates list attributes by extension rather than by replacement. Works in conjunction with the `OptionParser.lists` instance attribute. cOsNtjj|||t|d s5|jdkrJtjj|_ndS(Ntrecord_dependencies( toptparseRpt__init__thasattrRqRRCRDRE(tselfRR((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRs4scCst|tr|j}n|j}xb|jjD]Q}t||r7||kr7t||}|r|||7}||=qq7q7W|j|dS(N( R,Rpt__dict__tcopytlistsR\Rttgetattrt _update_loose(Rut other_dictRRR ((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyR;s  cCs|jd|jS(s Return a shallow copy of `self`.tdefaults(t __class__Rv(Ru((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRwGs(t__name__t __module__t__doc__RsRRw(((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRp-s  tOptioncBs'eZejjddgZdZRS(t validatort overridesc Cstjj|||||}|j}|r|jrt||}y|j|||}WnEtk r}tjd|t|fdt j dfnXt |||n|j rt ||j dqn|S(s Call the validator function on applicable settings and evaluate the 'overrides' option. Extends `optparse.Option.process`. sError in option "%s": %siN(RrRtprocesstdestRRyt ExceptiontOptionValueErrorRRRRRR( RuR R RR tresultRt new_valueR((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRPs    (R~RRrRtATTRSR(((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRLst OptionParserc8BseZdZdddgZdjZidd6dd6d d 6d d 6d d6Zi ed6ed6ed6ed6ed6ed6ed6ed6ed6Z e e j ddpepdZdZddddgifddd gid!d"6ed#6fd$d%gid&d"6d'd(6fd)d*d+gid,d"6d-d.6d/d(6fd0d1d2gid,d"6d3d.6d/d(6fd4d5gid,d"6dd.6d/d(6fd6d7d8gid!d"6ed#6fd9d:gid;d<6fd=d>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!rdej!pde 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)RMRNsGeneral Docutils Optionss'Specify the document title as metadata.s--titles2Include a "Generated by Docutils" credit and link.s --generators-gt store_truetactionRs"Do not include a generator credit.s--no-generatort store_falset generatorRs2Include 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-classROtstrip_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)s [%s]ic Os i|_g|_tjj|dtdddtjdd|||js^|j |_nt |j |_ |ft ||_ |j|j |j|pi|r |jd r y|j}Wn&tk r}|jt|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(Rxt config_filesRrRRsRRtTitledHelpFormatterRtversion_templateR9trelative_path_settingsRgt componentstpopulate_from_componentstset_defaults_from_dictR|tget_standard_config_settingsRRRRv(RuRR|tread_config_filesRRtconfig_settingsR((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRsDs$     c Cs`x#|D]}|dkrqn|j}|jj|jxtdt|dD]}|||d!\}}}|rtj|||}|j|n|}xW|D]O\} } } |j d| | | } | j ddkrd|j | j ttitlet descriptiont option_spectgroupt help_texttoption_stringsRR ((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRds,        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((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyts( RXtenvironR'tpathsepR1tstandard_config_filesR^t expandusertpwdt ImportErrorR/(RuRtexpandRtf((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytget_standard_config_filess    cCs=t}x-|jD]}|j|j||qW|S(N(RpRRR(RuRjtfilename((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRs 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_filesRXR^tdirnameRpRRgtconfig_section_dependenciesR!Rt get_sectionR_RvR(Rut config_fileR R]tappliedRjRtsection((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRs$    !cCs>|j|\|_|_t|j|j|j|_|S(s/Store positional arguments as runtime settings.(t check_argsRRR_RvRRR(RuRR((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyt check_valuess cCsd}}|r7|jd}|dkr7d}q7n|rd|jd}|dkrdd}qdn|rz|jdn|r||kr|jdn||fS(NiRbsMaximum 2 arguments allowed.s_Do not specify the same file for both source and destination. It will clobber the source file.(RR:R(RuRtsourcet destination((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRs     cCs|jj|dS(N(R|R(RuR|((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRscCst|j}|j|_|S(s(Needed to get custom `Values` instances.(RpR|RR(RuR|((s5/tmp/pip-install-usGedi/docutils/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_listRR1(RuRRR ((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pytget_option_by_dests  N(RR(R((/R~RRRR'tthreshold_choicesR6tTruetFalseR.RyRtstderrRRtdefault_error_encodingt$default_error_encoding_error_handlerR2RRLR8R+R$RGRRR=RhRRR!RCt __version__t__version_details__RtplatformRRsRRRRRRRRR(((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRhsf   )&                                          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(tCPtRawConfigParserRsRRt_stderr(RuRR((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyRss  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(RtstrtunicodeRtopenRFRt version_infoR R treadfpt read_filetUnicodeDecodeErrorRtwritetnot_utf8_errortcloseRROt has_sectionthandle_old_configtvalidate_settings(Rut filenamesRRtfp((s5/tmp/pip-install-usGedi/docutils/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_sectionR t old_settingst has_optionR(tremove_section(RuRRRR RR((s5/tmp/pip-install-usGedi/docutils/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. R R!sAError in config file "%s", section "[%s]": %s %s = %siN(tsectionsRRR1RRRRRRRRR(R( RuRRRRR R RR((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyR,s(   ' cCs|jjddS(sW Transform '-' to '_' so the cmdline form of option names can be used. RbRc(R0Rf(Rut optionstr((s5/tmp/pip-install-usGedi/docutils/docutils/frontend.pyt optionxformHscCsLi}|j|rHx0|j|D]}|j||||sJ          "       "   }v