mò %U²Ic@s|dZdZdZdZeeZeZeZeeZdZeddZ dZ dZ eee eZ e eed ƒƒZed ƒieƒZ[d d „Zd ad „Zd kZdfd„ƒYZdefd„ƒYZdfd„ƒYZeZeZ eZ!eZ"d„Z#d„Z$d„Z%d d„Z&d d„Z'd d„Z(d dd„Z)e)Z*d dd„Z+dd„ZeZ,d„Z-d „Z.d!„Z/d"„Z0d#„Z1e2Z3e4Z5e6Z7d$„Z8d%d&„Z9d%d'„Z:d(„Z;d)„Z<d*„Z=d+„Z>d,d-„Z?d d.„Z@d/„ZAdd0„ZBy-d1kClZlZlZlZeeZWneDj onXd S(2súA collection of string operations (most are no longer used). Warning: most of the code you see here isn't normally used nowadays. Beginning with Python 1.6, many of these functions are implemented as methods on the standard string object. They used to be implemented by a built-in module called strop, but strop is now obsolete itself. Public module variables: whitespace -- a string containing all characters considered whitespace lowercase -- a string containing all characters considered lowercase letters uppercase -- a string containing all characters considered uppercase letters letters -- a string containing all characters considered letters digits -- a string containing all characters considered decimal digits hexdigits -- a string containing all characters considered hexadecimal digits octdigits -- a string containing all characters considered octal digits punctuation -- a string containing all characters considered punctuation printable -- a string containing all characters considered printable s tabcdefghijklmnopqrstuvwxyztABCDEFGHIJKLMNOPQRSTUVWXYZt 0123456789tabcdeftABCDEFt01234567s !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~itcCs>|pdig}|i|ƒD]}||iƒq!~ƒS(sùcapwords(s, [sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. Note that this replaces runs of whitespace characters by a single space. t N(tseptjoint_[1]tstsplittxt capitalize(R RR R ((t#/data/zmath/lib/python2.4/string.pytcapwords/scCs’t|ƒt|ƒjo td‚ntptdtƒant}tt |ƒ}x,t t|ƒƒD]}||||| string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. s)maketrans arguments must have same lengthRN( tlentfromstrttostrt ValueErrort_idmapLtmaptNonet_idmaptLtordtrangetiR (RRRR((Rt maketrans=s Nt _multimapcBs tZdZd„Zd„ZRS(s‡Helper class for combining multiple mappings. Used by .{safe_,}substitute() to combine the mapping and keyword arguments. cCs||_||_dS(N(tprimarytselft_primaryt secondaryt _secondary(R RR"((Rt__init__[s cCs4y|i|SWntj o|i|SnXdS(N(R R!tkeytKeyErrorR#(R R%((Rt __getitem___s(t__name__t __module__t__doc__R$R'(((RRUs  t_TemplateMetaclasscBstZdZd„ZRS(Ns/ %(delim)s(?: (?P%(delim)s) | # Escape sequence of two delimiters (?P%(id)s) | # delimiter and a Python identifier {(?P%(id)s)} | # delimiter and a braced identifier (?P) # Other ill-formed delimiter exprs ) cCs‡tt|ƒi|||ƒd|jo |i}n/tihdti |i ƒ<d|i <}ti |ti tiBƒ|_dS(Ntpatterntdelimtid(tsuperR+tclsR$tnametbasestdctR,t_retescapet delimitert idpatterntcompilet IGNORECASEtVERBOSE(R0R1R2R3R,((RR$ps   .(R(R)R,R$(((RR+fs tTemplatecBsDtZdZeZdZdZd„Zd„Zd„Z d„Z RS(s.A string class for supporting $-substitutions.t$s[_a-z][_a-z0-9]*cCs ||_dS(N(ttemplateR (R R=((RR$ƒscCs|idƒ}|i| itƒ}|pd}d}n*|t di |d ƒƒ}t |ƒ}t d||fƒ‚dS(NtinvalidiRiÿÿÿÿs.Invalid placeholder in string: line %d, col %d( tmotstartRR R=t splitlinestTruetlinestcolnotlinenoRR R(R R?RRCRERD((Rt_invalidˆs  cst|ƒdjotdƒ‚n|p |‰n)|ot||dƒ‰n |d‰‡‡d†}ˆii |ˆi ƒS(NisToo many positional argumentsics |idƒp |idƒ}|dj oˆ|}d|Sn|idƒdj o ˆiSn|idƒdj oˆi|ƒnt dˆi ƒ‚dS(Ntnamedtbraceds%stescapedR>s#Unrecognized named group in pattern( R?tgroupRGRtmappingtvalR R6RFRR,(R?RLRG(RKR (Rtconvertžs    ( Rtargst TypeErrortkwsRKRRMR R,tsubR=(R RNRPRMRK((R RKRt substitute”s  cst|ƒdjotdƒ‚n|p |‰n)|ot||dƒ‰n |d‰‡‡d†}ˆii |ˆi ƒS(NisToo many positional argumentsics|idƒ}|dj o5ydˆ|SWqQtj oˆi|SqQXn|idƒ}|dj o=ydˆ|SWqªtj oˆid|dSqªXn|idƒdj o ˆiSn|idƒdj o ˆiSnt dˆi ƒ‚dS( NRGs%sRHt{t}RIR>s#Unrecognized named group in pattern( R?RJRGRRKR&R R6RHRR,(R?RGRH(RKR (RRM¸s$    ( RRNRORPRKRRMR R,RQR=(R RNRPRMRK((R RKRtsafe_substitute®s  ( R(R)R*R+t __metaclass__R6R7R$RFRRRU(((RR;|s   cCs |iƒS(sSlower(s) -> string Return a copy of the string s converted to lowercase. N(R tlower(R ((RRWÜscCs |iƒS(sSupper(s) -> string Return a copy of the string s converted to uppercase. N(R tupper(R ((RRXåscCs |iƒS(s„swapcase(s) -> string Return a copy of the string s with upper case characters converted to lowercase and vice versa. N(R tswapcase(R ((RRYîscCs |i|ƒS(sstrip(s [,chars]) -> string Return a copy of the string s with leading and trailing whitespace removed. If chars is given and not None, remove characters in chars instead. If chars is unicode, S will be converted to unicode before stripping. N(R tstriptchars(R R[((RRZøscCs |i|ƒS(s®lstrip(s [,chars]) -> string Return a copy of the string s with leading whitespace removed. If chars is given and not None, remove characters in chars instead. N(R tlstripR[(R R[((RR\scCs |i|ƒS(s¯rstrip(s [,chars]) -> string Return a copy of the string s with trailing whitespace removed. If chars is given and not None, remove characters in chars instead. N(R trstripR[(R R[((RR]siÿÿÿÿcCs|i||ƒS(srsplit(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string. If maxsplit is given, splits at no more than maxsplit places (resulting in at most maxsplit+1 words). If sep is not specified or is None, any whitespace string is a separator. (split and splitfields are synonymous) N(R R Rtmaxsplit(R RR^((RR s cCs|i||ƒS(sWrsplit(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string, starting at the end of the string and working to the front. If maxsplit is given, at most maxsplit splits are done. If sep is not specified or is None, any whitespace string is a separator. N(R trsplitRR^(R RR^((RR_(sRcCs |i|ƒS(sÖjoin(list [,sep]) -> string Return a string composed of the words in list, with intervening occurrences of sep. The default separator is a single space. (joinfields and join are synonymous) N(RR twords(R`R((RR 4s cGs |i|ŒS(spindex(s, sub [,start [,end]]) -> int Like find but raises ValueError when the substring is not found. N(R tindexRN(R RN((RRaBscGs |i|ŒS(srrindex(s, sub [,start [,end]]) -> int Like rfind but raises ValueError when the substring is not found. N(R trindexRN(R RN((RRbKscGs |i|ŒS(sÈcount(s, sub[, start[,end]]) -> int Return the number of occurrences of substring sub in string s[start:end]. Optional arguments start and end are interpreted as in slice notation. N(R tcountRN(R RN((RRcTscGs |i|ŒS(sfind(s, sub [,start [,end]]) -> in Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. N(R tfindRN(R RN((RRd_s cGs |i|ŒS(srfind(s, sub [,start [,end]]) -> int Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. N(R trfindRN(R RN((RRels cCs t|ƒS(sYatof(s) -> float Return the floating point number represented by the string s. N(t_floatR (R ((Rtatof~si cCs t||ƒS(ssatoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. N(t_intR tbase(R Ri((Rtatoiˆs cCs t||ƒS(s³atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. N(t_longR Ri(R Ri((Rtatol—s cGs|i||ŒS(sõljust(s, width[, fillchar]) -> string Return a left-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. If specified the fillchar is used instead of spaces. N(R tljusttwidthRN(R RnRN((RRm§scGs|i||ŒS(sörjust(s, width[, fillchar]) -> string Return a right-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. If specified the fillchar is used instead of spaces. N(R trjustRnRN(R RnRN((RRo²scGs|i||ŒS(sîcenter(s, width[, fillchar]) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never truncated. If specified the fillchar is used instead of spaces. N(R tcenterRnRN(R RnRN((RRp½scCs-t|tƒpt|ƒ}n|i|ƒS(s¡zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. N(t isinstanceR t basestringtreprtzfillRn(R Rn((RRtÊsicCs |i|ƒS(s×expandtabs(s [,tabsize]) -> string Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). N(R t expandtabsttabsize(R Rv((RRu×scCs4|o|i||ƒSn|i||d ƒSdS(sgtranslate(s,table [,deletions]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletions are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. The deletions argument is not allowed for Unicode strings. iN(t deletionsR t translatettable(R RyRw((RRxâs cCs |iƒS(socapitalize(s) -> string Return a copy of the string s with only its first character capitalized. N(R R(R ((RRõscCs|i|||ƒS(sñreplace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced. N(R treplacetoldtnewR^(R R{R|R^((RRzÿs(s maketranss lowercases uppercases whitespace(ER*t whitespacet lowercaset uppercasetletterstascii_lowercasetascii_uppercaset ascii_letterstdigitst hexdigitst octdigitst punctuationt printableRtchrtxrangetltstrR RRRRRtreR4RttypeR+R;Rt index_errort atoi_errort atof_errort atol_errorRWRXRYRZR\R]R t splitfieldsR_t joinfieldsRaRbRcRdRetfloatRftintRhtlongRkRgRjRlRmRoRpRtRuRxRRztstropt ImportError(6RRXR4R€R’R\RRƒRgRzRRRuR;RZR‚R†RcRaRmR}RhRbRfR‡RdR“R R]RxRR”RoRˆRWRYR‘RjR…RlR_R„R~R RpRkR‹ReRRRR+RtR((Rt?sz     Z