MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/usr/lib/python2.4/site-packages/mx/TextTools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/lib/python2.4/site-packages/mx/TextTools/TextTools.pyo
mò
H<c
@sBdZdkZdkZdkTdklZdkTdkTeid„Zdd„Z	d„Z
dd	„Zdeid
„Z
eid„Zdd„Zd
„Zdeeeeeeieeid„	Zdeeeeeied„Zeieeid„Zeeeeeid„Zdeeed„Zdeed„Zdeed„Zdeeed„Zd„Z d„Z!d„Z"dee#e$d„Z%dee&e'e(e)ƒd„Z*ee+ddfee+ddfde,e-e'd dƒdd!fee.e/de0fd"e1e-ddd#ffZ2ee2d$„Z3e3Z4ee+ddfee+ddfde,e5e'd dƒdd!fee.e/de0fd"e1e5ddd#ffZ6e6d%„Z7ee,e8dfd&e,e-e#ddfee.e/de0ffZ9e&e8d'„Z:dk;Z;d(fd)„ƒYZ<d*d+„Z=e>d,joe=ƒndS(-s< mxTextTools - A tools package for fast text processing.

    Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
N(t*(s__version__cCs ||}d}	d}
|d \}}}t|ƒdjo|d}	nt|ƒdjo|d}
nt	|dƒ\}}t|}t
|ƒ|jo|djo
d}nI|djo
d	}n2t|ƒ}t|ƒd
jo|d
 d}ndt|ƒd
||f|	|
fS(s7 Returns a pp-formatted tag table entry as string 
    iiiiitTabletSubTables<table>sHere/Tois...s#%-15.15s : %-30s : jne=%+i : je=%+is%-.15s : %sN(RR(ttabletitetjnetjetttctmtlentdivmodtflagstcmdtid2cmdttypet	TupleTypetNonetrepr(RRRR	RRR
R
RRR((t:/usr/lib/python2.4/site-packages/mx/TextTools/TextTools.pytformat_entrys&

 


iÿÿÿÿcCs|g}x_tt|ƒƒD]K}||jo|idt||ƒƒq|idt||ƒƒqWti	|dƒdS(s; Returns a pp-formatted version of the tag table as string s--> s    s
N(
tltrangeRRtjRtappendRtstringtjoin(RRRR((Rtformat_table6s
cCst|ƒGHdS(s Print the tag table 
    N(RR(R((Rtprint_tagtableBsic	Csõxî|D]æ\}}}}t|ƒ}t|ƒdjo|d d}nt|||!ƒ}t|ƒdjo|d d}n|djo'd|dG|GdG|G||fGHqd|dG|GdG|G||fGHt|||dƒqWdS(	sC Print the taglist tags for text using the given indent level 
    is...i<t s |s: iN(
ttagsttagRtrtsubtagsRttagnameRttextttargetRtindentt
print_tags(	R$RR&R%R RR"R!R#((RR'Hs
'#cCsøxñ|D]é}t|ƒ|joTt|ƒ}t|ƒdjo|d d}nd|dG|Gdt|ƒGHq|d}|dd!\}}t|||!ƒ}t|ƒdjo|d d}nd|dG|Gd||G||fGHqWd	S(
s< Print the joinlist joins using the given indent level 
    i(s...Rs |s (len = %i)iiiN(
tjoinsRRt
StringTypeRR$RR&RR!(R(R&R)R$RRR!((Rtprint_joinlistYs#
cCs|dgt|ƒ}xbtt|ƒƒD]N}||}t|ƒ|jo|||<q&|d|d|d!||<q&W|S(sÓ Return a normalized joinlist.

        All tuples in the joinlist are turned into real strings.  The
        resulting list is a equivalent copy of the joinlist only
        consisting of strings.
        
    tiiiN(RtjlistRRRtentryRR)(R,R)RRR-((Rtnormlistms

!cCsWh}xJ|D]B}||}|i|ƒo||i|ƒq
|g||<q
W|S(N(tdRtwtindexR	thas_keyR(RR1R	R0R/((Rt_lookup_dict„s
cCs4g}t|ƒ}|iƒ}t|ƒdjoB|idtt	i
|iƒdƒfƒ|idtdfƒnxž|iƒD]\}}|idƒt|ƒd}x.|D]&}|idt|ddtfƒq°W|idttfƒdt|t|ƒ|f||<q€W|idttfƒt|ƒS(s9 Creates a lookup table that matches the words in l 
    iR+iÿÿÿÿiN(RR3RR/tkeysRRRtIsInRRtSkiptitemsR	tgroupRR0tWordtMatchOktFailtHeretIsttuple(RR8R/R4R	RRR0((Rtword_in_lists$(

$$cCs÷|
|ƒ|jo||ƒ}n|}|i}|djoD|djo't	|ƒdjo|	|||ƒSnt	|ƒ}n|t
|df|ttt	|ƒddf|ttff}|||||ƒ\}}}
|p|Sn||ƒS(sìA fast replacement for string.replace.
    
       what can be given as string or search object.

       This function is a good example for the AppendTagobj-flag usage
       (the taglist can be used directly as joinlist).
       
    iiiÿÿÿÿN(RtwhatR)tSearchObjecttsotmatchtstopRtstartRtstring_replaceR$twitht
sWordStartR6tAppendTagobjtMovetToEOFRR tfoundttaglisttlastR(R$R@RGRERDRARtjoinlistR RFRR)RMRNRBRRL((Rtreplaceªs
	
 =c
Cs˜|djot|ƒ}nt|ƒ|jo|	|ƒ}n|t	|ddff}|||||ƒ\}}
}
|p|Sn||||
ƒƒS(sAnalogon to string.replace; returns a string with all occurences
       of what in text[start:stop] replaced by with
       - uses a one entry tag-table and a Boyer-Moore-Search-object
       - what can be a string or a BMS/FS search object
       - it's faster than string.replace in those cases, where
         the what-string gets long and/or many replacements are found;
         faster meaning from a few percent up to many times as fast
       - start and stop define the slice of text to work in
       - stop defaults to len(text)
    iiN(RDRRR$RR@R)tBMSRGt	sFindWordRR RERLRMRNRRO(R$R@RGRERDRROR R)RQRNRRLRM((Rt	_replace2Îs
cCs t|ƒ|jo||ƒ}n|i|ƒ}|p|Sng}d}	x2|D]*\}
}|i||	|
!|ƒ|}	qTW|i||	ƒ||dƒS(NiR+(RR@R)tFStfindallR$tslicesRtxtlefttrightRRGR(R$R@RGRRTR)RVRRYRWRX((Rt	_replace3çs
cCs™t|ƒ|jo||ƒ}n|i|ƒ}|p|Sndgt|ƒ}
x/t
t|ƒƒD]}	|f||	|
|	<qgW||||
ƒƒS(N(RR@R)RTRUR$RVRRtreplRRRGRRO(R$R@RGRROR RTR)RVRR[((Rt	_replace4ùscCsD|dj	o||||||ƒƒSn|||||ƒƒSdS(s¨ Apply multiple replacement to a text at once.

        replacements must be list of tuples (replacement, left,
        right).  It is used to replace the slice text[left:right] with
        the string replacement.

        Note that the replacements do not affect one another.  Indices
        always refer to the original text string.

        Replacements must not overlap. Otherwise a ValueError is
        raised.

    N(RDRRROR$treplacementsRE(R$R]RERDRRO((Rtmultireplaces
cCsD|dj	o||ƒi|||ƒSn||ƒi||ƒSdS(s A faster replacement for string.find().

        Uses a search object for the task. Returns the position of the
        first occurance of what in text[start:stop]. stop defaults to
        len(text).  Returns -1 in case no occurance was found.
        
    N(RDRRAR@tfindR$RE(R$R@RERDRA((RR_s

cCsD|dj	o||ƒi|||ƒSn||ƒi||ƒSdS(s Find all occurances of what in text.

        Uses a search object for the task. Returns a list of slice
        tuples (l,r) marking the all occurances in
        text[start:stop]. stop defaults to len(text).  Returns an
        empty list in case no occurance was found.
        
    N(RDRRAR@RUR$RE(R$R@RERDRA((RRU.s
c
Cs­|o|||ƒ}	n
||ƒ}	|o|	i|||ƒ}
n|	i||ƒ}
d}g}|i}x+|
D]#\}}||||!ƒ|}qtW|||ƒ|S(s” A faster replacement for string.split().

        Uses a search object for the task. Returns the result of
        cutting the text[start:stop] string into snippets at every sep
        occurance in form of a list of substrings. translate is passed
        to the search object as translation string.

        XXX convert to a C function... or even better, add as method
        to search objects.

    iN(t	translateRAtsepRBRDRUR$REtcutsRtlistRRXRY(
R$RaRERDR`RARYRRcRBRbRRX((Rtsplit?s 	
c	Csdx]|D]U\}}}}|t|ƒ}|||!||<|ot
|||d|ƒqqWdS(Nt.(RMtoRR!tstprefixtstrtpfxR$tdictt_tagdict(	R$RkRhRMRRfRgR!Rj((RRl`scGs¬tt|f|ƒ\}}}|p|d|fSnh}t	}xY|D]Q\}}}	}t|ƒ}
|||	!||
<|o||t|
d|ƒqJqJW|||fS(sÝ Tag a text just like the function tag() and then convert
        its output into a dictionary where the tagobjects reference
        their respective strings
        - this function emulates the interface of tag()
        - in contrast to tag() this funtion *does* make copies
          of the found stings
        - returns a tuple (rc,tagdict,next) with the same meaning
          of rc and next as tag(); tagdict is the new dictionary - 
          None in case rc is 0
    ReN(tapplyR R$targstrcRMtnextRR/RlttagdictRfRR!RgRiRjRk(R$RnR/RqRRfRpRgRoR!RjRM((RRqhscCs
t|dƒS(sB Return a set with all characters *except* the ones in chars.
    iN(tsettchars(Rs((Rtinvset€scCs<|djot|ƒ}n|||||ƒ}|djS(s Return 1 iff text[start:stop] only contains whitespace
        characters (as defined in Constants/Sets.py), 0 otherwise.
    iN(RDRRR$tsetfindt
nonwhitespaceRER(R$RERDRvRuR((Rt
is_whitespace†s

RcCs||||ƒ|ƒS(sá Eliminates newline characters and compresses whitespace
        characters into one space.

        The result is a one line text string. Tim Peters will like
        this function called with '-' separator ;-)
        
    N(RtsetsplitR$tcollapse_sett	separator(R$RzRRxRy((Rtcollapse’s
s
is
tlines
iþÿÿÿs
empty lineiüÿÿÿcCs|||ƒdS(s Split text into a list of single lines.

        The following combinations are considered to be line-ends:
        '
', '
', '
'; they may be used in any combination.  The
        line-end indicators are removed from the strings prior to
        adding them to the list.

        This function allows dealing with text files from Macs, PCs
        and Unix origins in a portable way.
        
    iN(R R$tlinesplit_table(R$R R}((Rt
splitlines§scCstt||ƒdƒS(s Returns the number of lines in text.

        Line ends are treated just like for splitlines() in a
        portable way.
    iN(RR R$tlinecount_table(R$R((Rt
countlinesÃstwordcCs
|||ƒS(sª Split text into a list of single words.

        Words are separated by whitespace. The whitespace is stripped
        before adding the words to the list.
        
    N(RxR$twhitespace_set(R$RxR‚((Rt
splitwordsÔs	t_timercBswtZdZdZdZeieid„Zeieid„Zeieid„Z	eieid„Z
d„ZRS(s timer class with a quite obvious interface
        - .start() starts a fairly accurate CPU-time timer plus an
          absolute timer
        - .stop() stops the timer and returns a tuple: the CPU-time in seconds
          and the absolute time elapsed since .start() was called
    icCs|ƒ|_|ƒ|_dS(N(ttimetselftatimetclocktutime(R†RˆR…((RREòscCs6|ƒ|i|_|ƒ|i|_|i|ifS(N(RˆR†R‰R…R‡(R†RˆR…((RRD÷scCs-|ƒ|i|_|ƒ|i|_|iS(N(RˆR†R‰R…R‡(R†RˆR…((RtusertimeýscCs-|ƒ|i|_|ƒ|i|_|iS(N(RˆR†R‰R…R‡(R†RˆR…((RtabstimescCsd|i|ifS(Ns%0.2fu %0.2fa sec.(R†R‰R‡(R†((Rt__str__	s(t__name__t
__module__t__doc__R‰R‡R…RˆRERDRŠR‹RŒ(((RR„æssmxTextTools/mxTextTools.ccCs@d„}t|ƒiƒ}dk}tƒ}dt|ƒGHdS(NcCsúHx£tt|ƒƒD] }||||joPqqWdt|ƒt|ƒfGHt|ƒt|ƒjodt|t|ƒƒGHndt|t|ƒƒGHHdSd|GH||d|!dt||ƒt||ƒf||d|d!GHHdS(NsLength mismatch: orig=%i new=%isMissing chars:s
Excess chars:sMismatch at offset %i:ids<- %s != %s ->i(RRtorigRtnewR(RR‘R((Rtmismatchs		EsWorking on a %i byte string(	R’topentfiletreadR$RR„RR(R”RR$R’R((Rt_bench
s			.)$t__main__(?RRttypestmxTextToolst__version__tConstants.TagTablestConstants.SetsRRRRR'R)R*R.R3R?RRQRROR RPRRSRTRZR\R^R_RURdRlRqRttnonwhitespace_setRuRwRxRrtnewlinet
whitespaceR{R=tAllInSettAppendMatchtEOFR<R:R6t_linesplit_tableR~t	linesplitRIt_linecount_tableR€R‚t_wordsplit_tableRƒR…R„R–R("R3RlRRPR¥R?R{RqR„RR£R_R–RdRƒRšR'RRR.R¦RwR€R¤R˜RtRUR^RSRZR~R\R…R*((Rt?sN
		*$!!			
kk=	'ÿ	


Anon7 - 2021