%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/usr/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/usr/lib/python3.8/__pycache__/formatter.cpython-38.pyc

U

k�]e';�@s�dZddlZddlZejdedd�dZGdd�d�ZGdd	�d	�ZGd
d�d�ZGdd
�d
e�Z	Gdd�de�Z
ddd�Zedkr�e�dS)aGeneric output formatting.

Formatter objects transform an abstract flow of formatting events into
specific output events on writer objects. Formatters manage several stack
structures to allow various properties of a writer object to be changed and
restored; writers need not be able to handle relative changes nor any sort
of ``change back'' operation. Specific writer properties which may be
controlled via formatter objects are horizontal alignment, font, and left
margin indentations. A mechanism is provided which supports providing
arbitrary, non-exclusive style settings to a writer as well. Additional
interfaces facilitate formatting events which are not reversible, such as
paragraph separation.

Writer objects encapsulate device interfaces. Abstract devices, such as
file formats, are supported as well as physical devices. The provided
implementations all work with abstract devices. The interface makes
available mechanisms for setting the properties which formatter objects
manage and inserting data into the output.
�Nz"the formatter module is deprecated�)�
stacklevelc@s�eZdZdZd(dd�Zdd�Zdd�Zd	d
�Zd)dd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd*d$d%�Zd+d&d'�ZdS),�
NullFormattera=A formatter which does nothing.

    If the writer parameter is omitted, a NullWriter instance is created.
    No methods of the writer are called by NullFormatter instances.

    Implementations should inherit from this class if implementing a writer
    interface but don't need to inherit any implementation.

    NcCs|dkrt�}||_dS�N)�
NullWriter�writer��selfr�r
�/usr/lib/python3.8/formatter.py�__init__)szNullFormatter.__init__cCsdSrr
�r	�	blankliner
r
r�
end_paragraph-�zNullFormatter.end_paragraphcCsdSrr
�r	r
r
r�add_line_break.rzNullFormatter.add_line_breakcOsdSrr
�r	�args�kwr
r
r�add_hor_rule/rzNullFormatter.add_hor_rulecCsdSrr
�r	�format�counterrr
r
r�add_label_data0rzNullFormatter.add_label_datacCsdSrr
�r	�datar
r
r�add_flowing_data1rzNullFormatter.add_flowing_datacCsdSrr
rr
r
r�add_literal_data2rzNullFormatter.add_literal_datacCsdSrr
rr
r
r�flush_softspace3rzNullFormatter.flush_softspacecCsdSrr
�r	�alignr
r
r�push_alignment4rzNullFormatter.push_alignmentcCsdSrr
rr
r
r�
pop_alignment5rzNullFormatter.pop_alignmentcCsdSrr
)r	�xr
r
r�	push_font6rzNullFormatter.push_fontcCsdSrr
rr
r
r�pop_font7rzNullFormatter.pop_fontcCsdSrr
)r	�marginr
r
r�push_margin8rzNullFormatter.push_margincCsdSrr
rr
r
r�
pop_margin9rzNullFormatter.pop_margincCsdSrr
�r	�spacingr
r
r�set_spacing:rzNullFormatter.set_spacingcGsdSrr
�r	�stylesr
r
r�
push_style;rzNullFormatter.push_style�cCsdSrr
�r	�nr
r
r�	pop_style<rzNullFormatter.pop_stylecCsdSrr
�r	�flagr
r
r�assert_line_data=rzNullFormatter.assert_line_data)N)N)r0)r0)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr"r#r%r&r(r)r,r/r3r6r
r
r
rrs&



rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd.dd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd/d*d+�Zd0d,d-�Zd
S)1�AbstractFormatterz�The standard formatter.

    This implementation has demonstrated wide applicability to many writers,
    and may be used directly in most circumstances.  It has been used to
    implement a full-featured World Wide Web browser.

    cCsR||_d|_g|_g|_g|_d|_g|_d|_d|_d|_	d|_
d|_d|_dS�Nr0r)
rr!�align_stack�
font_stack�margin_stackr+�style_stack�nospace�	softspace�para_end�parskip�
hard_break�
have_labelrr
r
rrNszAbstractFormatter.__init__cCs`|js|j��d|_|j|krD|jsD|j�||j�||_d|_d|_|_|_d|_dS�Nrr0)	rEr�send_line_breakrFrD�send_paragraphrArCrBr
r
r
rr]s
zAbstractFormatter.end_paragraphcCs8|js"|js"|j��d|_|_d|_|_d|_dSrG)rErCrrHrFrDrArBrr
r
rrhs

z AbstractFormatter.add_line_breakcOsF|js|j��|jj||�d|_|_d|_|_|_|_dSr<)	rErrH�
send_hor_rulerArFrCrBrDrr
r
rros

zAbstractFormatter.add_hor_ruleNcCs�|js|js|j��|js0|j�|r*dp,d�t|t�rP|j�|�	||��n|j�|�d|_
|_|_|_d|_|_dSr<)
rFrErrHrCrI�
isinstance�str�send_label_data�format_counterrArBrDrr
r
rrvs

z AbstractFormatter.add_label_datacCstd}|D]f}|dkr"|d|}q|dkrD|dkrn||�||�}q|dkrf|dkrn||�||�}q||}q|S)N��1z%dZaArZiI)�
format_letter�format_roman)r	rr�label�cr
r
rrN�s
z AbstractFormatter.format_countercCs<d}|dkr8t|dd�\}}tt|�|�}||}q|S)NrOrr0�)�divmod�chr�ord)r	�caserrSr$�sr
r
rrQ�s
zAbstractFormatter.format_letterc	Cs�ddddg}dddg}d\}}|d	kr�t|d
�\}}|dkrV||||d|}nT|d
krt|||||}n6|dkr�||}|d}nd}||||}||}|d}q|dkr�|��S|S)N�ir$rT�m�v�l�d)rOrr�
�	r0��rO�I)rV�upper)	r	rYrZonesZfivesrS�indexr$rZr
r
rrR�s&


zAbstractFormatter.format_romancCs�|sdS|dd���}|dd���}d�|���}|jrD|sDdS|sN|jrv|sh|jsdd|_d|_dS|jsvd|}d|_|_|_|_|_||_|j	�
|�dS)Nr0���� r)�isspace�join�splitrArBrDrErCrFr�send_flowing_data)r	rZprespaceZ	postspacer
r
rr�s*

�z"AbstractFormatter.add_flowing_datacCsZ|sdS|jr|j�d�|dd�dk|_d|_|_|_|_|_|j�|�dS)Nrhrg�
r)	rBrrlrErArCrDrF�send_literal_datarr
r
rr�s�z"AbstractFormatter.add_literal_datacCs:|jr6d|_|_|_|_|_d|_|j�d�dS�Nrr0rh)rBrErCrDrFrArrlrr
r
rr�s�z!AbstractFormatter.flush_softspacecCs@|r.||jkr.|j�|�||_|j�|�n|j�|j�dSr)r!r�
new_alignmentr=�appendr r
r
rr"�s
z AbstractFormatter.push_alignmentcCsH|jr|jd=|jr2|jd|_}|j�|�nd|_|j�d�dS�Nrg)r=r!rrpr r
r
rr#�szAbstractFormatter.pop_alignmentc
Cs�|\}}}}|jr6d|_|_|_d|_|j�d�|jr~|jd\}}}}	|tkrZ|}|tkrf|}|tkrr|}|tkr~|	}||||f}|j�|�|j�	|�dS)Nrr0rhrg)
rBrErCrArrlr>�AS_ISrq�new_font)
r	�font�sizer[�bZttZcsizeZci�cbZcttr
r
rr%�s$zAbstractFormatter.push_fontcCs4|jr|jd=|jr |jd}nd}|j�|�dSrr)r>rrt�r	rur
r
rr&�szAbstractFormatter.pop_fontcCsB|j�|�dd�|jD�}|s,|r,|d}|j�|t|��dS)NcSsg|]}|r|�qSr
r
��.0r\r
r
r�
<listcomp>sz1AbstractFormatter.push_margin.<locals>.<listcomp>rg)r?rqr�
new_margin�len)r	r'�fstackr
r
rr(s
zAbstractFormatter.push_margincCsF|jr|jd=dd�|jD�}|r,|d}nd}|j�|t|��dS)NrgcSsg|]}|r|�qSr
r
rzr
r
rr|
sz0AbstractFormatter.pop_margin.<locals>.<listcomp>)r?rr}r~)r	rr'r
r
rr)
s
zAbstractFormatter.pop_margincCs||_|j�|�dSr)r+r�new_spacingr*r
r
rr,szAbstractFormatter.set_spacingcGsV|jr*d|_|_|_d|_|j�d�|D]}|j�|�q.|j�t	|j��dSro)
rBrErCrArrlr@rq�
new_styles�tuple)r	r.Zstyler
r
rr/szAbstractFormatter.push_styler0cCs$|j|d�=|j�t|j��dSr)r@rr�r�r1r
r
rr3!szAbstractFormatter.pop_stylecCs$||_|_d|_|_|_dS�Nr)rArErCrDrFr4r
r
rr6%sz"AbstractFormatter.assert_line_data)N)r0)r0)r7r8r9r:rrrrrrNrQrRrrrr"r#r%r&r(r)r,r/r3r6r
r
r
rr;@s,

	
	
	
r;c@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)raMinimal writer interface to use in testing & inheritance.

    A writer which only provides the interface definition; no actions are
    taken on any methods.  This should be the base class for all writers
    which do not need to inherit any implementation methods.

    cCsdSrr
rr
r
rr2rzNullWriter.__init__cCsdSrr
rr
r
r�flush3rzNullWriter.flushcCsdSrr
r r
r
rrp4rzNullWriter.new_alignmentcCsdSrr
ryr
r
rrt5rzNullWriter.new_fontcCsdSrr
�r	r'�levelr
r
rr}6rzNullWriter.new_margincCsdSrr
r*r
r
rr�7rzNullWriter.new_spacingcCsdSrr
r-r
r
rr�8rzNullWriter.new_stylescCsdSrr
r
r
r
rrI9rzNullWriter.send_paragraphcCsdSrr
rr
r
rrH:rzNullWriter.send_line_breakcOsdSrr
rr
r
rrJ;rzNullWriter.send_hor_rulecCsdSrr
rr
r
rrM<rzNullWriter.send_label_datacCsdSrr
rr
r
rrl=rzNullWriter.send_flowing_datacCsdSrr
rr
r
rrn>rzNullWriter.send_literal_dataN)r7r8r9r:rr�rprtr}r�r�rIrHrJrMrlrnr
r
r
rr*src@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�AbstractWriterz�A writer which can be used in debugging formatters, but not much else.

    Each method simply announces itself by printing its name and
    arguments on standard output.

    cCstd|f�dS)Nznew_alignment(%r)��printr r
r
rrpIszAbstractWriter.new_alignmentcCstd|f�dS)Nznew_font(%r)r�ryr
r
rrtLszAbstractWriter.new_fontcCstd||f�dS)Nznew_margin(%r, %d)r�r�r
r
rr}OszAbstractWriter.new_margincCstd|f�dS)Nznew_spacing(%r)r�r*r
r
rr�RszAbstractWriter.new_spacingcCstd|f�dS)Nznew_styles(%r)r�r-r
r
rr�UszAbstractWriter.new_stylescCstd|f�dS)Nzsend_paragraph(%r)r�r
r
r
rrIXszAbstractWriter.send_paragraphcCstd�dS)Nzsend_line_break()r�rr
r
rrH[szAbstractWriter.send_line_breakcOstd�dS)Nzsend_hor_rule()r�rr
r
rrJ^szAbstractWriter.send_hor_rulecCstd|f�dS)Nzsend_label_data(%r)r�rr
r
rrMaszAbstractWriter.send_label_datacCstd|f�dS)Nzsend_flowing_data(%r)r�rr
r
rrldsz AbstractWriter.send_flowing_datacCstd|f�dS)Nzsend_literal_data(%r)r�rr
r
rrngsz AbstractWriter.send_literal_dataN)r7r8r9r:rprtr}r�r�rIrHrJrMrlrnr
r
r
rr�Asr�c@sJeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�
DumbWritera;Simple writer class which writes output on the file object passed in
    as the file parameter or, if file is omitted, on standard output.  The
    output is simply word-wrapped to the number of columns specified by
    the maxcol parameter.  This class is suitable for reflowing a sequence
    of paragraphs.

    N�HcCs(|ptj|_||_t�|�|��dSr)�sys�stdout�file�maxcolrr�reset)r	r�r�r
r
rrts
zDumbWriter.__init__cCsd|_d|_dSr�)�col�atbreakrr
r
rr�zszDumbWriter.resetcCs |j�d|�d|_d|_dS�Nrmr�r��writer�r�r
r
r
rrI~szDumbWriter.send_paragraphcCs|j�d�d|_d|_dSr�r�rr
r
rrH�szDumbWriter.send_line_breakcOs:|j�d�|j�d|j�|j�d�d|_d|_dS)Nrm�-r)r�r�r�r�r�rr
r
rrJ�s
zDumbWriter.send_hor_rulecCsV|j�|�|�d�}|dkr4d|_||dd�}|��}|jt|�|_d|_dS)Nrmrr0)r�r��rfindr��
expandtabsr~r�)r	rr[r
r
rrn�s
zDumbWriter.send_literal_datacCs�|sdS|jp|d��}|j}|j}|jj}|��D]N}|rl|t|�|kr\|d�d}n|d�|d}||�|t|�}d}q6||_|d��|_dS)Nrrmrhr0rg)r�rir�r�r�r�rkr~)r	rr�r�r�r�Zwordr
r
rrl�s$zDumbWriter.send_flowing_data)Nr�)r7r8r9r:rr�rIrHrJrnrlr
r
r
rr�ks

r�cCs�t�}t|�}|dk	r t|�}n$tjdd�r>ttjd�}ntj}z,|D]"}|dkrb|�d�qJ|�|�qJW5|tjk	r�|��X|�d�dS)Nr0rmr)	r�r;�openr��argv�stdin�closerr)r��w�f�fp�liner
r
r�test�s


r��__main__)N)
r:r��warnings�warn�DeprecationWarningrsrr;rr�r�r�r7r
r
r
r�<module>s�"k*C


Zerion Mini Shell 1.0