o
    Nil                     @   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m	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		d9ddZ		d9ddZ	d:ddZ		d9ddZ		d9ddZ		d9ddZ		d9ddZ		d9ddZ		d9ddZ		d9ddZ		d9dd Z		d9d!d"Z		d9d#d$Z		d9d%d&Zd;d'd(Zd)d* Z d+d, Z!G d-d. d.ej"Z"G d/d0 d0ej#Z#G d1d2 d2ej$ej%Z$G d3d4 d4ej&Z'G d5d6 d6e(Z)d7d8 Z*dS )<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)Path)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   E/home/ubuntu/.local/lib/python3.10/site-packages/docutils/frontend.pystore_multipleF   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   new_settingserrr   r   r   read_config_fileS   s   r   c                 C   sH   |d u r| }|dkrd S zt | W |S  ty#   td| |f w )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   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))r   lookup_errorr   r    r   r   r   validate_encoding_error_handlero   s   r'   c                 C   sb   d|v r+| d\}}t| |r||| d | t|S t|j| d | t|S |}t|S )z
    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.
    :_error_handler)splitr'   setr   r   r%   )r!   r   r"   r#   r$   encodinghandlerr   r   r   #validate_encoding_and_error_handler   s   r.   c                 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")
isinstanceboolOptionParserbooleansstriplowerKeyErrorr   r    r   r   r   validate_boolean   s   

r6   c                 C   sN   |du r| }t |ts|du r|S z
tj|   W S  ty&   | Y S w )aY  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)r/   r0   r1   r2   r3   r4   r5   r    r   r   r   validate_ternary   s   r7   c                 C   s(   |d u r| }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   r9   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.)r8   r   r1   
thresholdsr4   r5   AttributeErrorr   r    r   r   r   validate_threshold   s   
r<   c                 C   s@   |d u r| }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   

rA   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 	
)r3   ).0ir   r   r   
<listcomp>        z1validate_comma_separated_list.<locals>.<listcomp>,)r/   r=   r>   r*   r?   )r!   r   r"   r#   r$   r@   r	   r   r   r   validate_comma_separated_list   s   

rG   c                 C   s   |du r| }d}d}|sg 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
|
}	||	g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pandoc   )maxsplitr   r   zUnknown math output format: "z",
    choose from .rJ   zMathML converter "z!" not supported,
    choose from )r*   r4   
IndexErrorr   )r!   r   r"   r#   r$   formatstex2mathml_convertersr   formatoptions	converterr   r   r   validate_math_output   s2   




rY   c                 C   s*   |d u r| }|s
dS | dr|S |d S )Nz.//)endswithr    r   r   r   validate_url_trailing_slash$  s   
r\   c                 C   s6   |d u r| }zt |W S  ty   t d  Y S w N)r   DependencyListOSErrorr    r   r   r   validate_dependency_file3  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?))rG   docutilsnodesmake_idr   )r!   r   r"   r#   r$   cls
normalizedr   r   r   validate_strip_classA  s   rf   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`.
    Nr(   rP   z4Invalid value "%s". Format is "<language>:<quotes>".asciibackslashreplace   z[Invalid value "%s". Please specify 4 quotes
    (primary open/close; secondary open/close).)rG   r*   r;   appendr   encoder3   len)
r!   r   r"   r#   r$   	lc_quotesitemlangquotesmultichar_quotesr   r   r   validate_smartquotes_localesS  s2   




rr   c                    sr    du r	t   nt   |D ]'}|| v r6| | }t|tr( fdd|D }n
|r2t |  }|| |< 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   )strresolve)rB   path	base_pathr   r   rD     s    z'make_paths_absolute.<locals>.<listcomp>)r   cwdr/   r=   rs   rt   )pathdictkeysrw   r   r   r   rv   r   make_paths_absolute|  s   

r{   c                 C   s&   t jdtdd tjtj| |S )NzCfrontend.make_one_path_absolute() will be removed in Docutils 0.23.   
stacklevel)warningswarnDeprecationWarningosru   abspathjoin)rw   ru   r   r   r   make_one_path_absolute  s   r   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|      c                 S   s*   g | ]}| d r|dd ddqS )z--r|   N-_)
startswithreplace)rB   
opt_stringr   r   r   rD     s    z(filter_settings_spec.<locals>.<listcomp>rP   r   )r=   rangerl   rz   rj   tuple)settings_specexcluder   settingsrC   newoptsopt_specopt_namer   r   r   filter_settings_spec  s    
r   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.r|   r}   record_dependencies)	r   r   r   super__init__getattrr   r^   r   selfr   r   	__class__r   r   r     s   zValues.__init__c                 C   sh   t |tr|j}t|}|j D ]}t| |r,||v r,t| |}|r,||| 7 }||= q| | d S r]   )	r/   r   __dict__dictlistsrz   hasattrr   _update_loose)r   
other_dictr"   r!   r   r   r   r   r     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)r   catch_warningsfilterwarningsr   r   r   )r   r   r   r   copy  s   
$zValues.copyc                 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   namedefaultr   r   r   
setdefault  s   
zValues.setdefault)	__name__
__module____qualname____doc__r   r   r   r   __classcell__r   r   r   r   r     s    	r   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.r|   r}   )r   r   r   r   r   r   r   r   r   r     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)r   processdestr   r   	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   ATTRSr   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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d0d1gd2d3d4fd5d6d7gdedfd8d9gdd:ifd;d<gd=ed>d?fd@dAgdBd&dCdCdDfdEdFgdBd&dGdHfdIdJgdBd dKfdLdMgdd
edNfdOdPgdQd dKfdRdSgddTd
edUfdVdWgd dTd"fdXdYgdedfdZd[gd d\d"fd]d^gd_d`daedbfdcddgd_dedaedbfdfdgdhgeddidjedkfdldmdngd&ddid)fdodpdqgd&ddid)fdrdsgedtddjedufdvdwgd&ddtd)fdxdygedzddjedufd{d|gdedfd}d~gd dd"fddgdddfddgddedNfddgdd dK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R fZ	 dddddÜZ	 dZdejejrOdej pPde
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 )r1   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(info 1 warning 2 error 3 severe 4 none 5rP   r|   r   ri      )infowarningr   severenoneTF)	1onyestrue0offnofalser   r,   Nrg   rh   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-datestampzVBase directory for absolute paths when reading from the local filesystem. Default "/".z--root-prefixrZ   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-classrj   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-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-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 %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.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   r   r   r     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   r   r   r   rj   T)r   r   r?   r   rl   r   OptionGroupadd_option_group
add_optiongetr   r   settings_defaultsr   r   settings_default_overrides)r   r   	componentr   rC   titledescriptionoption_specgroup	help_text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.DOCUTILSCONFIGc                 S   s    g | ]}|  rtj|qS r   )r3   r   ru   
expanduser)rB   fr   r   r   rD   ?  rE   z:OptionParser.get_standard_config_files.<locals>.<listcomp>)r   environr*   pathsepstandard_config_files)rd   r   r   r   r   get_standard_config_files8  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   )r   r   r   r   r   r  r   r   )r   r   filenamer   r   r   r  A  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+   r   r   r   r   r   readr   r   r   config_section_dependenciesr$   addhas_sectionr   r{   r   r   r   ru   dirname)r   config_filer#   appliedr   r
  sectionr   r   r   r   I  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_valuesa  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   r   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   sourcedestinationr   r   r   r"  h  s   



zOptionParser.check_argsc                 C   s    t jdtdd | j| d S )NzlOptionParser.set_defaults_from_dict() will be removed in Docutils 0.22 or with the switch to ArgumentParser.r|   r}   )r   r   r   r   r   r   r   r   r   r   set_defaults_from_dicty  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)r   r   r   r   r   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.)option_groupsoption_listr   r5   )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*   threshold_choicesr:   r2   r   sysstderrr   _locale_encodingdefault_error_encoding$default_error_encoding_error_handlerr6   r   rf   r<   r.   r'   r`   r   r   rA   r   r  r$   ra   __version____version_details__r   platformr   r   r   classmethodr  r  r   r#  r"  r'  r(  r+  r   r   r   r   r   r1     s   





!%
(+/269<?EK
P
S
V[^dgiknpuy~   
  
               "  #  $  %  &  )  .$ 
r1   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 writer
stylesheet)r6  stylesheet_path)r6  template)pep_stylesheetpep_stylesheet_pathpep_templateu  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".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.r|   r}   r   )r,   rW   )r   r   r   r/   rs   r   r  UnicodeDecodeErrorr-  r.  writenot_utf8_errorhandle_old_configvalidate_settings)r   	filenamesr"   read_okr  r   r   r   r    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   rW   r   )r   warn_explicitold_warningConfigDeprecationWarningget_sectionr  add_sectionr	   old_settings
has_optionr+   remove_section)r   r  rW   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)sectionsrW   r+  r5   r   r  r   r   r   r   r+   r   )	r   r  r"   r!  r!   r
   r   r   r   r   r   r   rA    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.
        r   r   )r4   r   )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.r|   r}   )r   r   r   r   r5   )r   r!  r   r   r   rG    s   	zConfigParser.get_sectionr]   )r   r   r   r   rI  rE  r?  r  r@  rA  rN  rG  r   r   r   r   r   r    s    r  c                   @   s   e Zd ZdZdS )rF  z3Warning for deprecated configuration file features.N)r   r   r   r   r   r   r   r   rF    s    rF  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   r1   r(  )r   r   r   r   get_default_settings  s   

$rO  )NNNN)NNr]   )+r   __docformat__r   configparserr   r   r   os.pathpathlibr   r-  r   ra   r   r   r   r   r%   r'   r.   r6   r7   r9   r<   rA   rG   rY   r\   r`   rf   rr   r{   r   r   r   r   r1   SettingsSpecRawConfigParserr  FutureWarningrF  rO  r   r   r   r   <module>   s   0









$




).%   