
    ohe^                        d Z dZddlZddlZddlZddlmZ ddlZddlZddlZddl	Z	ddl
Z
ddl
mZmZ d Zd Z	 d#dZ	 d#d	Z	 d#d
Z	 d#dZ	 d#dZ	 d#dZ	 d#dZ	 d#dZ	 d#dZ	 d#dZ	 d#dZ	 d#dZ	 d#dZd$dZd Zd Z G d dej>                        Z G d dej@                        Z  G d dejB                  e
jD                        Z! G d dejF                        Z$ G d  d!e%      Z&d" Z'y)%a  
Command-line and common processing for Docutils front-end tools.

This module is provisional.
Major changes will happen with the switch from the deprecated
"optparse" module to "arparse".

Applications should use the high-level API provided by `docutils.core`.
See https://docutils.sourceforge.io/docs/api/runtime-settings.html.

Exports the following classes:

* `OptionParser`: Standard Docutils command-line processing.
  Deprecated. Will be replaced by an ArgumentParser.
* `Option`: Customized version of `optparse.Option`; validation support.
  Deprecated. Will be removed.
* `Values`: Runtime settings; objects are simple structs
  (``object.attribute``).  Supports cumulative list settings (attributes).
  Deprecated. Will be removed.
* `ConfigParser`: Standard Docutils config file processing.
  Provisional. Details will change.

Also exports the following functions:

Interface function:
   `get_default_settings()`.  New in 0.19.

Option callbacks:
   `store_multiple()`, `read_config_file()`. Deprecated.

Setting validators:
  `validate_encoding()`, `validate_encoding_error_handler()`,
  `validate_encoding_and_error_handler()`,
  `validate_boolean()`, `validate_ternary()`,
  `validate_nonnegative_int()`, `validate_threshold()`,
  `validate_colon_separated_string_list()`,
  `validate_comma_separated_list()`,
  `validate_url_trailing_slash()`,
  `validate_dependency_file()`,
  `validate_strip_class()`
  `validate_smartquotes_locales()`.

  Provisional.

Misc:
  `make_paths_absolute()`, `filter_settings_spec()`. Provisional.
reStructuredText    N)SUPPRESS_HELP)ioutilsc                     |D ]  }t        |j                  |d        |j                         D ]  \  }}t        |j                  ||        y)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keys           3/usr/lib/python3/dist-packages/docutils/frontend.pystore_multipler   E   sL      0	y$/0lln +
UsE*+    c                     	 |j                  |      }|j                  j	                  |       y# t        $ r}|j                  |       Y d}~<d}~ww xY w)zQ
    Read a configuration file during option processing.  (Option callback.)
    N)get_config_file_settings
ValueErrorerrorr	   update)r   r   r   r   new_settingserrs         r   read_config_filer   R   sN    66u= MMv.  Ss   0 	AAAc                 |    |dk(  ry 	 t        j                  |       |S # t        $ r t        d| d|d      w xY w)N z	setting "z": unknown encoding: "")codecslookupLookupErrorsettingr   option_parserconfig_parserconfig_sections        r   validate_encodingr)   ]   sL    {.e L  .$e- . 	..s    ;c                 h    	 t        j                  |       |S # t        $ r t        d|z        w xY w)Nzunknown encoding error handler: "%s" (choices: "strict", "ignore", "replace", "backslashreplace", "xmlcharrefreplace", and possibly others; see documentation for the Python ``codecs`` module))r!   lookup_errorr#   r$   s        r   validate_encoding_error_handlerr,   i   sI    5E" L  5, /445 	55s    1c                     d|v rZ|j                  d      \  }}t        | dz   ||||       |r|j                  || dz   |       nt        |j                  | dz   |       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.
    :_error_handler)splitr,   setr   r	   r)   )r%   r   r&   r'   r(   encodinghandlers          r   #validate_encoding_and_error_handlerr4   v   s     e|!KK,''&&>	+ ng8H.H%' M(('4D*DgNgx#^5Or   c                     t        |t              r|S 	 |j                  |j                         j	                            S # t
        $ r t        d|z        w xY w)z|Check/normalize boolean settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
    zunknown boolean value: "%s")
isinstanceboolbooleansstriplowerKeyErrorr#   r$   s        r   validate_booleanr<      s[     %A%%ekkm&9&9&;<< A7%?@@As	   *? Ac                     t        |t              s||S 	 |j                  |j                         j	                            S # t
        $ r |cY S w xY w)zCheck/normalize three-value settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
         any other value: returned as-is.
    )r6   r7   r8   r9   r:   r;   r$   s        r   validate_ternaryr>      sP     %%-%%ekkm&9&9&;<< s   *A AAc                 <    t        |      }|dk  rt        d      |S )Nr   z(negative value; must be positive or zero)intr   r$   s        r   validate_nonnegative_intrA      s#    JEqyCDDLr   c                     	 t        |      S # t        $ rB 	 |j                  |j                            cY S # t        t
        f$ r t        d|z        w xY ww xY w)Nzunknown threshold: %r.)r@   r   
thresholdsr:   r;   AttributeErrorr#   r$   s        r   validate_thresholdrE      sg    @5z @	@ ++EKKM::.) 	@6>??	@@s   
 	A6AAAc                     t        |t              s|j                  d      }|S |j                         }|j	                  |j                  d             |S )Nr.   )r6   listr0   popextend)r%   r   r&   r'   r(   lasts         r   $validate_colon_separated_string_listrK      sG    eT"C  L yy{TZZ_%Lr   c                     t        |t              s|g}|j                         }|j                  d      D cg c]%  }|j	                  d      s|j	                  d      ' }}|j                  |       |S c c}w )zHCheck/normalize list arguments (split at "," and strip whitespace).
    ,z 	
)r6   rG   rH   r0   r9   rI   )r%   r   r&   r'   r(   rJ   ir
   s           r   validate_comma_separated_listrO      sh     eT" 99;D'+zz#K!!''':JQWWWKEK	LLL Ls   A6A6c                 8    |sy|j                  d      r|S |dz   S )Nz.//)endswithr$   s        r   validate_url_trailing_slashrS      s#    		s{r   c                 v    	 t        j                  |      S # t        $ r t        j                  d       cY S w xY wN)r   DependencyListOSErrorr$   s        r   validate_dependency_filerX      s8    *##E** *##D))*s    88c                     t        | ||||      }|D ]8  }t        j                  j                  |      }||k7  s(t	        d|d|d       |S )NzInvalid class value z
 (perhaps z?))rO   docutilsnodesmake_idr   )r%   r   r&   r'   r(   cls
normalizeds          r   validate_strip_classr_      se     *'5-*7IE  2^^++C0
* #Z1 2 22
 Lr   c           	         t        | ||||      }g }|D ]  }	 |j                  dd      \  }}|j                         }|j                  d      }	t        |	      dk(  r|	}n,t        |      dk7  rt	        d|j                  dd      z        |j                  ||f        |S # t        $ r |j                  |       Y t        $ r t	        d|j                  dd      z        w xY w)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).)rO   r0   rD   appendr   encoder9   len)
r%   r   r&   r'   r(   	lc_quotesitemlangquotesmultichar_quotess
             r   validate_smartquotes_localesrm      s#    *'5-*7IE I )
	I::c1-LD& !<<, A%%F[A O#{{74FGH I I 	$(+), '  	 T" 	I A#{{74FGH I I	Is   B""C%>'C%c                     |t        j                         }|D ]I  }|| v s| |   }t        |t              r|D cg c]  }t	        ||       }}n|rt	        ||      }|| |<   K yc c}w )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`.
    N)osgetcwdr6   rG   make_one_path_absolute)pathdictkeys	base_pathr   r   paths         r   make_paths_absoluterv     s     IIK	 "(?SME%&%*,! 0	4@ , ,.y%@!HSM",s   A&c                 |    t         j                  j                  t         j                  j                  | |            S rU   )ro   ru   abspathjoin)rt   ru   s     r   rq   rq   0  s$    77??277<<	4899r   c           	         t        |       }t        dt        |      d      D ]  }g }||   D ]y  }|d   D cg c](  }|j                  d      r|dd j	                  dd      * c}d   }||v rB||j                         v r|j                  ||          i|j                  |       { t        |      ||<    t        |      S c c}w )	aj  Return a copy of `settings_spec` excluding/replacing some settings.

    `settings_spec` is a tuple of configuration settings
    (cf. `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.)
          ra   z--N-_r   )rG   rangerg   
startswithreplacers   re   tuple)	settings_specexcluder   settingsrN   newoptsopt_spec
opt_stringopt_names	            r   filter_settings_specr   4  s     M"H1c(mQ' %  
	)H +31+8&%006 #12..sC8 889;H 7"7<<>)wx01x(
	) Gn% ?8s   -Cc                   4     e Zd ZdZ fdZd Zd Zd Z xZS )ValueszStorage for option values.

    Updates list attributes by extension rather than by replacement.
    Works in conjunction with the `OptionParser.lists` instance attribute.

    Deprecated. Will be removed.
    c                     t        j                  dt        d       t        |   |i | t        | dd       t        j                         | _        y y )Nz@frontend.Values class will be removed in Docutils 0.21 or later.r{   
stacklevelrecord_dependencies)	warningswarnDeprecationWarningsuper__init__getattrr   rV   r   selfr   r   	__class__s      r   r   zValues.__init__Z  sS     3(Q	8 	$)&)4.5=',';';'=D$ >r   c                 
   t        |t              r|j                  }t        |      }|j                  j                         D ].  }t        | |      s||v st        | |      }|s$|||   z  }||= 0 | j                  |       y rU   )	r6   r   __dict__dictlistsrs   hasattrr   _update_loose)r   
other_dictr&   r%   r   s        r   r   zValues.updatec  s    j&)#,,J*%
$**//1 	,GtW%'Z*?g.Z00E"7+	, 	:&r   c                     t        j                         5  t        j                  dt               | j	                  | j
                        cddd       S # 1 sw Y   yxY w)z Return a shallow copy of `self`.ignorecategory)defaultsN)r   catch_warningsfilterwarningsr   r   r   )r   s    r   copyzValues.copyo  sF    $$& 	:##H7IJ>>4==>9	: 	: 	:s   7AAc                 N    t        | |d      t        | ||       t        | |      S )znReturn ``self.name`` or ``default``.

        If ``self.name`` is unset, set ``self.name = default``.
        N)r   r   )r   namedefaults      r   
setdefaultzValues.setdefaultu  s,    
 4t$,D$(tT""r   )	__name__
__module____qualname____doc__r   r   r   r   __classcell__r   s   @r   r   r   Q  s    >
':#r   r   c                   b     e Zd ZdZej
                  j                  ddgz   Z fdZ fdZ xZ	S )Optionz`Add validation and override support to `optparse.Option`.

    Deprecated. Will be removed.
    	validator	overridesc                 \    t        j                  dt        d       t        |   |i | y )NzDThe frontend.Option class will be removed in Docutils 0.21 or later.r{   r   )r   r   r   r   r   r   s      r   r   zOption.__init__  s-     3(Q	8 	$)&)r   c           	      ~   t         	|   ||||      }| j                  }|r\| j                  r-t	        ||      }	 | j                  |||      }t        |||       | j                  rt        || j                  d       |S # t
        $ r3}t        j                  d|dt        j                  |            d}~ww xY w)z
        Call the validator function on applicable settings and
        evaluate the 'overrides' option.
        Extends `optparse.Option.process`.
        zError in option "z":
    N)r   processdestr   r   	ExceptionoptparseOptionValueErrorr   error_stringr   r   )
r   r   r   r	   r   resultr%   	new_valuer   r   s
            r   r   zOption.process  s     eVV<))~~07 $wv FI
 3~~5 ! 7"33 467 77s   B   	B<	.B77B<)
r   r   r   r   r   r   ATTRSr   r   r   r   s   @r   r   r     s2    
 OO!![+$>>E* r   r   c                       e Zd ZdZg dZ	 dj                         Z	 dddddd	Z	 d
d
d
d
dddddd	Z	  e	e
j                  dd      xs ej                  xs dZdZddg ddgddifddgddifdddgdedfddgd d!d"fd#d$d%gd&d'd(d)fd*d+d,gd&d-d(d)fd.d/gd&dd(d)fd0d1d2gdedfd3d4gdd5ifd6d7gd8ed9d:fd;d<gd=d&d>d>d?fd@dAgd=d&dBdCfdDdEgd=d dFfdGdHgddedIfdJdKgdLd dFfdMdNgddOdedPfdQdRgd dOd"fdSdTgdedfdUdVgd dWd"fdXdYgdZd[d\ed]fd^d_gdZd`d\ed]fdadbdcgeddddeedffdgdhdigd&dddd)fdjdkdlgd&dddd)fdmdngedoddeedpfdqdrgd&ddod)fdsdtgeduddeedpfdvdwgdedfdxdygd dzd"fd{d|gd}d~dfddgddedIfddgdd dFfdddgdedfddgdedfdddgddedfddgdedfdez  ddgdeedfdez  dgeedfdddgddddfddgd~eddfddgd~dd8edfdddgddifdddgddifedgddifedgddifedgddifedgddifedgddifedgddifedgdZdedfedgddiffZ	 dddddZ	 dZdej<                  ej>                  xr dej>                  z  xs dde
j@                  j                         d   de
jB                  dŝZ"	 dЈ fdƄ	Z#dǄ Z$e%dȄ        Z&dɄ Z'dʄ Z(d˄ Z)d̄ Z*d̈́ Z+d΄ Z,dτ Z- xZ.S )OptionParsera  
    Settings 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 restricted to using long options.

    Deprecated.
    Will be replaced by a subclass of `argparse.ArgumentParser`.
    )z/etc/docutils.confz./docutils.confz~/.docutilsz(info 1 warning 2 error 3 severe 4 none 5ra   r{   r|   rd      )infowarningr   severenoneTF)	1onyestrue0offnofalser   r2   Nrb   rc   zGeneral Docutils OptionszaOutput destination name. Obsoletes the <destination> positional argument. Default: None (stdout).z--outputmetavarz<destination>z'Specify the document title as metadata.z--titlez<title>z2Include 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-%d	datestamp)r   constr   zInclude 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-urlz<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-backlinks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-backlinksfootnote_backlinksz0Enable section numbering by Docutils.  (default)z--section-numbering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_commentszRemove all elements with classes="<class>" from the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z--strip-elements-with-classre   strip_elements_with_classesz<class>)r   r   r   r   zRemove all classes="<class>" attributes from elements in the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z--strip-classstrip_classeszReport system messages at or higher than <level>: "info" or "1", "warning"/"2" (default), "error"/"3", "severe"/"4", "none"/"5"z--reportz-r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--halt
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-statusexit_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	tracebackzdSpecify the encoding and optionally the error handler of input text.  Default: <auto-detect>: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-outf-8)r   r   r   zSpecify error handler for unencodable output characters; "strict" (default), "ignore", "replace", "xmlcharrefreplace", "backslashreplace".z--output-encoding-error-handlerzSpecify text encoding and optionally error handler for error output.  Default text encoding: system encoding. Default error handler: %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-l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%z--dump-settingsz--dump-internalsz--dump-transformsz--dump-pseudo-xmlz--expose-internal-attributeexpose_internals)r   r   r   z--strict-visitor)_disable_config_source_destination_config_filesgeneralz%prog (Docutils z [%s]z	, Python r   z, on )c                 h   i | _         	 g | _        	 dg| _        t        j                  dt
        d       t        |   |t        dt        j                  d      d| | j                  s| j                  | _        | g|| _        | j                  | j                         | j                  j!                  |xs i        |rG| j                  d	   s7	 | j#                         }| j                  j!                  j(                         yyy# t$        $ r}| j'                  |       Y d}~Gd}~ww xY w)
zSet up OptionParser instance.

        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.
        `defaults` is a mapping of setting default overrides.
        r   ztThe frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.r{   r   NN   )width)option_classadd_help_option	formatterr   )r   config_filesrelative_path_settingsr   r   r   r   r   r   r   TitledHelpFormatterr   version_template
componentspopulate_from_componentsr   r   get_standard_config_settingsr   r   r   )	r   r  r   read_config_filesr   r   config_settingsr   r   s	           r   r   zOptionParser.__init__  s    
(;'7&8# 3 )Q	8 	 '-d#+#?#?b#I	*"(	* ||00DL-*-%%doo6X^,T]]3D%E "&"C"C"E MM  !9!9: &F   

3 s   D 	D1D,,D1c                    |D ]
  }||j                   }| j                  j                  |j                         t        dt	        |      d      D ]  }|||dz    \  }}}|r)t        j                  | ||      }| j                  |       n| }|D ]H  \  }	}
} |j                  |
d|	i|}|j                  d      dk(  s0d| j                  |j                  <   J |j                  s| j                  j                  |j                           |D ]7  }|s|j                  s| j                  j                  |j                         9 y)ao  Collect settings specification from components.

        For each component, 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.
        Nr   r|   r   r   re   T)r   r  rI   r   rg   r   OptionGroupadd_option_group
add_optiongetr   r   settings_defaultsr   r   settings_default_overrides)r   r  	componentr   rN   titledescriptionoption_specgroup	help_textoption_stringsr   r   s                r   r  z%OptionParser.populate_from_components  s[    $ 	FI %33M''..0021c-0!4 F2?!A#2F/{K$00ukJE))%0 E;F 77Y-U--~ 89 8068Fzz(+x726

6;;/	7
 ..MM(()D)DEF	F( $ 	KIYAA$$Y%I%IJ	Kr   c                 &   dt         j                  v r1t         j                  d   j                  t         j                        }n| j                  }|D cg c]2  }|j                         st         j                  j                  |      4 c}S c c}w )z:Return list of config files, from environment or standard.DOCUTILSCONFIG)ro   environr0   pathsepstandard_config_filesr9   ru   
expanduser)r]   r  fs      r   get_standard_config_filesz&OptionParser.get_standard_config_files  sd     rzz)::&67==bjjIL44L/;I!qwwy""1%IIIs   B*!Bc                    t        j                         5  t        j                  dt               t	               }d d d        | j                         D ]#  }j                  | j                  |      |        % S # 1 sw Y   AxY w)Nr   r   )r   r   r   r   r   r   r   r   )r   r   filenames      r   r  z)OptionParser.get_standard_config_settings  su    $$& 	 ##H7IJxH	  668 	KHOOD99(CTJ	K	  	 s   &A;;Bc                    t               }t               }t        j                         5  t        j                  dt
               | xj                  |j                  ||       z  c_        t               }ddd       | j                  D ]n  }|st        |j                  xs d      |j                  fz   D ]?  }||v r|j                  |       |j                  |      s+j                  ||   |        A p t!        j"                  | j$                  t&        j(                  j+                  |             |j"                  S # 1 sw Y   xY w)zAReturns a dictionary containing appropriate config file settings.r   r   N )ConfigParserr1   r   r   r   r   r  readr   r  r   config_section_dependenciesr(   addhas_sectionr   rv   r   r  ro   ru   dirname)r   config_filer'   appliedr   r  sections          r   r   z%OptionParser.get_config_file_settings  s'   $%$$& 	 ##H7IJ!3!3K!FFxH	   		BI!)"G"G"M2N(779: Bg%G$ ,,W5OOM'$:DAB		B 	H-- 77GGOOK8	:    #	  	 s   AEEc                     | j                  |      \  |_        |_        t        |j                  | j
                         | j                  |_        |S )z/Store positional arguments as runtime settings.)
check_argsr   r   rv   r   r  r  r   )r   r	   r   s      r   check_valueszOptionParser.check_values  sA    .2ood.C++FOOT-H-HI#00r   c                     d x}}|r|j                  d      }|dk(  rd }|r|j                  d      }|dk(  rd }|r| j                  d       |r||k(  r| j                  d       ||fS )Nr   r}   zMaximum 2 arguments allowed.z_Do not specify the same file for both source and destination.  It will clobber the source file.)rH   r   )r   r   sourcedestinations       r   r/  zOptionParser.check_args   s}    ##XXa[F}((1+Kc!"JJ56f+JJ H I{""r   c                 :    | j                   j                  |       y rU   )r   r   r   r   s     r   set_defaults_from_dictz#OptionParser.set_defaults_from_dict  s    X&r   c                     t        j                         5  t        j                  dt               t	        | j
                        }ddd       | j                  _        |S # 1 sw Y   xY w)z(Needed to get custom `Values` instances.r   r   N)r   r   r   r   r   r   r  r   r5  s     r   get_default_valueszOptionParser.get_default_values  sW    $$& 	-##H7IJdmm,H	- "&!2!2		- 	-s   1A!!A*c                     | j                   | gz   D ](  }|j                  D ]  }|j                  |k(  s|c c S  * t        d|z        )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.
        zNo option with dest == %r.)option_groupsoption_listr   r;   )r   r   r  r   s       r   get_option_by_destzOptionParser.get_option_by_dest  sY     ''4&0 	"E++ ";;$&!M"	" 3d:;;r   )r$  NF)/r   r   r   r   r  r0   threshold_choicesrC   r8   r   sysstderrr   _locale_encodingdefault_error_encoding$default_error_encoding_error_handlerr<   r   r_   rE   r4   r,   rX   r   r   rK   r   r  r(   rZ   __version____version_details__r   platformr  r   r  classmethodr   r  r   r0  r/  r6  r8  r<  r   r   s   @r   r   r     s   
 CHHJGAANJ@dDuEEuFH?%cjj*dC )!#!4!4)!(  ,>( 	#e	 9,O4
6 e	 4+	9-
/e	
 ?$
L/?"A
Be	 /
L
Ne	 ?T
}z%02
3e	 +T
}&:%02
3e	" 4
'24
5#e	( 3D
!l1A$C
D)e	. @
Y0
2/e	2 :
^9;
<3e	: A"
#"mg
 ;e	B = 
!"me
L
NCe	H 8
 "m
<
>Ie	N C!
"!a(*
+Oe	V <$
%'=
A
CWe	\ = 
!!?&68
9]e	d 3#
$"O
<
>ee	j <
!0@
A
Cke	p C
",<
=
?qe	v# )
)'D.BD	
Ewe	B# 
.BD	
ECe	NKt
*;'5),>@
AOe	X A
-!(6 8
9Ye	^ @d
&46
7_e	d9*"3\"#	$68
9ee	n C,=1!-/
0oe	t6
):&9)*y+=?
@ue	@ @+,%57
8Ae	F -.]GD
FGe	J :.#3I
KKe	N >/lt)9;
<Oe	T 2
{mL
NUe	XIt
$(;=
>Ye	bB+
,-L
M
Oce	j,
%(W;=
>ke	t5 -
--L
M	
Oue	~')MN t
$(5K;=	
>e	J(01 ,
,:79	
:Ke	V I
T,4!6
7We	\ 6"
#-E
]e	d C,Hh#-;KM
Nee	j 9
)4
6ke	n -T
Xv.
0oe	t -9b/	:ue	v ,-	3/?	@we	z +,x.F	G{e	| ,-,/G	H}e	~ -.<0H	Ie	@ -.<0H	IAe	B 78'9<>
?Ce	H ,-,/G	HIe	hMR0 -1$()-*.0
 N $//#77 D&x'C'CCJGIJ;;,,.q13<<	A
 #";HK@ J J!0#"'<r   r   c                   R     e Zd ZdZddddZ	 dZdZd fd	Zd	 Zd
 Z	d Z
d Z xZS )r%  aZ  Parser for Docutils configuration files.

    See https://docutils.sourceforge.io/docs/user/config.html.

    Option key normalization includes conversion of '-' to '_'.

    Config file encoding is "utf-8". Encoding errors are reported
    and the affected file(s) skipped.

    This class is provisional and will change in future versions.
    )pep_html writer
stylesheet)rH  stylesheet_path)rH  template)pep_stylesheetpep_stylesheet_pathpep_templatea  The "[option]" section is deprecated.
Support for old-format configuration files will be removed in Docutils 0.21 or later.  Please revise your configuration files.  See <https://docutils.sourceforge.io/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.
c                 t   |t        j                  dt        d       g }t        |t              r|g}|D ]A  }	 |t
        |   |d      z  }d| v r| j                  |       |0| j                  ||       C |S # t        $ r1 t        j                  j                  | j                  ||fz         Y w xY w)Nzbfrontend.ConfigParser.read(): parameter "option_parser" will be removed in Docutils 0.21 or later.r{   r   r   )r2   options)r   r   r   r6   strr   r&  UnicodeDecodeErrorr>  r?  writenot_utf8_errorhandle_old_configvalidate_settings)r   	filenamesr&   read_okr"  r   s        r   r&  zConfigParser.readO  s     $MM 7 -< i%"I! 
	@H57<7<CC D &&x0(&&x?
	@  & 

  !4!4(7K!KLs   A==7B76B7c                    t        j                  | j                  t        |d       | j	                  d      }| j                  d      s| j                  d       |j                         D ]r  \  }}|| j                  v r5| j                  |   \  }}| j                  |      s| j                  |       nd}|}| j                  ||      r`| j                  |||       t | j                  d       y )Nr   rP  r   )r   warn_explicitold_warningConfigDeprecationWarningget_sectionr)  add_sectionr
   old_settings
has_optionr1   remove_section)r   r"  rP  r   r   r-  r%   s          r   rU  zConfigParser.handle_old_configg  s    t//1I'	,""9-	*Y'!--/ 		2JCd'''#'#4#4S#9 ''0$$W-#??7G4'51		2 	I&r   c                    | j                         D ]  }| j                  |      D ]  }	 |j                  |      }|j                  r<| j                  ||      }	 |j	                  |||| |      }| j                  |||       |j                  sj| j                  ||j                  d         y# t        $ r Y w xY w# t        $ r2}t        d| d| dt        j                  |       d| d| 
      d}~ww xY w)zi
        Call the validator function and implement overrides on all applicable
        settings.
        )r'   r(   zError in config file "z", section "[z]":
    z	
        z = N)sectionsrP  r<  r;   r   r  r   r   r   r   r1   r   )	r   r"  r&   r-  r%   r   r   r   r   s	            r   rV  zConfigParser.validate_settingsy  s-   
 }} 	>G<<0 >*==gFF ## HHWg6EI$*$4$4#UM*.w %5 %H	 HHWgy9##HHWf&6&6=%>	>    % I(+A( L66=Y ?0020D/E F44;9Cw*H I IIs)   B1C 1	B=<B= 	C;	-C66C;c                 B    |j                         j                  dd      S )z
        Lowercase and transform '-' to '_'.

        So the cmdline form of option names can be used in config files.
        r}   r~   )r:   r   )r   	optionstrs     r   optionxformzConfigParser.optionxform  s      ((c22r   c                 z    t        j                  dt        d       	 t        | |         S # t        $ r i cY S w xY w)z
        Return a given section as a dictionary.

        Return empty dictionary if the section doesn't exist.

        Deprecated. Use the configparser "Mapping Protocol Access" and
        catch KeyError.
        zNfrontend.OptionParser.get_section() will be removed in Docutils 0.21 or later.r{   r   )r   r   r   r   r;   )r   r-  s     r   r]  zConfigParser.get_section  sC     	 C(Q	8	W&& 	I	s   , ::rU   )r   r   r   r   r_  r[  rT  r&  rU  rV  rf  r]  r   r   s   @r   r%  r%  .  sI    
 <E79L
	4 N
0'$>43r   r%  c                       e Zd ZdZy)r\  z3Warning for deprecated configuration file features.N)r   r   r   r   r$  r   r   r\  r\    s    =r   r\  c                      t        j                         5  t        j                  dt               t	        |       j                         cddd       S # 1 sw Y   yxY w)a|  Return default runtime settings for `components`.

    Return a `frontend.Values` instance with defaults for generic Docutils
    settings and settings from the `components` (`SettingsSpec` instances).

    This corresponds to steps 1 and 2 in the `runtime settings priority`__.

    __ https://docutils.sourceforge.io/docs/api/runtime-settings.html
       #settings-priority
    r   r   N)r   r   r   r   r   r8  )r  s    r   get_default_settingsrj    sG     
	 	 	" =3EFJ'::<= = =s   4AA)NNrU   )(r   __docformat__r!   configparserr   r   ro   os.pathr>  r   rZ   r   r   r   r   r)   r,   r4   r<   r>   rA   rE   rK   rO   rS   rX   r_   rm   rv   rq   r   r   r   r   SettingsSpecRawConfigParserr%  FutureWarningr\  rj  r$  r   r   <module>rq     sF  
.` #    " 	  
   
+/ :>	 HL
 GK0 9=A 9=  AE ;?@ GK FJ" GK AE* =A EI!H"(::+#X__ +#\"X__ "JG<8(((*?*? G<T|<// |~>} >=r   