o
    i                     @  s  d Z ddlmZ dZddlZddl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 ddlmZ ddlZddlmZmZ dZerpdd	lmZmZmZ dd
lmZmZmZmZ ddlmZmZmZ ddlmZ G dd deZ dmddZ!dnddZ"				dodpd&d'Z#				dodqd(d)Z$				dodqd*d+Z%				dodrd.d/Z&				dodsd1d2Z'				dodtd5d6Z(				dodtd7d8Z)				dodud;d<Z*				dodud=d>Z+				dodvd@dAZ,				dodwdBdCZ-				dodxdEdFZ.				dodydGdHZ/				dodzdKdLZ0	d{d|dSdTZ1d}dWdXZ2d~d^d_Z3G d`da daej4Z4G dbdc dcej5Z5G ddd dej6ejZ6G dedf dfej7Z8G dgdh dhe9Z:ddkdlZ;dS )a*  
Command-line and common processing for Docutils front-end tools.

This module is provisional.
Major changes will happen with the transition from the
"optparse" module to "arparse" in Docutils 2.0 or later.

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. To be removed.

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.
    )annotationsreStructuredTextN)SUPPRESS_HELP)Path)ioutilsF)IterableMappingSequence)AnyClassVarLiteralProtocol)SettingsSpec_OptionTuple_SettingsSpecTuple)StrPathc                   @  s   e Zd Z		ddddZdS )_OptionValidatorNconfig_parserConfigParser | Noneconfig_section
str | Nonesettingstrvalueoption_parserOptionParserreturnr   c                C  s   d S N )selfr   r   r   r   r   r   r   W/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/docutils/frontend.py__call__P   s   	z_OptionValidator.__call__)NN)r   r   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__r"   r   r   r   r!   r   O   s    r   optionoptparse.Optionoptr   r   r   parserr   argskwargsr   Nonec                 O  s<   |D ]	}t |j|d q| D ]\}}t |j|| qdS )a  
    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`.

    Deprecated. Will be removed with the switch to from optparse to argparse.
    N)setattrvaluesitems)r&   r(   r   r)   r*   r+   	attributekeyr   r   r!   store_multiple\   s
   r2   c              
   C  sP   z| |}W n ty } z|| W Y d}~nd}~ww |j|| dS )z
    Read a configuration file during option processing.  (Option callback.)

    Deprecated. Will be removed with the switch to from optparse to argparse.
    N)get_config_file_settings
ValueErrorerrorr.   update)r&   r(   r   r)   new_settingserrr   r   r!   read_config_fileq   s   
r9   r   r   r   OptionParser | Noner   r   r   c                 C  sp   |d u r| }|dkrt jdtdd d S zt| W |S  ty7   | r+d|  dnd}t| d| dw )	N ztInput encoding detection will be removed and the special encoding values None and "" become invalid in Docutils 1.0.   
stacklevelz	setting "z":z unknown encoding: "")warningswarnFutureWarningcodecslookupLookupError)r   r   r   r   r   prefixr   r   r!   validate_encoding   s   	rG   c                 C  s8   |d u r| }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))rC   lookup_errorrE   r   r   r   r   r   r   r   r!   validate_encoding_error_handler   s   
rJ   c                 C  sb   d|v r+| d\}}t| |r||| d | t|S t|j| d | t|S |}t|S )al  Check/normalize encoding settings

    Side-effect: if an error handler is included in the value, it is inserted
    into the appropriate place as if it were a separate setting/option.

    All arguments except `value` are ignored
    (kept for compatibility with "optparse" module).
    If there is only one positional argument, it is interpreted as `value`.
    :_error_handler)splitrJ   setr-   r.   rG   )r   r   r   r   r   encodinghandlerr   r   r!   #validate_encoding_and_error_handler   s   rQ   
str | boolboolc                 C  sJ   |du r| }t |tr|S z
tj|   W S  ty$   td| w )a$  Check/normalize boolean settings:

    :True:  '1', 'on', 'yes', 'true'
    :False: '0', 'off', 'no','false', ''

    All arguments except `value` are ignored
    (kept for compatibility with "optparse" module).
    If there is only one positional argument, it is interpreted as `value`.
    Nzunknown boolean value: "%s")
isinstancerS   r   booleansstriplowerKeyErrorrE   rI   r   r   r!   validate_boolean   s   
rY   str | bool | Nonec                 C  sN   |du r| }t |ts|du r|S z
tj|   W S  ty&   | Y S w )aN  Check/normalize three-value settings:

    :True:  '1', 'on', 'yes', 'true'
    :False: '0', 'off', 'no','false', ''
    :any other value: returned as-is.

    All arguments except `value` are ignored
    (kept for compatibility with "optparse" module).
    If there is only one positional argument, it is interpreted as `value`.
    N)rT   rS   r   rU   rV   rW   rX   rI   r   r   r!   validate_ternary   s   r[   	str | intintc                 C  s(   |d u r| }t |}|dk rtd|S )Nr   z(negative value; must be positive or zero)r]   r4   rI   r   r   r!   validate_nonnegative_int  s   	r^   c                 C  sZ   |d u r| }zt |W S  ty,   z
tj|  W  Y S  ttfy+   td| w w )Nzunknown threshold: %r.)r]   r4   r   
thresholdsrW   rX   AttributeErrorrE   rI   r   r   r!   validate_threshold  s   	
ra   str | list[str]	list[str]c                 C  s@   |d u r| }t |ts|d}|S | }||d |S )NrK   )rT   listrM   popextend)r   r   r   r   r   lastr   r   r!   $validate_colon_separated_string_list&  s   


rh   c                 C  sF   |du r| }t |ts|g}| }dd |dD }|| |S )zCheck/normalize list arguments (split at "," and strip whitespace).

    All arguments except `value` are ignored
    (kept for compatibility with "optparse" module).
    If there is only one positional argument, it is interpreted as `value`.
    Nc                 S  s    g | ]}| d r| d qS )z 	
)rV   ).0ir   r   r!   
<listcomp>P       z1validate_comma_separated_list.<locals>.<listcomp>,)rT   rd   re   rM   rf   )r   r   r   r   r   rg   r/   r   r   r!   validate_comma_separated_list:  s   

rn   tuple[()] | tuple[str, str]c                 C  s   |du r| }d}d}|sdS |j dd}|d  }z|d }	W n ty+   d}	Y nw ||vr;td	| d
| d|dkrT|	 }
|
|vrRtd|	 d| d|
}	||	fS )aQ  Check "math-output" setting, return list with "format" and "options".

    See also https://docutils.sourceforge.io/docs/user/config.html#math-output

    Argument list for compatibility with "optparse" module.
    All arguments except `value` are ignored.
    If there is only one positional argument, it is interpreted as `value`.
    N)htmllatexmathmlmathjax)r;   latexmlttm	blahtexmlpandocr      )maxsplitr   r;   zUnknown math output format: "z",
    choose from .rr   zMathML converter "z!" not supported,
    choose from )rM   rW   
IndexErrorrE   )r   r   r   r   r   formatstex2mathml_convertersr.   formatoptions	converterr   r   r!   validate_math_outputU  s2   



r   c                 C  s*   |d u r| }|s
dS | dr|S |d S )Nz.//)endswithrI   r   r   r!   validate_url_trailing_slash}  s   	
r   utils.DependencyListc                 C  s6   |d u r| }zt |W S  ty   t d  Y S w r   )r   DependencyListOSErrorrI   r   r   r!   validate_dependency_file  s   	r   c                 C  sF   |d u r| }t |}|D ]}tj|}||kr td||f q|S )Nz$Invalid class value %r (perhaps %r?))rn   docutilsnodesmake_idr4   )r   r   r   r   r   cls
normalizedr   r   r!   validate_strip_class  s   	r   !str | list[str | tuple[str, str]]list[tuple[str, Sequence[str]]]c           
   
   C  s   |du r| }t |}g }|D ]T}z
|dd\}}W n ty(   || Y q ty8   td|dd w | }|d}	t|	dkrK|	}nt|dkr[td|dd |||f q|S )	a2  Check/normalize a comma separated list of smart quote definitions.

    Return a list of (language-tag, quotes) string tuples.

    All arguments except `value` are ignored
    (kept for compatibility with "optparse" module).
    If there is only one positional argument, it is interpreted as `value`.
    NrK   rx   z4Invalid value "%s". Format is "<language>:<quotes>".asciibackslashreplace   z[Invalid value "%s". Please specify 4 quotes
    (primary open/close; secondary open/close).)rn   rM   r`   appendr4   encoderV   len)
r   r   r   r   r   	lc_quotesitemlangquotesmultichar_quotesr   r   r!   validate_smartquotes_locales  s2   



r   pathdict"dict[str, list[StrPath] | StrPath]keys
tuple[str]	base_pathStrPath | Nonec                   s    du r	t   nt   tjdkrtjdd dkr   |D ])}|| v rJ| | }t|ttfr< fdd|D }n
|rFt	 | 
 }|| |< 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`.
    Nwin32r<   )   	   c                   s   g | ]
}t  |  qS r   )r   resolve)ri   pathr   r   r!   rk     s    z'make_paths_absolute.<locals>.<listcomp>)r   cwdsysplatformversion_infoabsoluterT   rd   tupler   r   )r   r   r   r1   r   r   r   r!   make_paths_absolute  s   

r   r   r   c                 C  s&   t jdtdd tjtj| |S )NzKfrontend.make_one_path_absolute() will be removed in Docutils 2.0 or later.r<   r=   )r@   rA   DeprecationWarningosr   abspathjoin)r   r   r   r   r!   make_one_path_absolute   s   r   settings_specr   excludereplacer   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.)
    r<   r   c                 S  s*   g | ]}| d r|dd ddqS )z--r<   N-_)
startswithr   )ri   
opt_stringr   r   r!   rk     s    z(filter_settings_spec.<locals>.<listcomp>rx   r   )rd   ranger   r   r   r   )r   r   r   settingsrj   newoptsopt_specopt_namer   r   r!   filter_settings_spec  s    r   c                      sB   e Zd ZdZdd fddZdddZdddZd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 when switching to the "argparse" module.
    Ndefaultsdict[str, Any] | Noner   r,   c                   s@   t jdtdd t j|d t| dd d u rt | _d S d S )Nz?frontend.Values class will be removed in Docutils 2.0 or later.r<   r=   r   record_dependencies)	r@   rA   r   super__init__getattrr   r   r   r    r   	__class__r   r!   r   1  s   zValues.__init__
other_dictValues | Mapping[str, Any]r   r   c                 C  sh   t |tr|j}t|}|j D ]}t| |r,||v r,t| |}|r,||| 7 }||= q| | d S r   )	rT   r   __dict__dictlistsr   hasattrr   _update_loose)r    r   r   r   r   r   r   r!   r6   :  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categoryr   N)r@   catch_warningsfilterwarningsr   r   r   )r    r   r   r!   copyI  s   
$zValues.copynamer   defaultr   c                 C  s&   t | |ddu rt| || t | |S )znReturn ``self.name`` or ``default``.

        If ``self.name`` is unset, set ``self.name = default``.
        N)r   r-   )r    r   r   r   r   r!   
setdefaultO  s   
zValues.setdefaultr   )r   r   r   r,   )r   r   r   r   r   r,   r   r   )r   r   r   r   r   r   )	r#   r$   r%   __doc__r   r6   r   r   __classcell__r   r   r   r!   r   (  s    
	
r   c                      sR   e Zd ZU dZejjddg Zded< ded< d fddZd fddZ	  Z
S )Optionz`Add validation and override support to `optparse.Option`.

    Deprecated. Will be removed.
    	validator	overridesr   r   r*   r+   r   r   r,   c                   s&   t jdtdd t j|i | d S )NzCThe frontend.Option class will be removed in Docutils 2.0 or later.r<   r=   )r@   rA   r   r   r   )r    r*   r+   r   r   r!   r   d  s   zOption.__init__r(   r   r   r.   r   r)   r   r]   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)r   processdestr   r   	ExceptionoptparseOptionValueErrorr   error_stringr-   r   )	r    r(   r   r.   r)   resultr   	new_valuer8   r   r   r!   r   j  s&   
zOption.process)r*   r   r+   r   r   r,   )
r(   r   r   r   r.   r   r)   r   r   r]   )r#   r$   r%   r   r   r   ATTRS__annotations__r   r   r   r   r   r   r!   r   Y  s   
 r   c                      sp  e Zd ZU dZg dZded< 	 dZded< 	 dd	d
dddZded< 	 dddddddddd	Zded< 	 e	e
jddp@ejp@dZded< dZded< ddg 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/d0d1gd2d3d4d5fd6d7d8gd2d9d4d5fd:d;gd2dd4d5fd<d=gd>d?d@fdAdBdCgd(ed)fdDdEgd dFifdGdHgdIedJdKfdLdMgdNd2dOdOdPfdQdRgdNd2dSdTfdUdVgdNd,dWfdXdYgd(dedZfd[d\gd]d,dWfd^d_gd(d`dedafdbdcgd,d`d.fdddegd(ed)fdfdggd,dhd.fdidjgdkdldmednfdodpgdkdqdmednfdrdsdtged	dudvedwfdxdydzgd2ddud5fd{d|d}gd2ddud5fd~dgedddvedfddgd2ddd5fddgedddvedfddgd(ed)fddgd,dd.fddgdddfddgd(dedZfddgdd,dWfddgddedfedgdedfddgddedfedgdedfde dddgdeedfedgeedfdddgddddfddgdeddfddgdddIedfdddgddifdddgddifedgdd>i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dkdedǜfedgdd(ifR fZ	 dddddɜZ	 dZded< dZdejej  Z!rmde! dНpnd>e
j"# d e
j$f Z%ded< 	 			dd fdd܄Z&dddބZ'e(dddZ)dddZ*dddZ+dddZ,dddZ-dddZ.d ddZ/  Z0S (  r   a  
    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ClassVar[list[str]]standard_config_files)
info1warning2r5   3severe4none5zClassVar[tuple[str]]threshold_choicesrx   r<   r   r      )r   r   r5   r   r   zClassVar[dict[str, int]]r_   TF)	r   onyestrue0offnofalser;   zClassVar[dict[str, bool]]rU   rO   Nr   ClassVar[str]default_error_encodingr   $default_error_encoding_error_handlerzGeneral Docutils OptionszaOutput destination name. Obsoletes the <destination> positional argument. Default: None (stdout).z--output-pathz--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-datestampzUBase directory for absolute paths when reading from the local filesystem. Default "".z--root-prefixr;   z<path>)r   r  z&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-classr   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	tracebackzUSpecify the encoding and optionally the error handler of input text.  Default: utf-8.z--input-encodingz<name[:handler]>utf-8)r  r   r   z--input-encoding-error-handlerstrict)r   r   zWSpecify the text encoding and optionally the error handler for output.  Default: utf-8.z--output-encodingz--output-encoding-error-handlerzSSpecify text encoding and optionally the error handler for error output.  Default: rz   z--error-encodingz-ez--error-encoding-error-handlerz<Specify the language (as BCP 47 language tag).  Default: en.z
--languagez-llanguage_codeenz<tag>)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   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_filesr   ztuple[str, ...]relative_path_settingsgeneralz(%%prog (Docutils %s%s, Python %s, on %s)z []r   version_template
componentsIterable[SettingsSpec]r   Mapping[str, Any] | Noneread_config_filesbool | Noner   r,   c              
     s   i | _ 	 g | _	 d| _tjdtdd t j|tdt	j
ddd| | js+| j| _| g|R | _| | j | j|p>i  |rp| jd	 srz|  }W n tyf } z| t| 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  zThe frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 2.0 or later.
  To get default settings, use frontend.get_default_settings().r<   r=   FN   )width)option_classadd_help_option	formatterr(  N)r   config_filesr,  r@   rA   r   r   r   r   r   TitledHelpFormatterr$  r/  r0  populate_from_componentsr   r6   get_standard_config_settingsr4   r5   r   r   )r    r0  r   r3  r*   r+   config_settingsr8   r   r   r!   r   o  s<   
zOptionParser.__init__c                 C  s   |D ]b}|du r	q|j }|  j|j7  _tdt|dD ]G}|||d  \}}}|r8t| ||}| | n| }|D ]\}	}
}|j|
d|	i|}|ddkrXd| j	|j
< q<|jrc| j|j qq|D ]}|ru|jru| j|j qgd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   r   r%  r  r   T)r   r,  r   r   r   OptionGroupadd_option_group
add_optiongetr   r   settings_defaultsr   r6   settings_default_overrides)r    r0  	componentr   rj   titledescriptionoption_specgroup	help_textoption_stringsr+   r&   r   r   r!   r<    s6   	
z%OptionParser.populate_from_componentsSequence[StrPath]c                 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.DOCUTILSCONFIGc                 S  s    g | ]}|  rtj|qS r   )rV   r   r   
expanduser)ri   fr   r   r!   rk     rl   z:OptionParser.get_standard_config_files.<locals>.<listcomp>)r   environrM   pathsepr   )r   r:  r   r   r!   get_standard_config_files  s   
z&OptionParser.get_standard_config_filesr   c                 C  s`   t   t jdtd t }W d    n1 sw   Y  |  D ]}|| ||  q"|S )Nr   r   )r@   r   r   r   r   rR  r6   r3   )r    r   filenamer   r   r!   r=    s   
z)OptionParser.get_standard_config_settingsconfig_filer   dict[str, Any]c                 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   )ConfigParserrN   r@   r   r   r   r:  readr   r0  r   config_section_dependenciesr   addhas_sectionr6   r   r   r,  r   r   dirname)r    rT  r   appliedr   rE  sectionr   r   r!   r3     s2   




z%OptionParser.get_config_file_settingsr.   r*   rc   c                 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_valuestuple[str | None, str | None]c                 C  sh   d  }}|r| d}|dkrd }|r| d}|dkrd }|r%| d |r0||kr0| 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.)re   r5   )r    r*   sourcedestinationr   r   r!   r^    s   



zOptionParser.check_argsc                 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)r@   r   r   r   r   r   r:  r+  r   r   r   r!   get_default_values  s   
zOptionParser.get_default_valuesr   r   c                 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.)option_groupsoption_listr   rX   )r    r   rI  r&   r   r   r!   get_option_by_dest  s   


zOptionParser.get_option_by_dest)r   NF)r0  r1  r   r2  r3  r4  r   r,   )r0  r1  r   r,   )r   rL  r   )rT  r   r   rU  )r.   r   r*   rc   r   r   )r*   rc   r   r`  )r   r   r   r   )1r#   r$   r%   r   r   r   r   r_   rU   r   r   stderrr   _locale_encodingr  r  rY   r2   r   ra   rQ   r   rJ   r   r9   rh   r   rC  r,  r   r   __version____version_details__detailsr$  rM   r   r/  r   r<  classmethodrR  r=  r3   r_  r^  rc  rf  r   r   r   r   r!   r     s  
 






!%
(+/269<?EK
P
S
V[^dgiknpuw|~   
  
                         %
* 




c                      st   e Zd ZU dZddddZded< 	 dZd	ed
< dZd	ed< 	d!d" fddZd#ddZ	d$ddZ
d%dd Z  ZS )&rV  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)rm  stylesheet_path)rm  template)pep_stylesheetpep_stylesheet_pathpep_templatez$ClassVar[dict[str, tuple[str, str]]]old_settingsu  The "[option]" section is deprecated.
Support for old-format configuration files will be removed in Docutils 2.0.  Please revise your configuration files.  See <https://docutils.sourceforge.io/docs/user/config.html>, section "Old-Format Configuration Files".r   old_warningzhUnable to read configuration file "%s": content not encoded as UTF-8.
Skipping "%s" configuration file.
not_utf8_errorN	filenamesstr | Sequence[str]r   r:   r   rc   c              	     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 )Nzafrontend.ConfigParser.read(): parameter "option_parser" will be removed in Docutils 2.0 or later.r<   r=   r  )rO   r   )r@   rA   r   rT   r   r   rW  UnicodeDecodeErrorr   rg  writerv  handle_old_configvalidate_settings)r    rw  r   read_okrS  r   r   r!   rW  5  s(   

zConfigParser.readrS  r   r,   c                 C  s   t | jt|d zt| d }W n ty   i }Y nw | ds'| d | D ],\}}|| j	v rF| j	| \}}| |sE| | nd}|}| 
||sW| ||| q+| d d S )Nr   r   r-  )r@   warn_explicitru  ConfigDeprecationWarningr   rX   rZ  add_sectionr/   rt  
has_optionrN   remove_section)r    rS  r   r1   r   r]  r   r   r   r!   r{  P  s,   





zConfigParser.handle_old_configr   c           	      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   rf  rX   r   rB  r   r4   r   r   rN   r   )	r    rS  r   r]  r   r&   r   r   r8   r   r   r!   r|  e  s@   

zConfigParser.validate_settings	optionstrc                 C  s   |  ddS )z
        Lowercase and transform '-' to '_'.

        So the cmdline form of option names can be used in config files.
        r   r   )rW   r   )r    r  r   r   r!   optionxform  s   zConfigParser.optionxformr   )rw  rx  r   r:   r   rc   )rS  r   r   r,   )rS  r   r   r   r   r,   )r  r   r   r   )r#   r$   r%   r   rt  r   ru  rv  rW  r{  r|  r  r   r   r   r   r!   rV    s   
 


rV  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  r0  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)r@   r   r   r   r   rc  )r0  r   r   r!   get_default_settings  s   

$r  )r&   r'   r(   r   r   r   r)   r   r*   r   r+   r   r   r,   )
r&   r'   r(   r   r   r   r)   r   r   r,   )NNNN)r   r   r   r   r   r:   r   r   r   r   r   r   )r   r   r   r   r   r:   r   r   r   r   r   r   )r   rR   r   r   r   r:   r   r   r   r   r   rS   )r   rR   r   r   r   r:   r   r   r   r   r   rZ   )r   r\   r   r   r   r:   r   r   r   r   r   r]   )r   rb   r   r   r   r:   r   r   r   r   r   rc   )r   r   r   r   r   r:   r   r   r   r   r   ro   )r   r   r   r   r   r:   r   r   r   r   r   r   )r   r   r   r   r   r:   r   r   r   r   r   r   )r   r   r   r   r   r:   r   r   r   r   r   rc   )r   r   r   r   r   r:   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r,   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r0  r   r   r   )<r   
__future__r   __docformat__rC   configparserr   r   os.pathr   r@   r   pathlibr   r   r   r   TYPE_CHECKINGcollections.abcr   r	   r
   typingr   r   r   r   r   r   r   docutils.ior   r   r2   r9   rG   rJ   rQ   rY   r[   r^   ra   rh   rn   r   r   r   r   r   r   r   r   r   r   r   RawConfigParserrV  rB   r  r  r   r   r   r!   <module>   s   0

)0

 1-   u