f _';c@sddlZddlZejdedddZGdddZGdddZGd d d ZGd d d eZGd ddeZ dddZ e dkre dS)Nz"the formatter module is deprecatedi)Z stacklevelc@seZdZd'ddZddZddZdd Zd(d d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd)d#d$Zd*d%d&ZdS)+ NullFormatterNcCs|durt}||_dSN) NullWriterwriterselfrr"/usr/lib64/python3.10/formatter.py__init__)szNullFormatter.__init__cCdSrrr blanklinerrr end_paragraph-zNullFormatter.end_paragraphcCr rrrrrradd_line_break.rzNullFormatter.add_line_breakcOr rrrZargsZkwrrr add_hor_rule/rzNullFormatter.add_hor_rulecCr rrrformatcounterr rrradd_label_data0rzNullFormatter.add_label_datacCr rrrdatarrradd_flowing_data1rzNullFormatter.add_flowing_datacCr rrrrrradd_literal_data2rzNullFormatter.add_literal_datacCr rrrrrrflush_softspace3rzNullFormatter.flush_softspacecCr rrralignrrrpush_alignment4rzNullFormatter.push_alignmentcCr rrrrrr pop_alignment5rzNullFormatter.pop_alignmentcCr rr)rxrrr push_font6rzNullFormatter.push_fontcCr rrrrrrpop_font7rzNullFormatter.pop_fontcCr rr)rmarginrrr push_margin8rzNullFormatter.push_margincCr rrrrrr pop_margin9rzNullFormatter.pop_margincCr rrrspacingrrr set_spacing:rzNullFormatter.set_spacingcGr rrrstylesrrr push_style;rzNullFormatter.push_stylecCr rrrZnrrr pop_style<rzNullFormatter.pop_stylecCr rrrZflagrrrassert_line_data=rzNullFormatter.assert_line_datarrr,r1)__name__ __module__ __qualname__r r rrrrrrrrr!r"r$r%r(r+r.r0rrrrrs$   rc@seZdZddZddZddZddZd-d d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd.d)d*Zd/d+d,Zd S)0AbstractFormattercCsR||_d|_g|_g|_g|_d|_g|_d|_d|_d|_ d|_ d|_ d|_ dSNr,r) rr align_stack font_stack margin_stackr' style_stacknospace softspacepara_endparskip hard_break have_labelrrrrr NszAbstractFormatter.__init__cCs`|js|jd|_|j|krD|jsD|j||j||_d|_d|_|_|_d|_dSNrr,) r?rsend_line_breakr@r>send_paragraphr;r=r<r rrrr ]s zAbstractFormatter.end_paragraphcCs8|js"|js"|jd|_|_d|_|_d|_dSrA)r?r=rrBr@r>r;r<rrrrrhs     z AbstractFormatter.add_line_breakcOsJ|js|j|jj|i|d|_|_d|_|_|_|_dSr6) r?rrB send_hor_ruler;r@r=r<r>rrrrros   zAbstractFormatter.add_hor_ruleNcCs|js |js|j|js0|j|r*dp,dt|trP|j| ||n |j|d|_ |_|_|_d|_ |_ dSr6) r@r?rrBr=rCZ isinstanceZstrsend_label_dataformat_counterr;r<r>rrrrrvs    z AbstractFormatter.add_label_datacCstd}|D]f}|dkr"|d|}q|dvrD|dkrn||||}q|dvrf|dkrn||||}q||}q|S)NZ1z%dZaArZiI) format_letter format_roman)rrrlabelcrrrrFs z AbstractFormatter.format_countercCs<d}|dkr8t|dd\}}tt||}||}q|S)NrGrr,i)divmodZchrZord)rcaserrJr srrrrHs  zAbstractFormatter.format_letterc Csgd}gd}d\}}|dkrt|d\}}|dkrP||||d|}nT|dkrn|||||}n6|d kr||}|d }nd }||||}||}|d}q|d kr|S|S) N)ir rKm)ZvZlZd)rGrri i r,iirGZI)rLZupper) rrMrZonesZfivesrJZindexr rNrrrrIs&  zAbstractFormatter.format_romancCs|sdS|dd}|dd}d|}|jrD|sDdS|sN|jrv|sh|jsdd|_d|_dS|jsvd|}d|_|_|_|_|_||_|j |dS)Nr, r) isspaceZjoinsplitr;r<r>r?r=r@rsend_flowing_data)rrZprespaceZ postspacerrrrs&  z"AbstractFormatter.add_flowing_datacCsZ|sdS|jr|jd|dddk|_d|_|_|_|_|_|j|dS)NrRrQ r) r<rrUr?r;r=r>r@send_literal_datarrrrrs z"AbstractFormatter.add_literal_datacCs:|jr6d|_|_|_|_|_d|_|jddSNrr,rR)r<r?r=r>r@r;rrUrrrrrs z!AbstractFormatter.flush_softspacecCs@|r.||jkr.|j|||_|j|n|j|jdSr)rr new_alignmentr7appendrrrrrs  z AbstractFormatter.push_alignmentcCsH|jr|jd=|jr2|jd|_}|j|nd|_|jddSNrQ)r7rrrYrrrrrszAbstractFormatter.pop_alignmentc Cs|\}}}}|jr6d|_|_|_d|_|jd|jr~|jd\}}}} |turZ|}|turf|}|turr|}|tur~| }||||f}|j||j |dS)Nrr,rRrQ) r<r?r=r;rrUr8AS_ISrZnew_font) rfontZsizerOZbZttZcsizeZciZcbZcttrrrr!s        zAbstractFormatter.push_fontcCs4|jr|jd=|jr |jd}nd}|j|dSr[)r8rr]rr^rrrr"s  zAbstractFormatter.pop_fontcCsB|j|dd|jD}|s,|r,|d}|j|t|dS)NcSg|] }|r|qSrrZ.0rPrrr rz1AbstractFormatter.push_margin..rQ)r9rZr new_marginlen)rr#fstackrrrr$s  zAbstractFormatter.push_margincCsF|jr|jd=dd|jD}|r,|d}nd}|j|t|dS)NrQcSr`rrrarrrrb rz0AbstractFormatter.pop_margin..)r9rrcrd)rrer#rrrr% s zAbstractFormatter.pop_margincCs||_|j|dSr)r'r new_spacingr&rrrr(zAbstractFormatter.set_spacingcGsV|jr*d|_|_|_d|_|jd|D]}|j|q.|jt |jdSrX) r<r?r=r;rrUr:rZ new_stylestuple)rr*Zstylerrrr+s zAbstractFormatter.push_styler,cCs$|j| d=|jt|jdSr)r:rrhrir-rrrr.!zAbstractFormatter.pop_stylecCs$| |_|_d|_|_|_dSNr)r;r?r=r>r@r/rrrr0%rjz"AbstractFormatter.assert_line_datarr1r1)r2r3r4r r rrrrFrHrIrrrrrr!r"r$r%r(r+r.r0rrrrr5@s*        r5c@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)rcCr rrrrrrr 2rzNullWriter.__init__cCr rrrrrrflush3rzNullWriter.flushcCr rrrrrrrY4rzNullWriter.new_alignmentcCr rrr_rrrr]5rzNullWriter.new_fontcCr rrrr#Zlevelrrrrc6rzNullWriter.new_margincCr rrr&rrrrf7rzNullWriter.new_spacingcCr rrr)rrrrh8rzNullWriter.new_stylescCr rrr rrrrC9rzNullWriter.send_paragraphcCr rrrrrrrB:rzNullWriter.send_line_breakcOr rrrrrrrD;rzNullWriter.send_hor_rulecCr rrrrrrrE<rzNullWriter.send_label_datacCr rrrrrrrU=rzNullWriter.send_flowing_datacCr rrrrrrrW>rzNullWriter.send_literal_dataN)r2r3r4r rlrYr]rcrfrhrCrBrDrErUrWrrrrr*src@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)AbstractWritercCtd|fdS)Nznew_alignment(%r)ZprintrrrrrYIzAbstractWriter.new_alignmentcCro)Nz new_font(%r)rpr_rrrr]LrqzAbstractWriter.new_fontcCstd||fdS)Nznew_margin(%r, %d)rprmrrrrcOrqzAbstractWriter.new_margincCro)Nznew_spacing(%r)rpr&rrrrfRrqzAbstractWriter.new_spacingcCro)Nznew_styles(%r)rpr)rrrrhUrqzAbstractWriter.new_stylescCro)Nzsend_paragraph(%r)rpr rrrrCXrqzAbstractWriter.send_paragraphcC tddS)Nzsend_line_break()rprrrrrB[rqzAbstractWriter.send_line_breakcOrr)Nzsend_hor_rule()rprrrrrD^rqzAbstractWriter.send_hor_rulecCro)Nzsend_label_data(%r)rprrrrrEarqzAbstractWriter.send_label_datacCro)Nzsend_flowing_data(%r)rprrrrrUdrqz AbstractWriter.send_flowing_datacCro)Nzsend_literal_data(%r)rprrrrrWgrqz AbstractWriter.send_literal_dataN)r2r3r4rYr]rcrfrhrCrBrDrErUrWrrrrrnAsrnc@sFeZdZdddZddZddZd d Zd d Zd dZddZ dS) DumbWriterNHcCs(|ptj|_||_t||dSr)sysZstdoutfilemaxcolrr reset)rrvrwrrrr ts  zDumbWriter.__init__cCsd|_d|_dSrk)colatbreakrrrrrxzrgzDumbWriter.resetcCs |jd|d|_d|_dSNrVrrvwriteryrzr rrrrC~szDumbWriter.send_paragraphcCs|jdd|_d|_dSr{r|rrrrrBs zDumbWriter.send_line_breakcOs:|jd|jd|j|jdd|_d|_dS)NrVz-r)rvr}rwryrzrrrrrDs   zDumbWriter.send_hor_rulecCsV|j||d}|dkr4d|_||dd}|}|jt||_d|_dS)NrVrr,)rvr}ZrfindryZ expandtabsrdrz)rrrOrrrrWs  zDumbWriter.send_literal_datacCs|sdS|jp|d}|j}|j}|jj}|D]N}|rl|t||kr\|dd}n|d|d}|||t|}d}q6||_|d|_dS)NrrVrRr,rQ)rzrSryrwrvr}rTrd)rrrzryrwr}ZwordrrrrUs"  zDumbWriter.send_flowing_data)Nrt) r2r3r4r rxrCrBrDrWrUrrrrrsks  rscCst}t|}|dur t|}n$tjddr>ttjd}ntj}z>|D]"}|dkrb|dqJ||qJW|tjur|n|tjur|0|ddS)Nr,rVr) rsr5ZopenruZargvZstdinr rZclose)rvZwZfZfpZlinerrrtests"     r~Z__main__r) ruZwarningsZwarnZDeprecationWarningr\rr5rrnrsr~r2rrrrZs"k*C