%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/formatter.pyc

ó
Mêáac@s£dZddlZdZddd„ƒYZddd„ƒYZddd„ƒYZd	efd
„ƒYZdefd„ƒYZdd
„Z	e
dkrŸe	ƒndS(sGeneric 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.
iÿÿÿÿNt
NullFormattercBs¼eZdZdd„Zd„Zd„Zd„Zdd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„Zd
„Zd„Zd„Zd„Zdd„Zdd„ZRS(s=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.

    cCs%|dkrtƒ}n||_dS(N(tNonet
NullWritertwriter(tselfR((s%/usr/local/lib/python2.7/formatter.pyt__init__&scCsdS(N((Rt	blankline((s%/usr/local/lib/python2.7/formatter.pyt
end_paragraph*tcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pytadd_line_break+RcOsdS(N((Rtargstkw((s%/usr/local/lib/python2.7/formatter.pytadd_hor_rule,RcCsdS(N((RtformattcounterR((s%/usr/local/lib/python2.7/formatter.pytadd_label_data-RcCsdS(N((Rtdata((s%/usr/local/lib/python2.7/formatter.pytadd_flowing_data.RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pytadd_literal_data/RcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pytflush_softspace0RcCsdS(N((Rtalign((s%/usr/local/lib/python2.7/formatter.pytpush_alignment1RcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pyt
pop_alignment2RcCsdS(N((Rtx((s%/usr/local/lib/python2.7/formatter.pyt	push_font3RcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pytpop_font4RcCsdS(N((Rtmargin((s%/usr/local/lib/python2.7/formatter.pytpush_margin5RcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pyt
pop_margin6RcCsdS(N((Rtspacing((s%/usr/local/lib/python2.7/formatter.pytset_spacing7RcGsdS(N((Rtstyles((s%/usr/local/lib/python2.7/formatter.pyt
push_style8RicCsdS(N((Rtn((s%/usr/local/lib/python2.7/formatter.pyt	pop_style9RcCsdS(N((Rtflag((s%/usr/local/lib/python2.7/formatter.pytassert_line_data:RN(t__name__t
__module__t__doc__RRRR	RRRRRRRRRRRRR R"R$(((s%/usr/local/lib/python2.7/formatter.pyRs&															tAbstractFormattercBsÔeZdZd„Zd„Zd„Zd„Zdd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zdd„Zdd„ZRS(sê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.

    cCsy||_d|_g|_g|_g|_d|_g|_d|_d|_	d|_
d|_d|_d|_
dS(Nii(RRRtalign_stackt
font_stacktmargin_stackRtstyle_stacktnospacet	softspacetpara_endtparskipt
hard_breakt
have_label(RR((s%/usr/local/lib/python2.7/formatter.pyRKs												cCs‹|js"|jjƒd|_n|j|krg|jrg|jj||jƒ||_d|_nd|_|_|_d|_dS(Nii(	R1Rtsend_line_breakR2R0tsend_paragraphR-R/R.(RR((s%/usr/local/lib/python2.7/formatter.pyRZs	
	cCsO|jp|js2|jjƒd|_|_nd|_|_d|_dS(Nii(R1R/RR3R2R0R-R.(R((s%/usr/local/lib/python2.7/formatter.pyR	es

cOs^|js|jjƒn|jj||Žd|_|_d|_|_|_|_dS(Nii(	R1RR3t
send_hor_ruleR-R2R/R.R0(RR
R((s%/usr/local/lib/python2.7/formatter.pyRls
	cCs»|js|jr#|jjƒn|jsK|jj|rAdpDdƒnt|tƒry|jj|j	||ƒƒn|jj|ƒd|_
|_|_|_d|_|_dS(Nii(
R2R1RR3R/R4t
isinstancetstrtsend_label_datatformat_counterR-R.R0(RR
RR((s%/usr/local/lib/python2.7/formatter.pyRss	cCsªd}x|D]•}|dkr0|d|}q
|dkrd|dkr¢||j||ƒ}q¢q
|dkr˜|dkr¢||j||ƒ}q¢q
||}q
W|S(NRt1s%dtaAitiI(t
format_lettertformat_roman(RR
Rtlabeltc((s%/usr/local/lib/python2.7/formatter.pyR9s
cCsVd}xI|dkrQt|ddƒ\}}tt|ƒ|ƒ}||}q	W|S(NRiii(tdivmodtchrtord(RtcaseRR?Rts((s%/usr/local/lib/python2.7/formatter.pyR=Žsc	Csddddg}dddg}d\}}xÂ|d	krñt|d
ƒ\}}|dkrz||||d|}nj|d
krŸ|||||}nE|dkrÂ||}|d}nd}||||}||}|d}q0W|dkr|jƒS|S(NtiRR@tmtvtltdRii
i	iiitI(Ri(RAtupper(	RRDRtonestfivesR?tindexRRE((s%/usr/local/lib/python2.7/formatter.pyR>™s&



cCså|s
dS|d jƒ}|djƒ}dj|jƒƒ}|jrS|rSdS|sb|jr£|sŠ|js†d|_d|_ndS|js£d|}q£nd|_|_|_|_|_||_|j	j
|ƒdS(Niiÿÿÿÿt i(tisspacetjointsplitR-R.R0R1R/R2Rtsend_flowing_data(RRtprespacet	postspace((s%/usr/local/lib/python2.7/formatter.pyR±s$			%	cCsr|s
dS|jr&|jjdƒn|ddk|_d|_|_|_|_|_|jj|ƒdS(NRPiÿÿÿÿs
i(	R.RRTR1R-R/R0R2tsend_literal_data(RR((s%/usr/local/lib/python2.7/formatter.pyRÅs	%cCsN|jrJd|_|_|_|_|_d|_|jjdƒndS(NiiRP(R.R1R/R0R2R-RRT(R((s%/usr/local/lib/python2.7/formatter.pyRÎs	%	cCsX|rA||jkrA|jj|ƒ||_|jj|ƒn|jj|jƒdS(N(RRt
new_alignmentR)tappend(RR((s%/usr/local/lib/python2.7/formatter.pyRÕs
	cCsc|jr|jd=n|jrF|jd|_}|jj|ƒnd|_|jjdƒdS(Niÿÿÿÿ(R)RRRXR(RR((s%/usr/local/lib/python2.7/formatter.pyRÝs	
		c
Csý|\}}}}|jrNd|_|_|_d|_|jjdƒn|jrÇ|jd\}}}}	|tkr…|}n|tkrš|}n|tkr¯|}n|tkrÇ|	}qÇn||||f}|jj|ƒ|jj	|ƒdS(NiiRPiÿÿÿÿ(
R.R1R/R-RRTR*tAS_ISRYtnew_font(
RtfonttsizeRFtbttttcsizetcitcbtctt((s%/usr/local/lib/python2.7/formatter.pyRçs$						cCsI|jr|jd=n|jr/|jd}nd}|jj|ƒdS(Niÿÿÿÿ(R*RRR[(RR\((s%/usr/local/lib/python2.7/formatter.pyR÷s	
	cCsY|jj|ƒtd|jƒ}|r<|r<|d}n|jj|t|ƒƒdS(Niÿÿÿÿ(R+RYtfilterRRt
new_margintlen(RRtfstack((s%/usr/local/lib/python2.7/formatter.pyRs


cCs^|jr|jd=ntd|jƒ}|r;|d}nd}|jj|t|ƒƒdS(Niÿÿÿÿ(R+RdRRReRf(RRgR((s%/usr/local/lib/python2.7/formatter.pyRs	

cCs||_|jj|ƒdS(N(RRtnew_spacing(RR((s%/usr/local/lib/python2.7/formatter.pyRs	cGsz|jr<d|_|_|_d|_|jjdƒnx|D]}|jj|ƒqCW|jjt	|jƒƒdS(NiiRP(
R.R1R/R-RRTR,RYt
new_stylesttuple(RRtstyle((s%/usr/local/lib/python2.7/formatter.pyR s		
icCs(|j|3|jjt|jƒƒdS(N(R,RRiRj(RR!((s%/usr/local/lib/python2.7/formatter.pyR"scCs,||_|_d|_|_|_dS(Ni(R-R1R/R0R2(RR#((s%/usr/local/lib/python2.7/formatter.pyR$"sN(R%R&R'RRR	RRRR9R=R>RRRRRRRRRRR R"R$(((s%/usr/local/lib/python2.7/formatter.pyR(=s,													
					
			RcBsƒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„ZRS(sMinimal 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(N((R((s%/usr/local/lib/python2.7/formatter.pyR/RcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pytflush0RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyRX1RcCsdS(N((RR\((s%/usr/local/lib/python2.7/formatter.pyR[2RcCsdS(N((RRtlevel((s%/usr/local/lib/python2.7/formatter.pyRe3RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyRh4RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyRi5RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyR46RcCsdS(N((R((s%/usr/local/lib/python2.7/formatter.pyR37RcOsdS(N((RR
R((s%/usr/local/lib/python2.7/formatter.pyR58RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyR89RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyRT:RcCsdS(N((RR((s%/usr/local/lib/python2.7/formatter.pyRW;R(R%R&R'RRlRXR[ReRhRiR4R3R5R8RTRW(((s%/usr/local/lib/python2.7/formatter.pyR's												tAbstractWritercBsqeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
RS(s°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.

    cCsd|fGHdS(Nsnew_alignment(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyRXFscCsd|fGHdS(Nsnew_font(%r)((RR\((s%/usr/local/lib/python2.7/formatter.pyR[IscCsd||fGHdS(Nsnew_margin(%r, %d)((RRRm((s%/usr/local/lib/python2.7/formatter.pyReLscCsd|fGHdS(Nsnew_spacing(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyRhOscCsd|fGHdS(Nsnew_styles(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyRiRscCsd|fGHdS(Nssend_paragraph(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyR4UscCs	dGHdS(Nssend_line_break()((R((s%/usr/local/lib/python2.7/formatter.pyR3XscOs	dGHdS(Nssend_hor_rule()((RR
R((s%/usr/local/lib/python2.7/formatter.pyR5[scCsd|fGHdS(Nssend_label_data(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyR8^scCsd|fGHdS(Nssend_flowing_data(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyRTascCsd|fGHdS(Nssend_literal_data(%r)((RR((s%/usr/local/lib/python2.7/formatter.pyRWds(R%R&R'RXR[ReRhRiR4R3R5R8RTRW(((s%/usr/local/lib/python2.7/formatter.pyRn>s										t
DumbWritercBsSeZdZd	dd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
RS(
s;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.

    iHcCs6|ptj|_||_tj|ƒ|jƒdS(N(tsyststdouttfiletmaxcolRRtreset(RRrRs((s%/usr/local/lib/python2.7/formatter.pyRqs	
cCsd|_d|_dS(Ni(tcoltatbreak(R((s%/usr/local/lib/python2.7/formatter.pyRtws	cCs*|jjd|ƒd|_d|_dS(Ns
i(RrtwriteRuRv(RR((s%/usr/local/lib/python2.7/formatter.pyR4{s	cCs&|jjdƒd|_d|_dS(Ns
i(RrRwRuRv(R((s%/usr/local/lib/python2.7/formatter.pyR3€s	cOsM|jjdƒ|jjd|jƒ|jjdƒd|_d|_dS(Ns
t-i(RrRwRsRuRv(RR
R((s%/usr/local/lib/python2.7/formatter.pyR5…s
	cCst|jj|ƒ|jdƒ}|dkrEd|_||d}n|jƒ}|jt|ƒ|_d|_dS(Ns
ii(RrRwtrfindRut
expandtabsRfRv(RRRF((s%/usr/local/lib/python2.7/formatter.pyRWŒs	cCsÞ|s
dS|jp |djƒ}|j}|j}|jj}xz|jƒD]l}|rš|t|ƒ|krƒ|dƒd}qš|dƒ|d}n||ƒ|t|ƒ}d}qNW||_|djƒ|_dS(Nis
RPiiÿÿÿÿ(RvRQRuRsRrRwRSRf(RRRvRuRsRwtword((s%/usr/local/lib/python2.7/formatter.pyRT–s$		
	



	N(R%R&R'RRRtR4R3R5RWRT(((s%/usr/local/lib/python2.7/formatter.pyRohs					
cCs§tƒ}t|ƒ}|dk	r0t|ƒ}n,tjdrSttjdƒ}n	tj}x7|D]/}|dkr…|jdƒqc|j|ƒqcW|jdƒdS(Nis
i(	RoR(RtopenRptargvtstdinRR(Rrtwtftfptline((s%/usr/local/lib/python2.7/formatter.pyttest«s	
	
t__main__((((R'RpRRZRR(RRnRoRƒR%(((s%/usr/local/lib/python2.7/formatter.pyt<module>s"ê*C

Zerion Mini Shell 1.0