U
    ZShB                     @   sx  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d7ddZd8ddZd9ddZd:ddZd;ddZd<ddZd=ddZd>ddZd?ddZd@ddZdAd d!ZdBd"d#ZdCd$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 )Da  
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                 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   D/root/rtd-docs/venv/lib/python3.8/site-packages/docutils/frontend.pystore_multipleE   s    r   c              
   C   sN   z| |}W n, tk
r: } z|| W 5 d}~X Y nX |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   sD   |dkrd S zt | W n$ tk
r>   td| |f Y nX |S )N z$setting "%s": unknown encoding: "%s")codecslookupLookupErrorsettingr   option_parserconfig_parserconfig_sectionr   r   r   validate_encoding]   s    r#   c                 C   s4   zt | W n  tk
r.   td| Y nX |S )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_handleri   s    
r%   c                 C   sn   d|krV| d\}}t| d |||| |rB||| d | qZt|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_handlerv   s(        r+   c                 C   sH   t |tr|S z|j|   W S  tk
rB   td| Y nX dS )z|Check/normalize boolean settings:
         True:  '1', 'on', 'yes', 'true'
         False: '0', 'off', 'no','false', ''
    zunknown boolean value: "%s"N)
isinstanceboolbooleansstriplowerKeyErrorr   r   r   r   r   validate_boolean   s    
r2   c                 C   sH   t |ts|dkr|S z|j|   W S  tk
rB   | Y S X dS )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/   r0   r1   r   r   r   r   validate_ternary   s    r3   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    r5   c                 C   s^   z
t |W S  tk
rX   z|j|  W  Y S  ttfk
rR   td| Y nX Y nX d S )Nzunknown threshold: %r.)r4   r   
thresholdsr0   r1   AttributeErrorr   r   r   r   r   validate_threshold   s    
r8   c                 C   s2   t |ts|d}n| }||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>   s     
 z1validate_comma_separated_list.<locals>.<listcomp>,)r,   r9   r:   r'   r;   )r   r   r    r!   r"   r<   r   r   r   r   validate_comma_separated_list   s    

rB   c                 C   s"   |sdS | dr|S |d S d S )Nz.//)endswithr   r   r   r   validate_url_trailing_slash   s
    
rE   c                 C   s0   zt |W S  tk
r*   t d  Y S X d S N)r   DependencyListOSErrorr   r   r   r   validate_dependency_file   s    rI   c                 C   sB   t | ||||}|D ](}tj|}||krtd||f q|S )Nz$Invalid class value %r (perhaps %r?))rB   docutilsZnodesZmake_idr   )r   r   r    r!   r"   cls
normalizedr   r   r   validate_strip_class   s     rM   c           
   
   C   s   t | ||||}g }|D ]}z|dd\}}W nH tk
rR   || Y qY n( tk
rx   td|dd Y nX | }|d}	t|	dkr|	}n t|dkrt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).)rB   r'   r7   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krt   |D ]H}|| kr| | }t|trF fdd|D }n|rTt |}|| |< 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,   r9   rY   )Zpathdictkeysr\   r   r   r   r[   r   make_paths_absolute  s    


r`   c                 C   s   t jt j| |S rF   )r]   rZ   abspathjoin)r\   rZ   r   r   r   rY   0  s    rY   c                 O   s   t | }tdt|dD ]h}g }|| D ]J}dd |d D d }||krLq(|| krh|||  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@   D  s   
z(filter_settings_spec.<locals>.<listcomp>rN   r   )r9   rangerT   r_   rR   tuple)settings_specexcluderh   settingsr?   ZnewoptsZopt_specopt_namer   r   r   filter_settings_spec4  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                    s<   t jdtdd t j|| t| dd d kr8t | _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   rG   rs   selfr   r   	__class__r   r   rx   Z  s     zValues.__init__c                 C   sh   t |tr|j}t|}|j D ]6}t| |r"||kr"t| |}|r"||| 7 }||= q"| | d S rF   )	r,   rp   __dict__dictlistsr_   hasattrry   _update_loose)r{   
other_dictr    r   r   r   r   r   r   c  s    

zValues.updatec              
   C   s<   t  * t jdtd | j| jdW  5 Q R  S Q R X dS )z Return a shallow copy of `self`.ignorecategory)defaultsN)rt   catch_warningsfilterwarningsrv   r}   r~   )r{   r   r   r   copyo  s    
zValues.copyc                 C   s&   t | |ddkrt| || t | |S )znReturn ``self.name`` or ``default``.

        If ``self.name`` is unset, set ``self.name = default``.
        N)ry   r   )r{   namedefaultr   r   r   
setdefaultu  s    zValues.setdefault)	__name__
__module____qualname____doc__rx   r   r   r   __classcell__r   r   r|   r   rp   Q  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|| 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}|r| jrt||}z| |||}W n: tk
rx } ztd|t	|f W 5 d}~X Y nX t
||| | jrt
|| 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optparse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   ATTRSrx   r   r   r   r   r|   r   r     s   r   c                9       s  e Zd ZdZdddg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p\ejp\dZdZdd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d0d1gd(dd*d+fd2d3d4gdedfd5d6gdd7ifd8d9gd:ed;d<fd=d>gd?d(d@d@dAfdBdCgd?d(dDdEfdFdGgd?d"dHfdIdJgddedKfdLdMgdNd"dHfdOdPgddQdedRfdSdTgd"dQd$fdUdVgdedfdWdXgd"dYd$fdZd[gd\d]d^ed_fd`dagd\dbd^ed_fdcdddegeddfdgedhfdidjdkgd(ddfd+fdldmdngd(d
dfd+fdodpgedqd	dgedrfdsdtgd(ddqd+fdudvgedwd
dgedrfdxdygdedfdzd{gd"d|d$fd}d~gdddfddgddedKfddgdd"dH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deddfddgddd:e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d\dedfedgddiff3f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falser   r)   NrO   rP   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-%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-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-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sT| j| _| f|| _| | j | j|pxi  |r| jd	 sz|  }W n, tk
r } z| | W 5 d}~X Y nX | j|j 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)option_classadd_help_option	formatterr   )r   config_filesrelative_path_settingsrt   ru   rv   rw   rx   r   r   TitledHelpFormatterr   version_template
componentspopulate_from_componentsr   r   get_standard_config_settingsr   r   r~   )r{   r   r   Zread_config_filesr   r   config_settingsr   r|   r   r   rx     s2    	 
zOptionParser.__init__c                 C   s   |D ]}|dkrq|j }| j|j tdt|dD ]}|||d  \}}}|rnt| ||}| | n| }|D ]8\}	}
}|j|
d|	i|}|	ddkrvd| j
|j< qv|jr6| j|j q6q|D ]}|r|jr| j|j qd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   r;   ri   rT   r   OptionGroupadd_option_group
add_optiongetr   r   settings_defaultsr   r   Zsettings_default_overrides)r{   r   	componentrk   r?   titledescriptionZoption_specgroup	help_textoption_stringsr   r	   r   r   r   r     s0    
z%OptionParser.populate_from_componentsc                 C   s2   dt jk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@     s      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   sL   t   t jdtd t }W 5 Q R X |  D ]}|| ||  q0|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 0 tjdtd |  j||| 7  _t }W 5 Q R X | j	D ]T}|sZqPt
|jpdd|jf D ]2}||kr~qp|| ||rp||| |  qpqPt|j| jtj| |jS )zAReturns a dictionary containing appropriate config file settings.r   r   r   )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     s,    




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 }|rJ| d |r`||kr`| 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.)r:   r   )r{   r   sourceZdestinationr   r   r   r      s    



zOptionParser.check_argsc                 C   s   | j | d S rF   )r   r   r{   r   r   r   r   set_defaults_from_dict  s    z#OptionParser.set_defaults_from_dictc              	   C   s8   t   t jdtd t| j}W 5 Q R X | j|_|S )z(Needed to get custom `Values` instances.r   r   )rt   r   r   rv   rp   r   r   r   r   r   r   r   get_default_values  s
    
zOptionParser.get_default_valuesc                 C   sD   | j | g D ]&}|jD ]}|j|kr|    S qqtd| dS )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.N)option_groupsoption_listr   r1   )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_choicesr6   r.   ry   sysstderrr   Z_locale_encodingZdefault_error_encodingZ$default_error_encoding_error_handlerr2   r   rM   r8   r+   r%   rI   r   r   r=   rk   r   r"   rJ   __version__Z__version_details__r   platformr   rx   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r|   r   r     s`  	
            
                        .	 $ 
r   c                       sV   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 writer
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 k	rt jdtdd g }t|tr,|g}|D ]r}z|t j|dd7 }W n. tk
rz   tj	
| j||f  Y q0Y nX d| kr| | |d k	r0| || q0|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   O  s&     


zConfigParser.readc                 C   s   t | jt|d | d}| ds0| d | D ]X\}}|| jkrn| j| \}}| |sv| | nd}|}| 	||s8| 
||| q8| 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  g  s"    
 




zConfigParser.handle_old_configc           	      C   s   |   D ]}| |D ]}z||}W n tk
r@   Y qY nX |jr| ||}z|j|||| |d}W nN tk
r } z0td| d| dt	| d| d| 
W 5 d}~X Y nX | 
||| |jr| 
||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   r1   r   r   r   r   r   r   r(   r   )	r{   r   r    r   r   r	   r   r   r   r   r   r   r  y  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   )r0   rh   )r{   	optionstrr   r   r   optionxform  s    zConfigParser.optionxformc                 C   s<   t jdtdd zt| | W S  tk
r6   i  Y S X dS )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   N)rt   ru   rv   r   r1   )r{   r   r   r   r   r    s    	 zConfigParser.get_section)N)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   s:   t  ( t jdtd t|  W  5 Q R  S Q R X 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  )NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)NN)N)(r   __docformat__r   configparserr   r   r]   os.pathr   rt   rJ   r   r   r   r   r#   r%   r+   r2   r3   r5   r8   r=   rB   rE   rI   rM   rX   r`   rY   ro   rp   r   r   ZSettingsSpecRawConfigParserr   FutureWarningr  r  r   r   r   r   <module>   s   0   
   
   
   
   
   
	   
   
   
   
   

   
   
$
.%   