HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/docutils/__pycache__/core.cpython-36.pyc
3

t2�e�s�@sTdZdZddlZddlZddlmZmZmZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlmZmZddlZGd	d
�d
�ZdZdZdd
ddddddddddeefdd�Zd"dd�Zd#dd�Zde	jddd
dddddddddfdd�Zde	jdd
dddddddfdd�Zd$dd�Zdd
ddddddddddeede	jfdd�Z d d!�Z!dS)%a�
Calling the ``publish_*`` convenience functions (or instantiating a
`Publisher` object) with component names will result in default
behavior.  For custom behavior (setting component options), create
custom component objects first, and pass *them* to
``publish_*``/`Publisher`.  See `The Docutils Publisher`_.

.. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html
ZreStructuredText�N)�__version__�__version_details__�SettingsSpec)�frontend�io�utils�readers�writers)�OptionParser)�Transformer)�ErrorOutput�ErrorStringc@s�eZdZdZddddejdejdfdd�Zdd�Zdd�Z	d	d
�Z
d&dd�Zd'd
d�Zdd�Z
d(dd�Zd)dd�Zd*dd�Zd+dd�Zdd�Zd,dd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)-�	PublisherzK
    A facade encapsulating the high-level logic of a Docutils system.
    Nc	
Cszd|_||_||_||_x6dD].}	tt||	�t�stdt||	�|	|	f��qW||_||_	||_
||_||_t
�|_dS)z�
        Initial setup.  If any of `reader`, `parser`, or `writer` are not
        specified, the corresponding ``set_...`` method should be called with
        a component name (`set_reader` sets the parser as well).
        N�reader�parser�writerz�passed string "%s" as "%s" parameter; pass an instance, or use the "%s_name" parameter instead (in docutils.core.publish_* convenience functions).)rrr)�documentrrr�
isinstance�getattr�str�AssertionError�source�source_class�destination�destination_class�settingsr�_stderr)
�selfrrrrrrrrZ	component�r�/usr/lib/python3.6/core.py�__init__ s

zPublisher.__init__cCs$tj|�}|||�|_|jj|_dS)zSet `self.reader` by name.N)rZget_reader_classrr)r�reader_namer�parser_nameZreader_classrrr�
set_readerPs
zPublisher.set_readercCstj|�}|�|_dS)zSet `self.writer` by name.N)r	Zget_writer_classr)r�writer_nameZwriter_classrrr�
set_writerVs
zPublisher.set_writercCs^|jdkr|j||j|�|jdkrF|jjdkr<|jj|�|jj|_|jdkrZ|j|�dS)N)rr#rZ
set_parserrr%)rr!r"r$rrr�set_components[s



zPublisher.set_componentscKs`|r<|st�}||_|j�}t|�dkr<|ddkr<dg|_t|j|j|j|f|d||d�}|S)N�ZapplicationZapplicationsT)Z
components�defaultsZread_config_files�usage�description���)	r�config_section�split�lenZconfig_section_dependenciesr
rrr)rr)r*�
settings_specr,r(�parts�
option_parserrrr�setup_option_parseres
zPublisher.setup_option_parsercKs$|j||||f|�}|j�|_|jS)a

        Set and return default settings (overrides in `defaults` dict).

        Set components first (`self.set_reader` & `self.set_writer`).
        Explicitly setting `self.settings` disables command line option
        processing from `self.publish()`.
        )r2Zget_default_valuesr)rr)r*r/r,r(r1rrr�get_settingsvs	
zPublisher.get_settingscCs<|jdkr8|pij�}|jdd�|jf||d�|��dS)N�	tracebackT)r/r,)r�copy�
setdefaultr3)rr/�settings_overridesr,r(rrr�process_programmatic_settings�s
z'Publisher.process_programmatic_settingscs`|j||||f|�}|dkrPtjdd�}tjdkrPtjp<d��fdd�|D�}|j|�|_dS)	z�
        Pass an empty list to `argv` to avoid reading `sys.argv` (the
        default).

        Set components first (`self.set_reader` & `self.set_writer`).
        Nr'�r�asciicsg|]}|j���qSr)�decode)�.0�a)�
argv_encodingrr�
<listcomp>�sz2Publisher.process_command_line.<locals>.<listcomp>)r9r)r2�sys�argv�version_inforZlocale_encoding�
parse_argsr)rrAr)r*r/r,r(r1r)r>r�process_command_line�s	

zPublisher.process_command_linecCs0|jdkr|j|d�|jdkr,|j|d�dS)N)�source_path)�destination_path)r�
set_sourcer�set_destination)rrErFrrr�set_io�s

zPublisher.set_iocCsd|dkr|jj}n||j_y|j|||jjd�|_Wn*tk
r^|j|||jjd�|_YnXdS)N)rrE�encoding)r�_sourcerZinput_encodingr�	TypeError)rrrErrrrG�s
zPublisher.set_sourcecCs:|dkr|jj}n||j_|j|||jj|jjd�|_dS)N)rrFrJZ
error_handler)rZ_destinationr�output_encoding�output_encoding_error_handlerr)rrrFrrrrH�s
zPublisher.set_destinationcCs4|jjj|j|j|jj|j|jf�|jjj�dS)N)	r�transformerZpopulate_from_componentsrrrrr�apply_transforms)rrrrrP�s
zPublisher.apply_transformsFcCs>d}yl|jdkr*|j|||||f|p&i�|j�|jj|j|j|j�|_|j�|j	j
|j|j�}	|j	j�Wnxt
k
r�}
zd}|
j}WYdd}
~
XnNtk
r�}
z2|js��|jjr�|j��|j|
�d}d}WYdd}
~
XnX|j�|�r*|j�r*|jjj|jjk�r*tj|jjjd�n|�r:tj|�|	S)z�
        Process command line options and arguments (if `self.settings` not
        already set), run `self.reader` and then `self.writer`.  Return
        `self.writer`'s output.
        Nr'T�
)rrDrIr�readrrrrPr�writerZassemble_parts�
SystemExit�code�	Exceptionr4�debugging_dumps�report_ExceptionZreporterZ	max_levelZexit_status_levelr@�exit)rrAr)r*r/r7r,�enable_exit_statusrY�output�errorZexit_statusrrr�publish�s@




zPublisher.publishcCs�|js
dS|jjr8td|jd�ttj|jj�|jd�|jjrftd|jd�ttj|jj�|jd�|jj	r�td|jd�td|jd�ttjdd�|jj
jD��|jd�|jjr�td|jd�t|jj�j
d	�|jd�dS)
Nz
::: Runtime settings:)�filez
::: Document internals:z
::: Transforms applied:z@ (priority, transform class, pending node details, keyword args)cSs2g|]*\}}}}|d|j|jf|o(|j|f�qS)z%s.%s)�
__module__�__name__Zdetails)r<ZpriorityZxclass�pending�kwargsrrrr?sz-Publisher.debugging_dumps.<locals>.<listcomp>z
::: Pseudo-XML:Zraw_unicode_escape)rrZ
dump_settings�printr�pprintZpformat�__dict__Zdump_internalsZdump_transformsrOZappliedZdump_pseudo_xml�encode)rrrrrW�s&
zPublisher.debugging_dumpscCs�t|tj�r|j|�n�t|t�r.|j|�n�t|tj�rP|jj	dt
|��njt|tj�rr|jj	dt
|��nHtdt
|�|jd�tdt
tjr�dtjp�dtjj�df|jd�dS)	Nz-Unable to open source file for reading:
  %s
z2Unable to open destination file for writing:
  %s
z%s)r^z�Exiting due to error.  Use "--traceback" to diagnose.
Please report errors to <[email protected]>.
Include "--traceback" output, Docutils version (%s%s),
Python version (%s), your OS type & version, and the
command line used.z [%s]�r)rrZ
SystemMessage�report_SystemMessage�UnicodeEncodeError�report_UnicodeErrorrZ
InputErrorrrSr
ZOutputErrorrcr�docutilsrr@�versionr-)rr\rrrrX	s"
zPublisher.report_ExceptioncCs&td|jtjj|jf|jd�dS)Nz,Exiting due to level-%s (%s) system message.)r^)rc�levelrZReporterZlevelsr)rr\rrrrh!szPublisher.report_SystemMessagec
CsZ|j|j|j�}|jjdt|�|jj|jdd�|jdd�|jj	t
tjj
�df�dS)Na�%s

The specified output encoding (%s) cannot
handle all of the output.
Try setting "--output-encoding-error-handler" to

* "xmlcharrefreplace" (for HTML & XML output);
  the output will contain "%s" and should be usable.
* "backslashreplace" (for other output formats);
  look for "%s" in the output.
* "replace"; look for "?" in the output.

"--output-encoding-error-handler" is currently set to "%s".

Exiting due to error.  Use "--traceback" to diagnose.
If the advice above doesn't eliminate the error,
please report it to <[email protected]>.
Include "--traceback" output, Docutils version (%s),
Python version (%s), your OS type & version, and the
command line used.
r:�xmlcharrefreplace�backslashreplacer)�object�start�endrrSr
rrMrfrNrr@rlr-)rr\�datarrrrj&s

zPublisher.report_UnicodeError)NNNN)NNNN)NNNNN)NN)NN)NN)NNNNNNF)r`r_�__qualname__�__doc__r�	FileInput�
FileOutputr r#r%r&r2r3r8rDrIrGrHrPr]rWrXrhrjrrrrrs4-









'rz*%prog [options] [<source> [<destination>]]z�Reads from <source> (default is stdin) and writes to <destination> (default is stdout).  See <http://docutils.sf.net/docs/user/config.html> for the full reference.�
standalone�restructuredtext�	pseudoxmlTc	Cs:t||||d�}|j|||�|j|||
|||	|
d�}|S)a%
    Set up & run a `Publisher` for command-line-based file I/O (input and
    output file paths taken automatically from the command line).  Return the
    encoded string output also.

    Parameters: see `publish_programmatically` for the remainder.

    - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
    - `usage`: Usage string, output if there's a problem parsing the command
      line.
    - `description`: Program description, output for the "--help" option
      (along with command-line option descriptions).
    )r)r,rZ)rr&r])rr!rr"rr$rr/r7r,rZrAr)r*�pubr[rrr�publish_cmdlineJs

r|FcCs6ttj||tj||||||||	|
|||
|d�\}}|S)z�
    Set up & run a `Publisher` for programmatic use with file-like I/O.
    Return the encoded string output also.

    Parameters: see `publish_programmatically`.
    )rrrErrrFrr!rr"rr$rr/r7r,rZ)�publish_programmaticallyrrvrw)rrErrFrr!rr"rr$rr/r7r,rZr[r{rrr�publish_filees
r~cCs6ttj||tjd||||||||	|
|||
d�\}}|S)aB
    Set up & run a `Publisher` for programmatic use with string I/O.  Return
    the encoded string or Unicode string output.

    For encoded string output, be sure to set the 'output_encoding' setting to
    the desired encoding.  Set it to 'unicode' for unencoded Unicode string
    output.  Here's one way::

        publish_string(..., settings_overrides={'output_encoding': 'unicode'})

    Similarly for Unicode string input (`source`)::

        publish_string(..., settings_overrides={'input_encoding': 'unicode'})

    Parameters: see `publish_programmatically`.
    N)rrrErrrFrr!rr"rr$rr/r7r,rZ)r}r�StringInput�StringOutput)rrErFrr!rr"rr$rr/r7r,rZr[r{rrr�publish_stringsr�cCs8t|||tjd|||||||	|
|||
|d�\}}|jjS)a
    Set up & run a `Publisher`, and return a dictionary of document parts.
    Dictionary keys are the names of parts, and values are Unicode strings;
    encoding is up to the client.  For programmatic use with string I/O.

    For encoded string input, be sure to set the 'input_encoding' setting to
    the desired encoding.  Set it to 'unicode' for unencoded Unicode string
    input.  Here's how::

        publish_parts(..., settings_overrides={'input_encoding': 'unicode'})

    Parameters: see `publish_programmatically`.
    N)rrErrrrFrr!rr"rr$rr/r7r,rZ)r}rr�rr0)rrErrFrr!rr"rr$rr/r7r,rZr[r{rrr�
publish_parts�sr�cCs\t||d||tjd�}|j||d�|j||	|
�|j||�|jdd�|j|d�}
|jS)a�
    Set up & run a `Publisher` for programmatic use with string I/O.
    Return the document tree.

    For encoded string input, be sure to set the 'input_encoding' setting to
    the desired encoding.  Set it to 'unicode' for unencoded Unicode string
    input.  Here's one way::

        publish_doctree(..., settings_overrides={'input_encoding': 'unicode'})

    Parameters: see `publish_programmatically`.
    N)rrrrrr�null)rZ)	rrZ
NullOutputr&r8rGrHr]r)rrErrr!rr"rr/r7r,rZr{r[rrr�publish_doctree�s

r�c	Csftjjjdd�}	t|	d|tj|�tj|d�}
|r@|r@|
j|�|
j	|||�|
j
d|�|
j|d�S)aJ
    Set up & run a `Publisher` to render from an existing document
    tree data structure, for programmatic use with string I/O.  Return
    the encoded string output.

    Note that document.settings is overridden; if you want to use the settings
    of the original `document`, pass settings=document.settings.

    Also, new document.transformer and document.reporter objects are
    generated.

    For encoded string output, be sure to set the 'output_encoding' setting to
    the desired encoding.  Set it to 'unicode' for unencoded Unicode string
    output.  Here's one way::

        publish_from_doctree(
            ..., settings_overrides={'output_encoding': 'unicode'})

    Parameters: `document` is a `docutils.nodes.document` object, an existing
    document tree.

    Other parameters: see `publish_programmatically`.
    r�)r"N)rrr)rZ)rkrZdoctree�ReaderrrZDocTreeInputr�r%r8rHr])rrFrr$rr/r7r,rZrr{rrr�publish_from_doctree�s


r�c	Cs<t|||||d�}|j|||�|j|||
|||	|
d�}|S)a�
    Set up & run a `Publisher` for command-line-based file I/O (input and
    output file paths taken automatically from the command line).  Return the
    encoded string output also.

    This is just like publish_cmdline, except that it uses
    io.BinaryFileOutput instead of io.FileOutput.

    Parameters: see `publish_programmatically` for the remainder.

    - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
    - `usage`: Usage string, output if there's a problem parsing the command
      line.
    - `description`: Program description, output for the "--help" option
      (along with command-line option descriptions).
    )rr)r,rZ)rr&r])rr!rr"rr$rr/r7r,rZrAr)r*rrr{r[rrr�publish_cmdline_to_binarys


r�cCs\t|||
|||d�}|j||	|�|j|
||�|j||�|j||�|j|d�}||fS)a7
    Set up & run a `Publisher` for custom programmatic use.  Return the
    encoded string output and the Publisher object.

    Applications should not need to call this function directly.  If it does
    seem to be necessary to call this function directly, please write to the
    Docutils-develop mailing list
    <http://docutils.sf.net/docs/user/mailing-lists.html#docutils-develop>.

    Parameters:

    * `source_class` **required**: The class for dynamically created source
      objects.  Typically `io.FileInput` or `io.StringInput`.

    * `source`: Type depends on `source_class`:

      - If `source_class` is `io.FileInput`: Either a file-like object
        (must have 'read' and 'close' methods), or ``None``
        (`source_path` is opened).  If neither `source` nor
        `source_path` are supplied, `sys.stdin` is used.

      - If `source_class` is `io.StringInput` **required**: The input
        string, either an encoded 8-bit string (set the
        'input_encoding' setting to the correct encoding) or a Unicode
        string (set the 'input_encoding' setting to 'unicode').

    * `source_path`: Type depends on `source_class`:

      - `io.FileInput`: Path to the input file, opened if no `source`
        supplied.

      - `io.StringInput`: Optional.  Path to the file or object that produced
        `source`.  Only used for diagnostic output.

    * `destination_class` **required**: The class for dynamically created
      destination objects.  Typically `io.FileOutput` or `io.StringOutput`.

    * `destination`: Type depends on `destination_class`:

      - `io.FileOutput`: Either a file-like object (must have 'write' and
        'close' methods), or ``None`` (`destination_path` is opened).  If
        neither `destination` nor `destination_path` are supplied,
        `sys.stdout` is used.

      - `io.StringOutput`: Not used; pass ``None``.

    * `destination_path`: Type depends on `destination_class`:

      - `io.FileOutput`: Path to the output file.  Opened if no `destination`
        supplied.

      - `io.StringOutput`: Path to the file or object which will receive the
        output; optional.  Used for determining relative paths (stylesheets,
        source links, etc.).

    * `reader`: A `docutils.readers.Reader` object.

    * `reader_name`: Name or alias of the Reader class to be instantiated if
      no `reader` supplied.

    * `parser`: A `docutils.parsers.Parser` object.

    * `parser_name`: Name or alias of the Parser class to be instantiated if
      no `parser` supplied.

    * `writer`: A `docutils.writers.Writer` object.

    * `writer_name`: Name or alias of the Writer class to be instantiated if
      no `writer` supplied.

    * `settings`: A runtime settings (`docutils.frontend.Values`) object, for
      dotted-attribute access to runtime settings.  It's the end result of the
      `SettingsSpec`, config file, and option processing.  If `settings` is
      passed, it's assumed to be complete and no further setting/config/option
      processing is done.

    * `settings_spec`: A `docutils.SettingsSpec` subclass or object.  Provides
      extra application-specific settings definitions independently of
      components.  In other words, the application becomes a component, and
      its settings data is processed along with that of the other components.
      Used only if no `settings` specified.

    * `settings_overrides`: A dictionary containing application-specific
      settings defaults that override the defaults of other components.
      Used only if no `settings` specified.

    * `config_section`: A string, the name of the configuration file section
      for this application.  Overrides the ``config_section`` attribute
      defined by `settings_spec`.  Used only if no `settings` specified.

    * `enable_exit_status`: Boolean; enable exit status at end of processing?
    )rrr)rZ)rr&r8rGrHr])rrrErrrFrr!rr"rr$rr/r7r,rZr{r[rrrr},sd

r})NNNNNrxNryNrzNNNNF)
NNNrxNryNrzNNNNF)NNrzNNNNF)"ruZ
__docformat__r@rdrkrrrrrrrr	Zdocutils.frontendr
Zdocutils.transformsrZdocutils.utils.error_reportingrr
Zdocutils.readers.doctreerZ
default_usageZdefault_descriptionr|r~r�rr�r�r�ZBinaryFileOutputr�r}rrrr�<module>
s�,


#