U AT^';@sddlZddlZejdedddZGdddZGdddZGd d d ZGd d d eZGd ddeZ dddZ e dkre dS)Nz"the formatter module is deprecated) 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__cCsdSrr r blankliner r r end_paragraph-zNullFormatter.end_paragraphcCsdSrr r r r r add_line_break.rzNullFormatter.add_line_breakcOsdSrr r argskwr r r add_hor_rule/rzNullFormatter.add_hor_rulecCsdSrr r formatcounterrr 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_stylecCsdSrr 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@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|_ dSNr0r) rr! align_stack font_stack margin_stackr+ style_stacknospace softspacepara_endparskip hard_break have_labelrr r r r NszAbstractFormatter.__init__cCs`|js|jd|_|j|krD|jsD|j||j||_d|_d|_|_|_d|_dSNrr0) rDrsend_line_breakrErCsend_paragraphr@rBrAr r r r r]s zAbstractFormatter.end_paragraphcCs8|js"|js"|jd|_|_d|_|_d|_dSrF)rDrBrrGrErCr@rArr r r rhs     z AbstractFormatter.add_line_breakcOsF|js|j|jj||d|_|_d|_|_|_|_dSr;) rDrrG send_hor_ruler@rErBrArCrr r r ros   zAbstractFormatter.add_hor_ruleNcCs|js |js|j|js0|j|r*dp,dt|trP|j| ||n |j|d|_ |_|_|_d|_ |_ dSr;) rErDrrGrBrH isinstancestrsend_label_dataformat_counterr@rArCrr r r rvs    z AbstractFormatter.add_label_datacCstd}|D]f}|dkr"|d|}q|dkrD|dkrn||||}q|dkrf|dkrn||||}q||}q|S)N1z%dZaArZiI) format_letter format_roman)r rrlabelcr r r rMs z AbstractFormatter.format_countercCs<d}|dkr8t|dd\}}tt||}||}q|S)NrNrr0)divmodchrord)r caserrRr$sr r r rPs  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$rSmvld)rNrr r0rNI)rUupper) r rXrZonesZfivesrRindexr$rYr r r rQs&    zAbstractFormatter.format_romancCs|sdS|dd}|dd}d|}|jrD|sDdS|sN|jrv|sh|jsdd|_d|_dS|jsvd|}d|_|_|_|_|_||_|j |dS)Nr0 r) isspacejoinsplitr@rArCrDrBrErsend_flowing_data)r rZprespaceZ postspacer r r rs*  z"AbstractFormatter.add_flowing_datacCsZ|sdS|jr|jd|dddk|_d|_|_|_|_|_|j|dS)Nrgrf r) rArrkrDr@rBrCrEsend_literal_datarr r r rs z"AbstractFormatter.add_literal_datacCs:|jr6d|_|_|_|_|_d|_|jddSNrr0rg)rArDrBrCrEr@rrkrr r r rsz!AbstractFormatter.flush_softspacecCs@|r.||jkr.|j|||_|j|n|j|jdSr)r!r new_alignmentr<appendr r r r r"s  z AbstractFormatter.push_alignmentcCsH|jr|jd=|jr2|jd|_}|j|nd|_|jddSNrf)r<r!rror r r r r#szAbstractFormatter.pop_alignmentc Cs|\}}}}|jr6d|_|_|_d|_|jd|jr~|jd\}}}} |tkrZ|}|tkrf|}|tkrr|}|tkr~| }||||f}|j||j |dS)Nrr0rgrf) rArDrBr@rrkr=AS_ISrpnew_font) r fontsizerZbttZcsizeZcicbZcttr r r r%s$    zAbstractFormatter.push_fontcCs4|jr|jd=|jr |jd}nd}|j|dSrq)r=rrsr 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 sz1AbstractFormatter.push_margin..rf)r>rpr new_marginlen)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| sz0AbstractFormatter.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|_|jd|D]}|j|q.|jt |jdSrn) rArDrBr@rrkr?rp new_stylestuple)r r.styler r r r/s zAbstractFormatter.push_styler0cCs$|j| d=|jt|jdSr)r?rrrr1r r r r3!szAbstractFormatter.pop_stylecCs$| |_|_d|_|_|_dSNr)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@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)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 r7rzNullWriter.new_spacingcCsdSrr r-r r r r8rzNullWriter.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 rrorsr}rrrHrGrIrLrkrmr r r r r*src@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)AbstractWritercCstd|fdS)Nznew_alignment(%r)printr r r r roIszAbstractWriter.new_alignmentcCstd|fdS)Nz new_font(%r)rryr r r rsLszAbstractWriter.new_fontcCstd||fdS)Nznew_margin(%r, %d)rrr r r r}OszAbstractWriter.new_margincCstd|fdS)Nznew_spacing(%r)rr*r r r rRszAbstractWriter.new_spacingcCstd|fdS)Nznew_styles(%r)rr-r r r rUszAbstractWriter.new_stylescCstd|fdS)Nzsend_paragraph(%r)rr r r r rHXszAbstractWriter.send_paragraphcCs tddS)Nzsend_line_break()rrr r r rG[szAbstractWriter.send_line_breakcOs tddS)Nzsend_hor_rule()rrr r r rI^szAbstractWriter.send_hor_rulecCstd|fdS)Nzsend_label_data(%r)rrr r r rLaszAbstractWriter.send_label_datacCstd|fdS)Nzsend_flowing_data(%r)rrr r r rkdsz AbstractWriter.send_flowing_datacCstd|fdS)Nzsend_literal_data(%r)rrr r r rmgsz AbstractWriter.send_literal_dataN)r7r8r9rorsr}rrrHrGrIrLrkrmr r r r rAsrc@sFeZdZdddZddZddZd d Zd d Zd dZddZ dS) DumbWriterNHcCs(|ptj|_||_t||dSr)sysstdoutfilemaxcolrr reset)r rrr r r r ts  zDumbWriter.__init__cCsd|_d|_dSr)colatbreakrr r r rzszDumbWriter.resetcCs |jd|d|_d|_dSNrlrrwriterrr r r r rH~szDumbWriter.send_paragraphcCs|jdd|_d|_dSrrrr r r rGs zDumbWriter.send_line_breakcOs:|jd|jd|j|jdd|_d|_dS)Nrl-r)rrrrrrr r r rIs   zDumbWriter.send_hor_rulecCsV|j||d}|dkr4d|_||dd}|}|jt||_d|_dS)Nrlrr0)rrrfindr expandtabsr~r)r rrZr r r rms  zDumbWriter.send_literal_datacCs|sdS|jp|d}|j}|j}|jj}|D]N}|rl|t||kr\|dd}n|d|d}|||t|}d}q6||_|d|_dS)Nrrlrgr0rf)rrhrrrrrjr~)r rrrrrZwordr r r rks$  zDumbWriter.send_flowing_data)Nr) r7r8r9r rrHrGrIrmrkr r r r rks  rcCst}t|}|dk r t|}n$tjddr>ttjd}ntj}z,|D]"}|dkrb|dqJ||qJW5|tjk r|X|ddS)Nr0rlr) rr:openrargvstdincloserr)rwffpliner r r tests    r__main__)N) rwarningswarnDeprecationWarningrrrr:rrrrr7r r r r s"k*C