ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python37/lib64/python3.7/__pycache__/formatter.cpython-37.pyc

B

� f';�@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�./opt/alt/python37/lib64/python3.7/formatter.py�__init__)szNullFormatter.__init__cCsdS)Nr)r�	blanklinerrr	�
end_paragraph-�zNullFormatter.end_paragraphcCsdS)Nr)rrrr	�add_line_break.r
zNullFormatter.add_line_breakcOsdS)Nr)r�args�kwrrr	�add_hor_rule/r
zNullFormatter.add_hor_rulecCsdS)Nr)r�format�counterrrrr	�add_label_data0r
zNullFormatter.add_label_datacCsdS)Nr)r�datarrr	�add_flowing_data1r
zNullFormatter.add_flowing_datacCsdS)Nr)rrrrr	�add_literal_data2r
zNullFormatter.add_literal_datacCsdS)Nr)rrrr	�flush_softspace3r
zNullFormatter.flush_softspacecCsdS)Nr)r�alignrrr	�push_alignment4r
zNullFormatter.push_alignmentcCsdS)Nr)rrrr	�
pop_alignment5r
zNullFormatter.pop_alignmentcCsdS)Nr)r�xrrr	�	push_font6r
zNullFormatter.push_fontcCsdS)Nr)rrrr	�pop_font7r
zNullFormatter.pop_fontcCsdS)Nr)r�marginrrr	�push_margin8r
zNullFormatter.push_margincCsdS)Nr)rrrr	�
pop_margin9r
zNullFormatter.pop_margincCsdS)Nr)r�spacingrrr	�set_spacing:r
zNullFormatter.set_spacingcGsdS)Nr)r�stylesrrr	�
push_style;r
zNullFormatter.push_style�cCsdS)Nr)r�nrrr	�	pop_style<r
zNullFormatter.pop_stylecCsdS)Nr)r�flagrrr	�assert_line_data=r
zNullFormatter.assert_line_data)N)N)r&)r&)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrrrrrr r!r#r%r(r*rrrr	rs&	


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)Nr&r)
rr�align_stack�
font_stack�margin_stackr"�style_stack�nospace�	softspace�para_end�parskip�
hard_break�
have_label)rrrrr	r
NszAbstractFormatter.__init__cCs`|js|j��d|_|j|krD|jsD|j�||j�||_d|_d|_|_|_d|_dS)Nrr&)	r8r�send_line_breakr9r7�send_paragraphr4r6r5)rrrrr	r]s
zAbstractFormatter.end_paragraphcCs8|js"|js"|j��d|_|_d|_|_d|_dS)Nrr&)r8r6rr:r9r7r4r5)rrrr	rhs

z AbstractFormatter.add_line_breakcOsF|js|j��|jj||�d|_|_d|_|_|_|_dS)Nr&r)	r8rr:�
send_hor_ruler4r9r6r5r7)rrrrrr	ros

zAbstractFormatter.add_hor_ruleNcCs�|js|js|j��|js0|j�|r*dp,d�t|t�rP|j�|�	||��n|j�|�d|_
|_|_|_d|_|_dS)Nr&r)
r9r8rr:r6r;�
isinstance�str�send_label_data�format_counterr4r5r7)rrrrrrr	rvs

z AbstractFormatter.add_label_datacCsxd}xn|D]f}|dkr$|d|}q
|dkrF|dkrp||�||�}q
|dkrh|dkrp||�||�}q
||}q
W|S)N��1z%dZaArZiI)�
format_letter�format_roman)rrr�label�crrr	r@�s
z AbstractFormatter.format_countercCs@d}x6|dkr:t|dd�\}}tt|�|�}||}qW|S)NrArr&�)�divmod�chr�ord)r�caserrEr�srrr	rC�s
zAbstractFormatter.format_letterc	Cs�ddddg}dddg}d\}}x�|d	kr�t|d
�\}}|dkrX||||d|}nT|d
krv|||||}n6|dkr�||}|d}nd}||||}||}|d}q W|dkr�|��S|S)N�irrF�m�v�l�d)rArr�
�	r&��rA�I)rH�upper)	rrKrZonesZfivesrE�indexrrLrrr	rD�s&


zAbstractFormatter.format_romancCs�|sdS|dd���}|dd���}d�|���}|jrD|sDdS|sN|jrv|sh|jsdd|_d|_dS|jsvd|}d|_|_|_|_|_||_|j	�
|�dS)Nr&���� r)�isspace�join�splitr4r5r7r8r6r9r�send_flowing_data)rrZprespaceZ	postspacerrr	r�s$

z"AbstractFormatter.add_flowing_datacCsZ|sdS|jr|j�d�|dd�dk|_d|_|_|_|_|_|j�|�dS)NrZrY�
r)	r5rr^r8r4r6r7r9�send_literal_data)rrrrr	r�sz"AbstractFormatter.add_literal_datacCs:|jr6d|_|_|_|_|_d|_|j�d�dS)Nrr&rZ)r5r8r6r7r9r4rr^)rrrr	r�sz!AbstractFormatter.flush_softspacecCs@|r.||jkr.|j�|�||_|j�|�n|j�|j�dS)N)rr�
new_alignmentr0�append)rrrrr	r�s
z AbstractFormatter.push_alignmentcCsH|jr|jd=|jr2|jd|_}|j�|�nd|_|j�d�dS)NrY)r0rrra)rrrrr	r�szAbstractFormatter.pop_alignmentc
Cs�|\}}}}|jr6d|_|_|_d|_|j�d�|jr~|jd\}}}}	|tkrZ|}|tkrf|}|tkrr|}|tkr~|	}||||f}|j�|�|j�	|�dS)Nrr&rZrY)
r5r8r6r4rr^r1�AS_ISrb�new_font)
r�font�sizerM�bZttZcsizeZci�cbZcttrrr	r�s$zAbstractFormatter.push_fontcCs4|jr|jd=|jr |jd}nd}|j�|�dS)NrY)r1rrd)rrerrr	r�szAbstractFormatter.pop_fontcCsB|j�|�dd�|jD�}|s,|r,|d}|j�|t|��dS)NcSsg|]}|r|�qSrr)�.0rNrrr	�
<listcomp>sz1AbstractFormatter.push_margin.<locals>.<listcomp>rY)r2rbr�
new_margin�len)rr�fstackrrr	r s
zAbstractFormatter.push_margincCsF|jr|jd=dd�|jD�}|r,|d}nd}|j�|t|��dS)NrYcSsg|]}|r|�qSrr)rirNrrr	rj
sz0AbstractFormatter.pop_margin.<locals>.<listcomp>)r2rrkrl)rrmrrrr	r!
s
zAbstractFormatter.pop_margincCs||_|j�|�dS)N)r"r�new_spacing)rr"rrr	r#szAbstractFormatter.set_spacingcGsZ|jr*d|_|_|_d|_|j�d�x|D]}|j�|�q0W|j�t	|j��dS)Nrr&rZ)
r5r8r6r4rr^r3rb�
new_styles�tuple)rr$Zstylerrr	r%s
zAbstractFormatter.push_styler&cCs$|j|d�=|j�t|j��dS)N)r3rrorp)rr'rrr	r(!szAbstractFormatter.pop_stylecCs$||_|_d|_|_|_dS)Nr)r4r8r6r7r9)rr)rrr	r*%sz"AbstractFormatter.assert_line_data)N)r&)r&)r+r,r-r.r
rrrrr@rCrDrrrrrrrr r!r#r%r(r*rrrr	r/@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.

    cCsdS)Nr)rrrr	r
2r
zNullWriter.__init__cCsdS)Nr)rrrr	�flush3r
zNullWriter.flushcCsdS)Nr)rrrrr	ra4r
zNullWriter.new_alignmentcCsdS)Nr)rrerrr	rd5r
zNullWriter.new_fontcCsdS)Nr)rr�levelrrr	rk6r
zNullWriter.new_margincCsdS)Nr)rr"rrr	rn7r
zNullWriter.new_spacingcCsdS)Nr)rr$rrr	ro8r
zNullWriter.new_stylescCsdS)Nr)rrrrr	r;9r
zNullWriter.send_paragraphcCsdS)Nr)rrrr	r::r
zNullWriter.send_line_breakcOsdS)Nr)rrrrrr	r<;r
zNullWriter.send_hor_rulecCsdS)Nr)rrrrr	r?<r
zNullWriter.send_label_datacCsdS)Nr)rrrrr	r^=r
zNullWriter.send_flowing_datacCsdS)Nr)rrrrr	r`>r
zNullWriter.send_literal_dataN)r+r,r-r.r
rqrardrkrnror;r:r<r?r^r`rrrr	r*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))�print)rrrrr	raIszAbstractWriter.new_alignmentcCstd|f�dS)Nznew_font(%r))rt)rrerrr	rdLszAbstractWriter.new_fontcCstd||f�dS)Nznew_margin(%r, %d))rt)rrrrrrr	rkOszAbstractWriter.new_margincCstd|f�dS)Nznew_spacing(%r))rt)rr"rrr	rnRszAbstractWriter.new_spacingcCstd|f�dS)Nznew_styles(%r))rt)rr$rrr	roUszAbstractWriter.new_stylescCstd|f�dS)Nzsend_paragraph(%r))rt)rrrrr	r;XszAbstractWriter.send_paragraphcCstd�dS)Nzsend_line_break())rt)rrrr	r:[szAbstractWriter.send_line_breakcOstd�dS)Nzsend_hor_rule())rt)rrrrrr	r<^szAbstractWriter.send_hor_rulecCstd|f�dS)Nzsend_label_data(%r))rt)rrrrr	r?aszAbstractWriter.send_label_datacCstd|f�dS)Nzsend_flowing_data(%r))rt)rrrrr	r^dsz AbstractWriter.send_flowing_datacCstd|f�dS)Nzsend_literal_data(%r))rt)rrrrr	r`gsz AbstractWriter.send_literal_dataN)r+r,r-r.rardrkrnror;r:r<r?r^r`rrrr	rsAsrsc@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�|�|��dS)N)�sys�stdout�file�maxcolrr
�reset)rryrzrrr	r
ts
zDumbWriter.__init__cCsd|_d|_dS)Nr)�col�atbreak)rrrr	r{zszDumbWriter.resetcCs |j�d|�d|_d|_dS)Nr_r)ry�writer|r})rrrrr	r;~szDumbWriter.send_paragraphcCs|j�d�d|_d|_dS)Nr_r)ryr~r|r})rrrr	r:�szDumbWriter.send_line_breakcOs:|j�d�|j�d|j�|j�d�d|_d|_dS)Nr_�-r)ryr~rzr|r})rrrrrr	r<�s
zDumbWriter.send_hor_rulecCsV|j�|�|�d�}|dkr4d|_||dd�}|��}|jt|�|_d|_dS)Nr_rr&)ryr~�rfindr|�
expandtabsrlr})rrrMrrr	r`�s
zDumbWriter.send_literal_datacCs�|sdS|jp|d��}|j}|j}|jj}xZ|��D]N}|rn|t|�|kr^|d�d}n|d�|d}||�|t|�}d}q8W||_|d��|_dS)Nrr_rZr&rY)r}r[r|rzryr~r]rl)rrr}r|rzr~Zwordrrr	r^�s$zDumbWriter.send_flowing_data)Nrv)r+r,r-r.r
r{r;r:r<r`r^rrrr	ruks

rucCs�t�}t|�}|dk	r t|�}n$tjdd�r>ttjd�}ntj}z0x*|D]"}|dkrd|�d�qL|�|�qLWWd|tjk	r�|��X|�d�dS)Nr&r_r)	rur/�openrw�argv�stdinrr�close)ry�w�f�fp�linerrr	�test�s



r��__main__)N)
r.rw�warnings�warn�DeprecationWarningrcrr/rrsrur�r+rrrr	�<module>s"k*C


Zerion Mini Shell 1.0