a �DOg';�@s�ddlZddlZejdedd�dZGdd�d�ZGdd�d�ZGd d �d �ZGd d �d e�ZGd d�de�Z ddd�Z e dkr�e �dS)�Nz"the formatter module is deprecated�)� stacklevelc@s�eZdZd'dd�Zdd�Zdd�Zdd �Zd(d d �Zd d �Zdd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd�Zdd�Zd d!�Zd)d#d$�Zd*d%d&�ZdS)+� NullFormatterNcCs|durt�}||_dS�N)� NullWriter�writer��selfr�r �!/usr/lib64/python3.9/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__r rrrrrrrr"r#r%r&r(r)r,r/r3r6r r r r rs$   rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd-d d �Zd d �Zdd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd.d)d*�Zd/d+d,�Zd S)0�AbstractFormattercCsR||_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 r r NszAbstractFormatter.__init__cCs`|js|j��d|_|j|krD|jsD|j�||j�||_d|_d|_|_|_d|_dS�Nrr0) rDr�send_line_breakrErC�send_paragraphr@rBrAr r r r r]s zAbstractFormatter.end_paragraphcCs8|js"|js"|j��d|_|_d|_|_d|_dSrF)rDrBrrGrErCr@rArr r r rhs     z AbstractFormatter.add_line_breakcOsJ|js|j��|jj|i|��d|_|_d|_|_|_|_dSr;) rDrrG� send_hor_ruler@rErBrArCrr r r ros   zAbstractFormatter.add_hor_ruleNcCs�|js |js|j��|js0|j�|r*dp,d�t|t�rP|j�|� ||��n |j�|�d|_ |_|_|_d|_ |_ dSr;) rErDrrGrBrH� isinstance�str�send_label_data�format_counterr@rArCrr r r rvs    z AbstractFormatter.add_label_datacCstd}|D]f}|dkr"|d|}q|dvrD|dkrn||�||�}q|dvrf|dkrn||�||�}q||}q|S)N��1z%dZaArZiI)� format_letter� format_roman)r rr�label�cr r r rM�s z AbstractFormatter.format_countercCs<d}|dkr8t|dd�\}}tt|�|�}||}q|S)NrNrr0�)�divmod�chr�ord)r �caserrRr$�sr r r rP�s  zAbstractFormatter.format_letterc Cs�gd�}gd�}d\}}|dkr�t|d�\}}|dkrP||||d|}nT|dkrn|||||}n6|d kr�||}|d }nd }||||}||}|d}q|d kr�|��S|S) N)�ir$rS�m)�v�l�d)rNrr� � r0��rN�I)rU�upper) r rXrZonesZfivesrR�indexr$rYr r r rQ�s&  zAbstractFormatter.format_romancCs�|sdS|dd���}|dd���}d�|���}|jrD|sDdS|sN|jrv|sh|jsdd|_d|_dS|jsvd|}d|_|_|_|_|_||_|j � |�dS)Nr0������ r) �isspace�join�splitr@rArCrDrBrEr�send_flowing_data)r rZprespaceZ postspacer r r r�s&  �z"AbstractFormatter.add_flowing_datacCsZ|sdS|jr|j�d�|dd�dk|_d|_|_|_|_|_|j�|�dS)Nrgrf� r) rArrkrDr@rBrCrE�send_literal_datarr r r r�s �z"AbstractFormatter.add_literal_datacCs:|jr6d|_|_|_|_|_d|_|j�d�dS�Nrr0rg)rArDrBrCrEr@rrkrr r r r�s �z!AbstractFormatter.flush_softspacecCs@|r.||jkr.|j�|�||_|j�|�n|j�|j�dSr)r!r� new_alignmentr<�appendr r r r r"�s  z AbstractFormatter.push_alignmentcCsH|jr|jd=|jr2|jd|_}|j�|�nd|_|j�d�dS�Nrf)r<r!rror r r r r#�szAbstractFormatter.pop_alignmentc Cs�|\}}}}|jr6d|_|_|_d|_|j�d�|jr~|jd\}}}} |turZ|}|turf|}|turr|}|tur~| }||||f}|j�|�|j� |�dS)Nrr0rgrf) rArDrBr@rrkr=�AS_ISrp�new_font) r �font�sizerZ�b�ttZcsizeZci�cbZcttr r r r%�s        zAbstractFormatter.push_fontcCs4|jr|jd=|jr |jd}nd}|j�|�dSrq)r=rrs�r rtr r r r&�s  zAbstractFormatter.pop_fontcCsB|j�|�dd�|jD�}|s,|r,|d}|j�|t|��dS)NcSsg|] }|r|�qSr r ��.0r[r r r � rz1AbstractFormatter.push_margin..rf)r>rpr� new_margin�len)r r'�fstackr r r r(s  zAbstractFormatter.push_margincCsF|jr|jd=dd�|jD�}|r,|d}nd}|j�|t|��dS)NrfcSsg|] }|r|�qSr r rzr r r r| rz0AbstractFormatter.pop_margin..)r>rr}r~)r rr'r r r r) s zAbstractFormatter.pop_margincCs||_|j�|�dSr)r+r� new_spacingr*r r r r,szAbstractFormatter.set_spacingcGsV|jr*d|_|_|_d|_|j�d�|D]}|j�|�q.|j�t |j��dSrn) rArDrBr@rrkr?rp� new_styles�tuple)r r.�styler r r r/s zAbstractFormatter.push_styler0cCs$|j| d�=|j�t|j��dSr)r?rr�r�r1r r r r3!szAbstractFormatter.pop_stylecCs$| |_|_d|_|_|_dS�Nr)r@rDrBrCrEr4r r r r6%sz"AbstractFormatter.assert_line_data)N)r0)r0)r7r8r9r rrrrrMrPrQrrrr"r#r%r&r(r)r,r/r3r6r r r r r:@s*        r:c@steZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�ZdS)rcCsdSrr rr r r r 2rzNullWriter.__init__cCsdSrr rr r r �flush3rzNullWriter.flushcCsdSrr r r r r ro4rzNullWriter.new_alignmentcCsdSrr ryr r r rs5rzNullWriter.new_fontcCsdSrr �r r'�levelr r r r}6rzNullWriter.new_margincCsdSrr r*r r r r�7rzNullWriter.new_spacingcCsdSrr r-r r r r�8rzNullWriter.new_stylescCsdSrr r r r r rH9rzNullWriter.send_paragraphcCsdSrr rr r r rG:rzNullWriter.send_line_breakcOsdSrr rr r r rI;rzNullWriter.send_hor_rulecCsdSrr rr r r rL<rzNullWriter.send_label_datacCsdSrr rr r r rk=rzNullWriter.send_flowing_datacCsdSrr rr r r rm>rzNullWriter.send_literal_dataN)r7r8r9r r�rorsr}r�r�rHrGrIrLrkrmr r r r r*src@sdeZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dd�Z dd�Z dS)�AbstractWritercCstd|f�dS)Nznew_alignment(%r)��printr r r r roIszAbstractWriter.new_alignmentcCstd|f�dS)Nz new_font(%r)r�ryr r r rsLszAbstractWriter.new_fontcCstd||f�dS)Nznew_margin(%r, %d)r�r�r r r r}OszAbstractWriter.new_margincCstd|f�dS)Nznew_spacing(%r)r�r*r r r r�RszAbstractWriter.new_spacingcCstd|f�dS)Nznew_styles(%r)r�r-r r r r�UszAbstractWriter.new_stylescCstd|f�dS)Nzsend_paragraph(%r)r�r r r r rHXszAbstractWriter.send_paragraphcCs td�dS)Nzsend_line_break()r�rr r r rG[szAbstractWriter.send_line_breakcOs td�dS)Nzsend_hor_rule()r�rr r r rI^szAbstractWriter.send_hor_rulecCstd|f�dS)Nzsend_label_data(%r)r�rr r r rLaszAbstractWriter.send_label_datacCstd|f�dS)Nzsend_flowing_data(%r)r�rr r r rkdsz AbstractWriter.send_flowing_datacCstd|f�dS)Nzsend_literal_data(%r)r�rr r r rmgsz AbstractWriter.send_literal_dataN)r7r8r9rorsr}r�r�rHrGrIrLrkrmr r r r r�Asr�c@sFeZdZddd�Zdd�Zdd�Zd d �Zd d �Zd d�Zdd�Z dS)� DumbWriterN�HcCs(|ptj|_||_t�|�|��dSr)�sys�stdout�file�maxcolrr �reset)r r�r�r r r r ts  zDumbWriter.__init__cCsd|_d|_dSr�)�col�atbreakrr r r r�zszDumbWriter.resetcCs |j�d|�d|_d|_dS�Nrlr�r��writer�r�r r r r rH~szDumbWriter.send_paragraphcCs|j�d�d|_d|_dSr�r�rr r r rG�s zDumbWriter.send_line_breakcOs:|j�d�|j�d|j�|j�d�d|_d|_dS)Nrl�-r)r�r�r�r�r�rr r r rI�s   zDumbWriter.send_hor_rulecCsV|j�|�|�d�}|dkr4d|_||dd�}|��}|jt|�|_d|_dS)Nrlrr0)r�r��rfindr�� expandtabsr~r�)r rrZr r r rm�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)Nrrlrgr0rf)r�rhr�r�r�r�rjr~)r rr�r�r�r�Zwordr r r rk�s"  zDumbWriter.send_flowing_data)Nr�) r7r8r9r r�rHrGrIrmrkr r r r r�ks  r�cCs�t�}t|�}|dur t|�}n$tjdd�r>ttjd�}ntj}z>|D]"}|dkrb|�d�qJ|�|�qJW|tjur�|��n|tjur�|��0|�d�dS)Nr0rlr) r�r:�openr��argv�stdinrr�close)r��w�f�fp�liner r r �test�s"    �  r��__main__)N) r��warnings�warn�DeprecationWarningrrrr:rr�r�r�r7r r r r �s�"k*C