Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/docutils/__pycache__/io.cpython-311.pyc



]j]8dZdZddlZddlZddlZddlZddlZddlZddlm	Z		ej
5ejdejdpej
dZeZdddn#1swxYwYn$#e$rZdejvrdZndZYdZ[ndZ[wdZYnxYw	ejen#eef$rdZYnwxYwGd	d
eZGddeZd
ZdZGdde	ZGdde	ZGddZGddeZGddeZGddeZ GddeZ!GddeZ"Gdd eZ#Gd!d"eZ$Gd#d$eZ%dS)%z
I/O classes provide a uniform API for low-level input and output.  Subclasses
exist for a variety of input/output mechanisms.
reStructuredTextN)
TransformSpecignorezunknown locale: UTF-8utf-8ceZdZdS)
InputErrorN__name__
__module____qualname__k/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/docutils/io.pyr	r	3rr	ceZdZdS)OutputErrorNr
rrrrr4rrrc	tj|jtj|kS#ttt
f$rYdSwxYw)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)codecslookupencodingLookupErrorAttributeError	TypeError)streamrs  rcheck_encodingr7sQ}V_--x1H1HHH3tts.1AAc$|jjd|S)z5Return string representation of Exception `err`.
    z: )	__class__r)errs rerror_stringr Gsm$-----rceZdZdZdZdZ		ddZdZdZdZ	e
jd	Z	e
jd
fe
jdfe
jdffZ	d
ZdZdS)Inputah
    Abstract base class for input wrappers.

    Docutils input objects must provide a `read()` method that
    returns the source, typically as `str` instance.

    Inheriting `TransformSpec` allows input objects to add
    "transforms" and "unknown_reference_resolvers" to the "Transformer".
    (Optional for custom input objects since Docutils 0.19.)
    inputNstrictcp||_	||_	||_	||_	|s|j|_d|_dSN)r
error_handlersourcesource_pathdefault_source_pathsuccessful_encoding)selfr(r)rr's     r__init__zInput.__init__]sM 
1**'&-	8#7D#' EErc4|jd|jd|jS)Nz	: source=z, source_path=)rr(r)r,s r__repr__zInput.__repr__qs(26...$+++262B2BD	Drct)z,Return input as `str`. Define in subclasses.NotImplementedErrorr/s rreadz
Input.readu!!rc|jr<|jdkrt|ts
Jdt|tr|S|jr	|jg}n_||}|r|g}nDdg}t
r%t
dkr|t
|d|D]W}	t|||j}||_|	ddcS#ttf$r}|}Yd}~Pd}~wwxYwtdd	d
|Ddt|d)
a
        Decode `data` if required.

        Return Unicode `str` instances unchanged (nothing to decode).

        If `self.encoding` is None, determine encoding from data
        or try UTF-8, locale encoding, and (as last ressort) 'latin-1'.
        The client application should call ``locale.setlocale`` at the
        beginning of processing::

            locale.setlocale(locale.LC_ALL, '')

        Raise UnicodeError if unsuccessful.

        Provisional:
          - Raise UnicodeError (instead of falling back to the locale
            encoding) if decoding the source with the default encoding (UTF-8)
            fails and Python is started in `UTF-8 mode`.

            Raise UnicodeError (instead of falling back to "latin1") if both,
            default and locale encoding, fail.

          - Only remove BOM (U+FEFF ZWNBSP at start of data),
            no other ZWNBSPs.
        unicodez;input encoding is "unicode" but `data` is no `str` instancerzlatin-1uNz=Unable to decode input data.  Tried the following encodings: z, c34K|]}t|VdSr&)repr).0encs  r	<genexpr>zInput.decode.<locals>.<genexpr>s(BBscBBBBBBr.
())rlower
isinstancestrdetermine_encoding_from_data_locale_encodingappendr'r+replaceUnicodeErrorrjoinr )r,dataencoding_candidates
data_encodingr<decodedrerrors        rdecodezInput.decodeys4=	NT]0022i??dC((
N
N,M
N
N(dC  	K=	6$(=/ ==dCCM
6(5o##
(/i#$A(8G(C(C'../?@@@#**9555&
	
	C	
dC);<<+.(x44444 +.




'yyBB.ABBBBB
'
'U##
'
'
'((	(s2DD!DD!scoding[:=]\s*([-\w.]+)rz	utf-16-bez	utf-16-lec|jD]\}}||r|cS|ddD]H}|j|}|r*|ddcSIdS)z
        Try to determine the encoding of `data` by looking *in* `data`.
        Check for a byte order mark (BOM) or an encoding declaration.
        Nrascii)byte_order_marks
startswith
splitlinescoding_slugsearchgrouprN)r,rIstart_bytesrlinematchs      rrCz"Input.determine_encoding_from_datas&*%:	 	 !K{++
 
 OO%%bqb)	6	6D$++D11E
6{{1~~,,W55555
6trcX	|jS#t$rYdSwxYw)z>Return True, if the input source is connected to a TTY device.F)r(isattyrr/s rr\zInput.isattys=	;%%'''			55	
))NNNr$)rrr
__doc__component_typer*r-r0r4rNrecompilerUrBOM_UTF8BOM_UTF16_BEBOM_UTF16_LErRrCr\rrrr"r"Ms		N?C'FFFF(DDD"""D(D(D(L"*788K''2,k:,k:=- rr"c8eZdZdZdZdZ		d	dZdZdZdZ	dS)
Outputak
    Abstract base class for output wrappers.

    Docutils output objects must provide a `write()` method that
    expects and handles one argument (the output).

    Inheriting `TransformSpec` allows output objects to add
    "transforms" and "unknown_reference_resolvers" to the "Transformer".
    (Optional for custom output objects since Docutils 0.19.)
    outputNr$cj||_	|pd|_	||_	||_	|s|j|_dSdS)Nr$)rr'destinationdestination_pathdefault_destination_path)r,rjrkrr's     rr-zOutput.__init__sX 
7*6h*&. 02	B$($AD!!!	B	Brc4|jd|jd|jS)Nz: destination=z, destination_path=)rrjrkr/s rr0zOutput.__repr__s*>>>4#3#3#3T5J5JL	Mrct)z#Write `data`. Define in subclasses.r2r,rIs  rwritezOutput.writer5rc|jr>|jdkr!t|ts
Jd|St|ts|S||j|jS)a?
        Encode and return `data`.

        If `data` is a `bytes` instance, it is returned unchanged.
        Otherwise it is encoded with `self.encoding`.

        Provisional: If `self.encoding` is set to the pseudo encoding name
        "unicode", `data` must be a `str` instance and is returned unchanged.
        r7z<output encoding is "unicode" but `data` is no `str` instance)rr@rArBencoder'ros  rrrz
Output.encode
s=	T]0022i??dC((
N
N,M
N
N(K$$$	BK;;t}d.@AAArr^)
rrr
r_r`rlr-r0rprrrrrrgrgs~		N#:>.6BBBB"MMM"""BBBBBrrgc2eZdZdZ			d	dZdZdZdZdS)
ErrorOutputz
    Wrapper class for file-like error streams with
    failsafe de- and encoding of `str`, `bytes`, `unicode` and
    `Exception` instances.
    NbackslashreplacerFc|
tj}n*|sd}n%t|trt	|d}||_	|pt
|ddptpd|_	||_		||_
dS)a
        :Parameters:
            - `destination`: a file-like object,
                        a string (path to a file),
                        `None` (write to `sys.stderr`, default), or
                        evaluating to `False` (write() requests are ignored).
            - `encoding`: `destination` text encoding. Guessed if None.
            - `encoding_errors`: how to treat encoding errors.
        NFwrrQ)sysstderrrArBopenrjgetattrrDrencoding_errorsdecoding_errors)r,rjrr|r}s     rr-zErrorOutput.__init__&s*KK	1KK
S
)
)	1{C00K&+!8W[*d%K%K8,807	

,.%.%%rc|jsdSt|trt|}	|j|dS#t
$r<|j||j|jYdSt$rt|tr;|j||j|jYdS|jtjtjfvr"|jj
|YdS|jt||j|jYdSwxYw)z
        Write `data` to self.destination. Ignore, if self.destination is False.

        `data` can be a `bytes`, `str`, or `Exception` instance.
        N)rjrA	ExceptionrBrpUnicodeEncodeErrorrrrr|rrxrystdoutbufferr}ros  rrpzErrorOutput.writeGs	FdI&&	t99D	B""4(((((!	F	F	F""4;;t}/3/C$E$E
F
F
F
F
F
F		B		B		B$$$
B &&t{{4=373G(I(IJJJJJJ!cj#*%=== '--d333333 &&s4+/+?(A(ABBBBBB		Bs%AAE!AE!)>E!*3E! E!c|jtjtjfvrdS	|jdS#t
$rYdSwxYw)z
        Close the error-output stream.

        Ignored if the destination is` sys.stderr` or `sys.stdout` or has no
        close() method.
        N)rjrxrrycloserr/s rrzErrorOutput.closeasb
CJ777F	""$$$$$			DD	s>
AAcX	|jS#t$rYdSwxYw)z=Return True, if the destination is connected to a TTY device.F)rjr\rr/s rr\zErrorOutput.isattyos>	#**,,,			55	r])NNrurF)rrr
r_r-rprr\rrrrtrtsn37!3!*&&&&BBBB4rrtc2eZdZdZ			d
dZdZdZd	ZdS)	FileInputz5
    Input for single, simple file-like objects.
    Nr$Trct|||||||_t|_|g|rS	t|||jpd|j|_n#t$r }t|j|j|d}~wwxYwtj|_nAt|j|jdur%t!d|jd|jjd|s%	|jj|_dS#t&$rYdSwxYwdS)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 is read only ('r').
        Nz	utf-8-sigrerrorsFz#Encoding clash: encoding given is "z&" but source is opened with encoding "z".)r"r-	autoclosert_stderrrzrr'r(OSErrorr	errnostrerrorrxstdinrrGnamer)r)r,r(r)rr'rmoderMs        rr-zFileInput.__init__|sT	tV[(MJJJ""}}>
(O"&{D04
0L.2.@#B#B#BDKKOOO$U[%.+NNNO"i
DK
7
75
@
@, $


t{/C/C/C EFF
F	
#';#3   !



		s)$A##
B
-BB
&C99
DDc^	|jtjur|jj}n|j}nd#t
tf$rP|jsE|jr>t|jd}|}|
nYnwxYw|jr|
n!#|jr|
wwxYw||}d
|dgzS)zU
        Read and decode a single file and return the data (Unicode string).
        rb
r8)r(rxrrr4rGrrr)rzrrrNrHrT)r,rIb_sources   rr4zFileInput.reads%	{ci''{)..00{''))k*			=
T%5
 0$77}}    ! 	~


~



{{4  yy**B4/000s+AA
CAB/,C.B//CC,cP|dS)zK
        Return lines of a single file as list of Unicode strings.
        T)r4rTr/s r	readlineszFileInput.readliness yy{{%%d+++rcb|jtjur|jdSdSr&)r(rxrrr/s rrzFileInput.closes3;ci''K('r)NNNr$Tr)rrr
r_r-r4rrrrrrrwsk15.6&)&&&&P1112,,,     rrc<eZdZdZdZdZ				ddZdZd	Zd
Z	dS)
FileOutputz,Output for single, simple file-like objects.z<file>rwNr$Tct|||||d|_||_|t	jdtd|||_t|_	||rd|_n`tj|_nN|rLt|jdr7||jjkr'td|jjd	|d
|j	|s%	|jj|_dS#t"$rYdSwxYwdS)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.
        TNz_io.FileOutput: init argument "handle_io_errors" is ignored and will be removed in Docutils 2.0.rP)
stacklevelFrzWarning: Destination mode "z" differs from specified mode "")file)rgr-openedrwarningswarnDeprecationWarningrrtrrxrrjhasattrprintrrkr)r,rjrkrr'rhandle_io_errorsrs        rr-zFileOutput.__init__sT&	k+; -	1	1	1"'M*+=!
M
M
M
MDI"}}
.##&:  	%t/88	%$*///E!%!1!6!6!6>|
%
%
%
% 	
(,(8(=%%%!



		sC))
C76C7cd|jvr|j|jd}ni}	t|j|jfi||_n2#t$r%}t|j|j	|jd}~wwxYwd|_
dS)NbrT)rrr'rzrkrjrrrrr)r,kwargsrMs   rrzzFileOutput.opensdi"&- $ 244FFF	5#D$949OOOOD	5	5	5ek5>"355
5	5s;
A* A%%A*c|js|t|trat	|j|jdurEtjdkr |	dtj}|
|}	|j|n#t$r}t|trz	|jj|nY#t$rLt	|j|jdur-t!d|jd|jjd|jd|wxYwYd}~nDd}~wt$t&f$r-}t%d|jd	t)|dd}~wwxYw|jr|n!#|jr|wwxYw|S)
aBWrite `data` to a single file, also return it.

        `data` can be a `str` or `bytes` instance.
        If writing `bytes` fails, an attempt is made to write to
        the low-level interface ``self.destination.buffer``.

        If `data` is a `str` instance and `self.encoding` and
        `self.destination.encoding` are  set to different values, `data`
        is encoded to a `bytes` instance using `self.encoding`.

        Provisional: future versions may raise an error if `self.encoding`
        and `self.destination.encoding` are set to different values.
        FrzEncoding of z (z&) differs 
  from specified encoding (r?Nz2Unable to encode output data. output-encoding is: r>)rrzrArBrrjroslineseprFrrrprbytesrr
ValueErrorrkrGrr rr)r,rIrs   rrpzFileOutput.writes/{	IIKKKtS!!	%t/??5HHzT!!||D"*55;;t$$D	""4((((	"	"	"$&&
"
"$+11$7777%"""%d&6&*m558=>>(K4+@KK $ 0 9KK:>-KKKLLL
"	"k*	<	<	<;=;;&23&7&7;;;<<
<	<
~


~



sUB.-F,.
F
8EC.-E.AEEF,F
 (FF

F,,G
c|jtjtjfvr"|jd|_dSdS)NF)rjrxrryrrr/s rrzFileOutput.close?sACJ
#;;;""$$$DKKK<;r)NNNr$TNN)
rrr
r_rlrr-rzrprrrrrrsv66'D)
;?BF-1----^,,,\     rrceZdZdZdZdS)BinaryFileOutputzL
    A version of docutils.io.FileOutput which writes to a binary file.
    wbN)rrr
r_rrrrrrEs
DDDrrceZdZdZdZdZdS)StringInputz'Input from a `str` or `bytes` instance.<string>c6||jS)z`Return the source as `str` instance.

        Decode, if required (see `Input.decode`).
        )rNr(r/s rr4zStringInput.readSs
{{4;'''rNrrr
r_r*r4rrrrrNs/11$(((((rrceZdZdZdZdZdS)StringOutputz=Output to a `bytes` or `str` instance.

    Provisional.
    rcD|||_|jS)avStore `data` in `self.destination`, and return it.

        If `self.encoding` is set to the pseudo encoding name "unicode",
        `data` must be a `str` instance and is stored/returned unchanged
        (cf. `Output.encode`).

        Otherwise, `data` can be a `bytes` or `str` instance and is
        stored/returned as a `bytes` instance
        (`str` data is encoded with `self.encode()`).

        Attention: the `output_encoding`_ setting may affect the content
        of the output (e.g. an encoding declaration in HTML or XML or the
        representation of characters as LaTeX macro vs. literal character).
        )rrrjros  rrpzStringOutput.writecs! ;;t,,rNrrr
r_rlrprrrrr[s5
 *     rrceZdZdZdZdZdS)	NullInputzDegenerate input: read nothing.z
null inputcdS)zReturn an empty string.r8rr/s rr4zNullInput.read|srrNrrrrrrvs/))&rrceZdZdZdZdZdS)
NullOutputz!Degenerate output: write nothing.znull outputcdS)zDo nothing, return None.Nrros  rrpzNullOutput.writesrNrrrrrrs/++,




rrceZdZdZdZdZdS)DocTreeInputzm
    Adapter for document tree input.

    The document tree must be passed in the ``source`` parameter.
    z
doctree inputc|jS)zReturn the document tree.)r(r/s rr4zDocTreeInput.reads
{rNrrrrrrs5*rr)&r_
__docformat__rlocalerrarxrdocutilsrcatch_warningssimplefilter	getlocalegetdefaultlocalerDr@rrMargsrrrrr	rrr r"rgrtrrrrrrrrrrr<module>rs


#








								



""""""	 	 	"	"44h''',F,..q1<6v688;	+1133	444444444444444
   %*,,"FM"####Y      '   


 ...QQQQQMQQQh;B;B;B;B;B];B;B;B|UUUUUUUUpN N N N N N N N bz z z z z z z z zz
(
(
(
(
(%
(
(
(     6   6







5sMBABBBBBBB;B22B;?C	CC
Back to Directory File Manager