U AT^';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|dkrt}||_dSN) NullWriterwriterselfrr!/usr/lib64/python3.8/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_breakcOsF|js|j|jj||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|dkrD|dkrn||||}q|dkrf|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 Csddddg}dddg}d\}}|d krt|d \}}|d krV||||d |}nT|d krt|||||}n6|dkr||}|d}nd}||||}||}|d }q|dkr|S|S)Nir rKmZvZlZd)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;rrUrrrrrsz!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\}}}} |tkrZ|}|tkrf|}|tkrr|}|tkr~| }||||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 z1AbstractFormatter.push_margin..rQ)r9rZr new_marginlen)rr#fstackrrrr$s  zAbstractFormatter.push_margincCsF|jr|jd=dd|jD}|r,|d}nd}|j|t|dS)NrQcSr`rrrarrrrb rcz0AbstractFormatter.pop_margin..)r9rrdre)rrfr#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:rrirjr-rrrr.!zAbstractFormatter.pop_stylecCs$| |_|_d|_|_|_dSNr)r;r?r=r>r@r/rrrr0%rkz"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#Zlevelrrrrd6rzNullWriter.new_margincCr rrr&rrrrg7rzNullWriter.new_spacingcCr rrr)rrrri8rzNullWriter.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 rmrYr]rdrgrirCrBrDrErUrWrrrrr*src@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)AbstractWritercCtd|fdS)Nznew_alignment(%r)ZprintrrrrrYIzAbstractWriter.new_alignmentcCrp)Nz new_font(%r)rqr_rrrr]LrrzAbstractWriter.new_fontcCstd||fdS)Nznew_margin(%r, %d)rqrnrrrrdOrrzAbstractWriter.new_margincCrp)Nznew_spacing(%r)rqr&rrrrgRrrzAbstractWriter.new_spacingcCrp)Nznew_styles(%r)rqr)rrrriUrrzAbstractWriter.new_stylescCrp)Nzsend_paragraph(%r)rqr rrrrCXrrzAbstractWriter.send_paragraphcC tddS)Nzsend_line_break()rqrrrrrB[rrzAbstractWriter.send_line_breakcOrs)Nzsend_hor_rule()rqrrrrrD^rrzAbstractWriter.send_hor_rulecCrp)Nzsend_label_data(%r)rqrrrrrEarrzAbstractWriter.send_label_datacCrp)Nzsend_flowing_data(%r)rqrrrrrUdrrz AbstractWriter.send_flowing_datacCrp)Nzsend_literal_data(%r)rqrrrrrWgrrz AbstractWriter.send_literal_dataN)r2r3r4rYr]rdrgrirCrBrDrErUrWrrrrroAsroc@sFeZdZdddZddZddZd d Zd d Zd dZddZ dS) DumbWriterNHcCs(|ptj|_||_t||dSr)sysZstdoutfilemaxcolrr reset)rrwrxrrrr ts  zDumbWriter.__init__cCsd|_d|_dSrl)colatbreakrrrrryzrhzDumbWriter.resetcCs |jd|d|_d|_dSNrVrrwwriterzr{r rrrrC~szDumbWriter.send_paragraphcCs|jdd|_d|_dSr|r}rrrrrBs zDumbWriter.send_line_breakcOs:|jd|jd|j|jdd|_d|_dS)NrVz-r)rwr~rxrzr{rrrrrDs   zDumbWriter.send_hor_rulecCsV|j||d}|dkr4d|_||dd}|}|jt||_d|_dS)NrVrr,)rwr~ZrfindrzZ expandtabsrer{)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)r{rSrzrxrwr~rTre)rrr{rzrxr~ZwordrrrrUs$  zDumbWriter.send_flowing_data)Nru) r2r3r4r ryrCrBrDrWrUrrrrrtks  rtcCst}t|}|dk r t|}n$tjddr>ttjd}ntj}z,|D]"}|dkrb|dqJ||qJW5|tjk r|X|ddS)Nr,rVr) rtr5ZopenrvZargvZstdinZcloser r)rwZwZfZfpZlinerrrtests    rZ__main__r) rvZwarningsZwarnZDeprecationWarningr\rr5rrortrr2rrrrZs"k*C