o
    b                     @   s  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d Zdd	 Z	d6d
dZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6ddZ	d6d d!Z	d6d"d#Zd7d$d%Zd&d' Zd(d) ZG d*d+ d+ejZG d,d- d-ej Z G d.d/ d/ej!e
j"Z!G d0d1 d1ej#Z$G d2d3 d3e%Z&d4d5 Z'dS )8a  
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.
ZreStructuredText    N)SUPPRESS_HELP)ioutilsc                 O   s<   |D ]	}t |j|d q| D ]\}}t |j|| qdS )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   5usr/lib/python3.10/site-packages/docutils/frontend.pystore_multipleE   s
   r   c              
   C   sP   z| |}W n ty } z|| W Y d}~nd}~ww |j|| dS )zQ
    Read a configuration file during option processing.  (Option callback.)
    N)get_config_file_settings
ValueErrorerrorr   update)r   r	   r
   r   Znew_settingserrr   r   r   read_config_fileR   s   r   c                 C   s0   zt | W |S  ty   td| |f w )Nz$setting "%s": unknown encoding: "%s")codecslookupLookupErrorsettingr
   option_parserconfig_parserconfig_sectionr   r   r   validate_encoding]   s   r!   c                 C   s,   zt | W |S  ty   td| 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   r   r   r   validate_encoding_error_handlerg   s   r#   c                 C   sn   d|v r+| d\}}t| d |||| |r!||| d | nt|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#   setr   r   r!   )r   r
   r   r   r    encodinghandlerr   r   r   #validate_encoding_and_error_handlert   s    
r)   c                 C   s>   t |tr|S z
|j|   W S  ty   td| 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   r   r   r   validate_boolean   s   
r0   c                 C   sB   t |ts	|du r|S z
|j|   W S  ty    | Y S w )zCheck/normalize three-value settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
         any other value: returned as-is.
    N)r*   r+   r,   r-   r.   r/   r   r   r   r   validate_ternary   s   r1   c                 C   s   t |}|dk rtd|S )Nr   z(negative value; must be positive or zero)intr   r   r   r   r   validate_nonnegative_int   s   r3   c                 C   sN   zt |W S  ty&   z
|j|  W  Y S  ttfy%   td| w w )Nzunknown threshold: %r.)r2   r   
thresholdsr.   r/   AttributeErrorr   r   r   r   r   validate_threshold   s   
r6   c                 C   s4   t |ts|d}|S | }||d |S )Nr$   )r*   listr%   popextend)r   r
   r   r   r    lastr   r   r   $validate_colon_separated_string_list   s   

r;   c                 C   s:   t |ts|g}| }dd |dD }|| |S )zHCheck/normalize list arguments (split at "," and strip whitespace).
    c                 S   s    g | ]}| d r| d qS )z 	
)r-   ).0ir   r   r   
<listcomp>        z1validate_comma_separated_list.<locals>.<listcomp>,)r*   r7   r8   r%   r9   )r   r
   r   r   r    r:   r   r   r   r   validate_comma_separated_list   s   

rA   c                 C   s   |sdS | dr|S |d S )Nz.//)endswithr   r   r   r   validate_url_trailing_slash   s
   
rD   c                 C   s*   zt |W S  ty   t d  Y S w N)r   DependencyListOSErrorr   r   r   r   validate_dependency_file   s
   rH   c                 C   sB   t | ||||}|D ]}tj|}||krtd||f q
|S )Nz$Invalid class value %r (perhaps %r?))rA   docutilsnodesZmake_idr   )r   r
   r   r   r    cls
normalizedr   r   r   validate_strip_class   s   rM   c           
   
   C   s   t | ||||}g }|D ]T}z
|dd\}}W n ty&   || Y q ty6   td|dd w | }|d}	t|	dkrI|	}nt|dkrYtd|dd |||f q|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).)rA   r%   r5   appendr   encoder-   len)
r   r
   r   r   r    Z	lc_quotesitemlangquotesZmultichar_quotesr   r   r   validate_smartquotes_locales   s2   



rX   c                    sb    du rt   |D ]$}|| v r.| | }t|tr# fdd|D }n|r*t |}|| |< q
dS )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`.
    Nc                    s   g | ]}t  |qS r   )make_one_path_absolute)r<   path	base_pathr   r   r>   '  s    z'make_paths_absolute.<locals>.<listcomp>)osgetcwdr*   r7   rY   )Zpathdictkeysr\   r   r
   r   r[   r   make_paths_absolute  s   


r`   c                 C   s   t jt j| |S rE   )r]   rZ   abspathjoin)r\   rZ   r   r   r   rY   .  s   rY   c                 O   s   t | }tdt|dD ]4}g }|| D ]%}dd |d D d }||v r&q|| v r4|||  q|| qt|||< qt|S )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.)
          c                 S   s*   g | ]}| d r|dd ddqS )z--rc   N-_)
startswithreplace)r<   Z
opt_stringr   r   r   r>   B  s    z(filter_settings_spec.<locals>.<listcomp>rN   r   )r7   rangerT   r_   rR   tuple)settings_specexcluderh   settingsr=   ZnewoptsZopt_specopt_namer   r   r   filter_settings_spec2  s    
ro   c                       s8   e Zd ZdZ fddZdd Zdd Zdd	 Z  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                    sD   t jdtdd t j|i | t| dd d u r t | _d S d S )Nz@frontend.Values class will be removed in Docutils 0.21 or later.rc   
stacklevelrecord_dependencies)	warningswarnDeprecationWarningsuper__init__getattrr   rF   rs   selfr   r   	__class__r   r   rx   X  s   zValues.__init__c                 C   sh   t |tr|j}t|}|j D ]}t| |r,||v r,t| |}|r,||| 7 }||= q| | d S rE   )	r*   rp   __dict__dictlistsr_   hasattrry   Z_update_loose)r{   
other_dictr   r   r
   r   r   r   r   a  s   

zValues.updatec                 C   sH   t   t jdtd | j| jdW  d   S 1 sw   Y  dS )z Return a shallow copy of `self`.ignorecategory)defaultsN)rt   catch_warningsfilterwarningsrv   r}   r~   )r{   r   r   r   copym  s   
$zValues.copyc                 C   s&   t | |ddu rt| || t | |S )zUV.setdefault(n[,d]) -> getattr(V,n,d), also set D.n=d if n not in D or None.
        N)ry   r   )r{   namedefaultr   r   r   
setdefaults  s   
zValues.setdefault)	__name__
__module____qualname____doc__rx   r   r   r   __classcell__r   r   r|   r   rp   O  s    	rp   c                       s<   e Zd ZdZejjddg Z fddZ fddZ  Z	S )Optionz`Add validation and override support to `optparse.Option`.

    Deprecated. Will be removed.
    	validator	overridesc                    s&   t jdtdd t j|i | d S )NzDThe frontend.Option class will be removed in Docutils 0.21 or later.rc   rq   )rt   ru   rv   rw   rx   rz   r|   r   r   rx     s   zOption.__init__c           	   
      s   t  ||||}| j}|rH| jr>t||}z	| |||}W n ty7 } ztd|t	|f d}~ww t
||| | jrHt
|| jd |S )z
        Call the validator function on applicable settings and
        evaluate the 'overrides' option.
        Extends `optparse.Option.process`.
        zError in option "%s":
    %sN)rw   processdestr   ry   	ExceptionoptparseZOptionValueErrorr   error_stringr   r   )	r{   r	   r
   r   r   resultr   	new_valuer   r|   r   r   r     s&   
zOption.process)
r   r   r   r   r   r   ZATTRSrx   r   r   r   r   r|   r   r   {  s
    r   c                       s  e Zd ZdZg dZ	 d Z	 dddddd	Z	 d
d
d
d
dddddd	Z	 e	e
jddp1ejp1dZdZddg ddg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d+d,d-gdedfd.d/gd0d1ifd2d3gd4ed5d6fd7d8gd9d!d:d:d;fd<d=gd9d!d>d?fd@dAgd9ddBfdCdDgddedEfdFdGgdHddBfdIdJgddKdedLfdMdNgddKdfdOdPgdedfdQdRgddSdfdTdUgdVdWdXedYfdZd[gdVd\dXedYfd]d^d_gedd`daedbfdcdddegd!dd`d$fdfdgdhgd!dd`d$fdidjgedkddaedlfdmdngd!ddkd$fdodpgedqddaedlfdrdsgdedfdtdugddvdfdwdxgdydzd{fd|d}gddedEfd~dgdddBfdddgdedfddgdedfdddgddedfddgdedfdeef ddgdeedfde dgeedfdddgddddfddgdzeddfddgdzdd4e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dVdedfedgddifR fZ	 dddddZ	 dZdejejr<dej p=de
j  d e
j!f Z"	 dԇ fdd	Z#ddÄ Z$e%ddń Z&ddǄ Z'ddɄ Z(dd˄ Z)dd̈́ Z*ddτ Z+ddф Z,ddӄ Z-  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 5rN   rc   rd   rQ      )infowarningr   ZseverenoneTF)	1onyestrue0offnofalse r'   NrO   rP   zGeneral 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-dZstore_constz%Y-%m-%dZ	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-urlmetavarz<URL>z-Do not include a "View document source" link.z--no-source-linkcallback)Zsource_linkZ
source_url)r   r   Z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-backlinksZfootnote_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_commentszRemove all elements with classes="<class>" from the document tree. Warning: potentially dangerous; use with caution. (Multiple-use option.)z--strip-elements-with-classrR   Z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-classZstrip_classeszReport 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-statusZ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-handlerzUSpecify text encoding and optionally 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%z--dump-settingsz--dump-internalsz--dump-transformsz--dump-pseudo-xmlz--expose-internal-attributeZexpose_internals)r   r   r   z--strict-visitor)_disable_config_source_destination_config_filesgeneralz(%%prog (Docutils %s%s, Python %s, on %s)z [%s]r   r   c              
      s   i | _ 	 g | _	 dg| _tjdtdd t j|tdt	j
ddd| | js,| j| _| g|R | _| | j | j|p?i  |ro| jd	 sqz|  }W n tye } z| | W Y d}~nd}~ww | j|j dS dS dS )
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.rc   rq   NN   )width)Zoption_classZadd_help_option	formatterr   )r   config_filesrelative_path_settingsrt   ru   rv   rw   rx   r   r   ZTitledHelpFormatterr   version_template
componentspopulate_from_componentsr   r   get_standard_config_settingsr   r   r~   )r{   r   r   Zread_config_filesr   r   Zconfig_settingsr   r|   r   r   rx     s:   	
zOptionParser.__init__c                 C   s   |D ]a}|du r	q|j }| j|j tdt|dD ]G}|||d  \}}}|r7t| ||}| | n| }|D ]\}	}
}|j|
d|	i|}|	ddkrWd| j
|j< q;|jrb| j|j qq|D ]}|rt|jrt| j|j qfdS )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   rd   r   r   rR   T)rk   r   r9   ri   rT   r   ZOptionGroupZadd_option_group
add_optiongetr   r   settings_defaultsr   r   Zsettings_default_overrides)r{   r   	componentrk   r=   titledescriptionZoption_specgroupZ	help_textZoption_stringsr   r   r   r   r   r     s:   
z%OptionParser.populate_from_componentsc                 C   s2   dt jv rt jd t j}n| j}dd |D S )z:Return list of config files, from environment or standard.ZDOCUTILSCONFIGc                 S   s    g | ]}|  rtj|qS r   )r-   r]   rZ   
expanduser)r<   fr   r   r   r>     r?   z:OptionParser.get_standard_config_files.<locals>.<listcomp>)r]   environr%   pathsepstandard_config_files)rK   r   r   r   r   get_standard_config_files  s   
z&OptionParser.get_standard_config_filesc                 C   s`   t   t jdtd t }W d    n1 sw   Y  |  D ]}|| ||  q"|S )Nr   r   )rt   r   r   rv   rp   r   r   r   )r{   rm   filenamer   r   r   r     s   
z)OptionParser.get_standard_config_settingsc                 C   s   t  }t }t  tjdtd |  j||| 7  _t }W d   n1 s*w   Y  | j	D ]*}|s7q2t
|jp<d|jf D ]}||v rIqB|| ||r[||| |  qBq2t|j| jtj| |jS )zAReturns a dictionary containing appropriate config file settings.r   r   Nr   )ConfigParserr&   rt   r   r   rv   r   readrp   r   rj   Zconfig_section_dependenciesr    addhas_sectionr   r`   r~   r   r]   rZ   dirname)r{   config_filer   Zappliedrm   r   sectionr   r   r   r     s2   




z%OptionParser.get_config_file_settingsc                 C   s,   |  |\|_|_t|j| j | j|_|S )z/Store positional arguments as runtime settings.)
check_argsr   r   r`   r~   r   r   r   )r{   r   r   r   r   r   check_values  s   zOptionParser.check_valuesc                 C   sh   d  }}|r| d}|dkrd }|r| d}|dkrd }|r%| d |r0||kr0| d ||fS )Nr   re   zMaximum 2 arguments allowed.z_Do not specify the same file for both source and destination.  It will clobber the source file.)r8   r   )r{   r   sourceZdestinationr   r   r   r     s   



zOptionParser.check_argsc                 C   s   | j | d S rE   )r   r   r{   r   r   r   r   set_defaults_from_dict
  s   z#OptionParser.set_defaults_from_dictc                 C   sL   t   t jdtd t| j}W d   n1 sw   Y  | j|_|S )z(Needed to get custom `Values` instances.r   r   N)rt   r   r   rv   rp   r   r   r   r   r   r   r   get_default_values  s   
zOptionParser.get_default_valuesc                 C   s@   | j | g D ]}|jD ]}|j|kr|    S qqtd| )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.)Zoption_groupsZoption_listr   r/   )r{   r   r   r   r   r   r   get_option_by_dest  s   


zOptionParser.get_option_by_dest)r   NF)/r   r   r   r   r   r%   Zthreshold_choicesr4   r,   ry   sysstderrr   Z_locale_encodingZdefault_error_encodingZ$default_error_encoding_error_handlerr0   r   rM   r6   r)   r#   rH   r   r   r;   rk   r   r    rI   __version__Z__version_details__r   platformr   rx   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r|   r   r     s   




!$(+/258>D
I
L
OTW]`bdginrw|   	
                        "  '$ 
r   c                       sX   e Zd ZdZddddZ	 dZdZd fd	d
	Zdd Zdd Z	dd Z
dd Z  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 writerZ
stylesheet)r   Zstylesheet_path)r   template)Zpep_stylesheetZpep_stylesheet_pathZ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.
Nc              	      s   |d urt jdtdd g }t|tr|g}|D ]6}z|t j|dd7 }W n ty:   tj	
| j||f  Y qw d| v rD| | |d urN| || q|S )Nzbfrontend.ConfigParser.read(): parameter "option_parser" will be removed in Docutils 0.21 or later.rc   rq   r   )r'   options)rt   ru   rv   r*   strrw   r   UnicodeDecodeErrorr   r   writenot_utf8_errorhandle_old_configvalidate_settings)r{   	filenamesr   read_okr   r|   r   r   r   H  s(   

zConfigParser.readc                 C   s   t | jt|d | d}| ds| d | D ],\}}|| jv r7| j| \}}| |s6| | nd}|}| 	||sH| 
||| q| d d S )Nr   r   r   )rt   warn_explicitold_warningConfigDeprecationWarningget_sectionr   add_sectionr   old_settings
has_optionr&   remove_section)r{   r   r   r   r
   r   r   r   r   r   r   `  s$   






zConfigParser.handle_old_configc           	      C   s   |   D ]e}| |D ]]}z||}W n	 ty   Y qw |jr]| ||}z|j|||| |d}W n" tyU } ztd| d| dt	| d| d| 
d}~ww | 
||| |jrh| 
||jd qqdS )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)sectionsr   r   r/   r   r   r   r   r   r   r&   r   )	r{   r   r   r   r   r   r
   r   r   r   r   r   r   r  s@   

zConfigParser.validate_settingsc                 C   s   |  ddS )z
        Lowercase and transform '-' to '_'.

        So the cmdline form of option names can be used in config files.
        re   rf   )r.   rh   )r{   	optionstrr   r   r   optionxform  s   zConfigParser.optionxformc                 C   s6   t jdtdd zt| | W S  ty   i  Y S 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.rc   rq   )rt   ru   rv   r   r/   )r{   r   r   r   r   r     s   	zConfigParser.get_sectionrE   )r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r|   r   r   '  s    r   c                   @   s   e Zd ZdZdS )r   z3Warning for deprecated configuration file features.N)r   r   r   r   r   r   r   r   r     s    r   c                  G   sF   t   t jdtd t|  W  d   S 1 sw   Y  dS )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)rt   r   r   rv   r   r   )r   r   r   r   get_default_settings  s   

$r  )NNrE   )(r   Z__docformat__r   configparserr   r   r]   os.pathr   rt   rI   r   r   r   r   r!   r#   r)   r0   r1   r3   r6   r;   rA   rD   rH   rM   rX   r`   rY   ro   rp   r   r   ZSettingsSpecRawConfigParserr   FutureWarningr   r  r   r   r   r   <module>   sh   0





	








$,%   
