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: //proc/722141/root/lib/python3.6/site-packages/docutils/__pycache__/io.cpython-36.pyc
3

s2�e)D�@s dZdZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
Gdd�de�ZGd	d
�d
e�Zdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZdS)!z
I/O classes provide a uniform API for low-level input and output.  Subclasses
exist for a variety of input/output mechanisms.
ZreStructuredText�N)�
TransformSpec)�b)�locale_encoding�ErrorString�ErrorOutputc@seZdZdS)�
InputErrorN)�__name__�
__module__�__qualname__�rr�/usr/lib/python3.6/io.pyrsrc@seZdZdS)�OutputErrorN)rr	r
rrrrr
sr
c
Cs6ytj|j�tj|�kStttfk
r0dSXdS)aNTest, whether the encoding of `stream` matches `encoding`.

    Returns

    :None:  if `encoding` or `stream.encoding` are not a valid encoding
            argument (e.g. ``None``) or `stream.encoding is missing.
    :True:  if the encoding argument resolves to the same value as `encoding`,
    :False: if the encodings differ.
    N)�codecs�lookup�encoding�LookupError�AttributeError�	TypeError)�streamrrrr�check_encodings
rc@sleZdZdZdZdZddd�Zdd�Zd	d
�Zdd�Z	e
jed
��Z
ejdfejdfejdffZdd�ZdS)�Inputz1
    Abstract base class for input wrappers.
    �inputN�strictcCs.||_||_||_||_|s$|j|_d|_dS)N)r�
error_handler�source�source_path�default_source_path�successful_encoding)�selfrrrrrrr�__init__2szInput.__init__cCsd|j|j|jfS)Nz%s: source=%r, source_path=%r)�	__class__rr)rrrr�__repr__Fs
zInput.__repr__cCst�dS)N)�NotImplementedError)rrrr�readJsz
Input.readcCs�|jr&|jj�dkr&t|t�s&td��t|t�r4|S|jrD|jg}n.|j|�}|rZ|g}nddg}trr|jdt�xX|D]P}y t|||j�}||_	|j
dd�Sttfk
r�}z
|}WYdd}~XqxXqxWtd	d
j
dd�|D��t|�f��dS)
a
        Decode a string, `data`, heuristically.
        Raise UnicodeError if unsuccessful.

        The client application should call ``locale.setlocale`` at the
        beginning of processing::

            locale.setlocale(locale.LC_ALL, '')
        �unicodez=input encoding is "unicode" but input is not a unicode objectzutf-8zlatin-1�u�NzEUnable to decode input data.  Tried the following encodings: %s.
(%s)z, cSsg|]}t|��qSr)�repr)�.0�encrrr�
<listcomp>zsz Input.decode.<locals>.<listcomp>)r�lower�
isinstance�str�AssertionError�determine_encoding_from_datar�insertrr�replace�UnicodeErrorr�joinr)r�dataZ	encodings�
data_encodingr)Zdecoded�err�errorrrr�decodeMs0




zInput.decodezcoding[:=]\s*([-\w.]+)zutf-8z	utf-16-bez	utf-16-lecCs`x |jD]\}}|j|�r|SqWx8|j�dd�D]$}|jj|�}|r4|jd�jd�Sq4WdS)z�
        Try to determine the encoding of `data` by looking *in* `data`.
        Check for a byte order mark (BOM) or an encoding declaration.
        N�r%�ascii)�byte_order_marks�
startswith�
splitlines�coding_slug�search�groupr8)rr4Zstart_bytesr�line�matchrrrr/�s
z"Input.determine_encoding_from_data)NNNr)rr	r
�__doc__�component_typerrr!r#r8�re�compilerr>r�BOM_UTF8�BOM_UTF16_BE�BOM_UTF16_LEr;r/rrrrr(s
0rc@s:eZdZdZdZdZd
dd�Zdd�Zd	d
�Zdd�Z	dS)�Outputz2
    Abstract base class for output wrappers.
    �outputNrcCs,||_|pd|_||_||_|s(|j|_dS)Nr)rr�destination�destination_path�default_destination_path)rrLrMrrrrrr�s
zOutput.__init__cCsd|j|j|jfS)Nz'%s: destination=%r, destination_path=%r)r rLrM)rrrrr!�szOutput.__repr__cCst�dS)z;`data` is a Unicode string, to be encoded by `self.encode`.N)r")rr4rrr�write�szOutput.writecCsL|jr*|jj�dkr*t|t�s&td��|St|t�s8|S|j|j|j�SdS)Nr$zFthe encoding given is "unicode" but the output is not a Unicode string)rr+r,r-r.�encoder)rr4rrrrP�s
z
Output.encode)NNNr)
rr	r
rCrDrNrr!rOrPrrrrrJ�s
rJc@s2eZdZdZddd�Zdd	�Zd
d�Zdd
�ZdS)�	FileInputz5
    Input for single, simple file-like objects.
    NrT�rUc
Ks2tj|||||�||_t�|_x.|D]&}|dkr@tjjd�q&td|��q&W|dkr�|r�tj	d
krv|j
|jd�}ni}yt||f|�|_
Wq�tk
r�}	zt|	j|	j|��WYdd}	~	Xq�Xntj|_
n4tj	dko�t|j
|j
�dk�rtd	|j
|j
j
f��|�s.y|j
j|_Wntk
�r,YnXdS)a�
        :Parameters:
            - `source`: either a file-like object (which is read directly), or
              `None` (which implies `sys.stdin` if no `source_path` given).
            - `source_path`: a path to a file, which is opened and then read.
            - `encoding`: the expected text encoding of the input file.
            - `error_handler`: the encoding error handler to use.
            - `autoclose`: close automatically after read (except when
              `sys.stdin` is the source).
            - `mode`: how the file is to be opened (see standard function
              `open`). The default 'rU' provides universal newline support
              for text files.
        �handle_io_errorsz�deprecation warning: io.FileInput() argument `handle_io_errors` is ignored since "Docutils 0.10 (2012-12-16)" and will soon be removed.z2__init__() got an unexpected keyword argument '%s'N�r)r�errorsFzOEncoding clash: encoding given is "%s" but source is opened with encoding "%s".)rTr)rTr)rr�	autocloser�_stderr�sys�stderrrOr�version_inforr�openr�IOErrorr�errno�strerror�stdinrr2�namerr)
rrrrrrV�mode�kwargs�keyr7rrrr�s8

$

zFileInput.__init__cCs�z�yL|jtjkrBtjdkrB|jjj�}td�j|j��td�}n
|jj�}Wnnt	t
fk
r�}zN|jr�|jr�t
|jd�}|j�}|j�td�j|j��td�}n�WYdd}~XnXWd|jr�|j�X|j|�S)zU
        Read and decode a single file and return the data (Unicode string).
        rTr�
�rbN)rTr)rrXr_rZ�bufferr#rr3r=r2rrrr[�closerVr8)rr4r6Zb_sourcerrrr#s 
zFileInput.readcCs|j�jd�S)zK
        Return lines of a single file as list of Unicode strings.
        T)r#r=)rrrr�	readlines"szFileInput.readlinescCs|jtjk	r|jj�dS)N)rrXr_rg)rrrrrg(szFileInput.close)NNNrTrR)rr	r
rCrr#rhrgrrrrrQ�s
7rQc@s6eZdZdZdZddd�Zdd	�Zd
d�Zdd
�ZdS)�
FileOutputz6
    Output for single, simple file-like objects.
    �wNrTcCs�tj|||||�d|_||_|dk	r,||_t�|_|dkrR|rHd|_q�tj|_	n6|r�t
|j	d�r�||j	jkr�td|j	j|f|jd�|s�y|j	j|_
Wntk
r�YnXdS)aA
        :Parameters:
            - `destination`: either a file-like object (which is written
              directly) or `None` (which implies `sys.stdout` if no
              `destination_path` given).
            - `destination_path`: a path to a file, which is opened and then
              written.
            - `encoding`: the text encoding of the output file.
            - `error_handler`: the encoding error handler to use.
            - `autoclose`: close automatically after write (except when
              `sys.stdout` or `sys.stderr` is the destination).
            - `handle_io_errors`: ignored, deprecated, will be removed.
            - `mode`: how the file is to be opened (see standard function
              `open`). The default is 'w', providing universal newline
              support for text files.
        TNFraz?Warning: Destination mode "%s" differs from specified mode "%s")�file)rJr�openedrVrarrWrX�stdoutrL�hasattr�printr`rMr)rrLrMrrrVrSrarrrr9s(

zFileOutput.__init__cCs�tjdkr$d|jkr$|j|jd�}ni}yt|j|jf|�|_Wn4tk
rt}zt	|j
|j|j��WYdd}~XnXd|_dS)NrTrr)rrUT)rTr)
rXrZrarrr[rMrLr\r
r]r^rl)rrbr7rrrr[ds
zFileOutput.opencCsn|js|j�d|jkr"tjd
ks4t|j|j�dkrh|j|�}tjdkrht	j
dkrh|jtd�tt	j
��}z�y|jj
|�Wn�tk
�r}z~tjdko�t|t��ry|jjj
|�WnNtk
�rt|j|j�dk�r�td|jp�d|jj|jf��n|�YnXWYdd}~Xn>ttfk
�rR}ztd	|jt|�f��WYdd}~XnXWd|j�rh|j�X|S)
z�Encode `data`, write it to a single file, and return it.

        With Python 3 or binary output mode, `data` is returned unchanged,
        except when specified encoding and output encoding differ.
        rrTrFrdz;Encoding of %s (%s) differs 
  from specified encoding (%s)rLNz:Unable to encode output data. output-encoding is: %s.
(%s))rTr)rTr)rTr)rlr[rarXrZrrLrrP�os�linesepr1rrOrr,�bytesrfr�
ValueErrorrMr2rrrVrg)rr4�er6rrrrOrs8
(
zFileOutput.writecCs&|jtjtjfkr"|jj�d|_dS)NF)rLrXrmrYrgrl)rrrrrg�s
zFileOutput.close)NNNrTNN)	rr	r
rCrarr[rOrgrrrrri-s
)(ric@seZdZdZdZdS)�BinaryFileOutputzL
    A version of docutils.io.FileOutput which writes to a binary file.
    �wbN)rr	r
rCrarrrrru�sruc@seZdZdZdZdd�ZdS)�StringInputz
    Direct string input.
    z<string>cCs|j|j�S)z$Decode and return the source string.)r8r)rrrrr#�szStringInput.readN)rr	r
rCrr#rrrrrw�srwc@seZdZdZdZdd�ZdS)�StringOutputz
    Direct string output.
    z<string>cCs|j|�|_|jS)z=Encode `data`, store it in `self.destination`, and return it.)rPrL)rr4rrrrO�szStringOutput.writeN)rr	r
rCrNrOrrrrrx�srxc@seZdZdZdZdd�ZdS)�	NullInputz)
    Degenerate input: read nothing.
    z
null inputcCsdS)zReturn a null string.r&r)rrrrr#�szNullInput.readN)rr	r
rCrr#rrrrry�sryc@seZdZdZdZdd�ZdS)�
NullOutputz+
    Degenerate output: write nothing.
    znull outputcCsdS)z6Do nothing ([don't even] send data to the bit bucket).Nr)rr4rrrrO�szNullOutput.writeN)rr	r
rCrNrOrrrrrz�srzc@seZdZdZdZdd�ZdS)�DocTreeInputzm
    Adapter for document tree input.

    The document tree must be passed in the ``source`` parameter.
    z
doctree inputcCs|jS)zReturn the document tree.)r)rrrrr#�szDocTreeInput.readN)rr	r
rCrr#rrrrr{�sr{)rCZ
__docformat__rXrprErZdocutilsrZdocutils._compatrZdocutils.utils.error_reportingrrrr\rr
rrrJrQrirurwrxryrzr{rrrr�<module>s*p0es