Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/UserString.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZddlZddlZddgZdejfd��YZdeejfd��YZedkr�dl	Z	e	j
jejd�\Z
Ze	j
je�\ZZd	ejkr�dd
lmZde_nedej��ndS(s�A user-defined wrapper around string objects

Note: string objects have grown methods in Python 1.6
This module requires Python 1.6 or later.
i�Nt
UserStringt
MutableStringcBsoeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�ZeZd�Zd�Zd�Zdejd�Zd;d;d�Zd;d;d�Zdejd�Zdd�Zdejd�Zdejd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+d;d(�Z,d)�Z-d*d+�Z.dejd,�Z/dejd-�Z0d.�Z1d/�Z2d;d0�Z3d;d*d1�Z4d;d*d2�Z5dd3�Z6dejd4�Z7d;d5�Z8d6�Z9d7�Z:d8�Z;d9�Z<d:�Z=RS(<cCsMt|t�r||_n.t|t�r:|j|_nt|�|_dS(N(t
isinstancet
basestringtdataRtstr(tselftseq((s /sys/lib/python2.7/UserString.pyt__init__s
cCs
t|j�S(N(RR(R((s /sys/lib/python2.7/UserString.pyt__str__scCs
t|j�S(N(treprR(R((s /sys/lib/python2.7/UserString.pyt__repr__scCs
t|j�S(N(tintR(R((s /sys/lib/python2.7/UserString.pyt__int__scCs
t|j�S(N(tlongR(R((s /sys/lib/python2.7/UserString.pyt__long__scCs
t|j�S(N(tfloatR(R((s /sys/lib/python2.7/UserString.pyt	__float__scCs
t|j�S(N(tcomplexR(R((s /sys/lib/python2.7/UserString.pyt__complex__scCs
t|j�S(N(thashR(R((s /sys/lib/python2.7/UserString.pyt__hash__scCs6t|t�r"t|j|j�St|j|�SdS(N(RRtcmpR(Rtstring((s /sys/lib/python2.7/UserString.pyt__cmp__scCs
||jkS(N(R(Rtchar((s /sys/lib/python2.7/UserString.pyt__contains__"scCs
t|j�S(N(tlenR(R((s /sys/lib/python2.7/UserString.pyt__len__%scCs|j|j|�S(N(t	__class__R(Rtindex((s /sys/lib/python2.7/UserString.pyt__getitem__&scCs5t|d�}t|d�}|j|j||!�S(Ni(tmaxRR(Rtstarttend((s /sys/lib/python2.7/UserString.pyt__getslice__'scCsgt|t�r&|j|j|j�St|t�rI|j|j|�S|j|jt|��SdS(N(RRRRRR(Rtother((s /sys/lib/python2.7/UserString.pyt__add__+s
cCsAt|t�r#|j||j�S|jt|�|j�SdS(N(RRRRR(RR$((s /sys/lib/python2.7/UserString.pyt__radd__2scCs|j|j|�S(N(RR(Rtn((s /sys/lib/python2.7/UserString.pyt__mul__7scCs|j|j|�S(N(RR(Rtargs((s /sys/lib/python2.7/UserString.pyt__mod__:scCs|j|jj��S(N(RRt
capitalize(R((s /sys/lib/python2.7/UserString.pyR+>scGs|j|jj||��S(N(RRtcenter(RtwidthR)((s /sys/lib/python2.7/UserString.pyR,?sicCs|jj|||�S(N(Rtcount(RtsubR!R"((s /sys/lib/python2.7/UserString.pyR.AscCs^|rD|r(|j|jj||��S|j|jj|��Sn|j|jj��SdS(N(RRtdecode(Rtencodingterrors((s /sys/lib/python2.7/UserString.pyR0Cs
cCs^|rD|r(|j|jj||��S|j|jj|��Sn|j|jj��SdS(N(RRtencode(RR1R2((s /sys/lib/python2.7/UserString.pyR3Ks
cCs|jj|||�S(N(Rtendswith(RtsuffixR!R"((s /sys/lib/python2.7/UserString.pyR4SsicCs|j|jj|��S(N(RRt
expandtabs(Rttabsize((s /sys/lib/python2.7/UserString.pyR6UscCs|jj|||�S(N(Rtfind(RR/R!R"((s /sys/lib/python2.7/UserString.pyR8WscCs|jj|||�S(N(RR(RR/R!R"((s /sys/lib/python2.7/UserString.pyRYscCs
|jj�S(N(Rtisalpha(R((s /sys/lib/python2.7/UserString.pyR9[scCs
|jj�S(N(Rtisalnum(R((s /sys/lib/python2.7/UserString.pyR:\scCs
|jj�S(N(Rt	isdecimal(R((s /sys/lib/python2.7/UserString.pyR;]scCs
|jj�S(N(Rtisdigit(R((s /sys/lib/python2.7/UserString.pyR<^scCs
|jj�S(N(Rtislower(R((s /sys/lib/python2.7/UserString.pyR=_scCs
|jj�S(N(Rt	isnumeric(R((s /sys/lib/python2.7/UserString.pyR>`scCs
|jj�S(N(Rtisspace(R((s /sys/lib/python2.7/UserString.pyR?ascCs
|jj�S(N(Rtistitle(R((s /sys/lib/python2.7/UserString.pyR@bscCs
|jj�S(N(Rtisupper(R((s /sys/lib/python2.7/UserString.pyRAcscCs|jj|�S(N(Rtjoin(RR((s /sys/lib/python2.7/UserString.pyRBdscGs|j|jj||��S(N(RRtljust(RR-R)((s /sys/lib/python2.7/UserString.pyRCescCs|j|jj��S(N(RRtlower(R((s /sys/lib/python2.7/UserString.pyRDgscCs|j|jj|��S(N(RRtlstrip(Rtchars((s /sys/lib/python2.7/UserString.pyREhscCs|jj|�S(N(Rt	partition(Rtsep((s /sys/lib/python2.7/UserString.pyRGisi�cCs|j|jj|||��S(N(RRtreplace(Rtoldtnewtmaxsplit((s /sys/lib/python2.7/UserString.pyRIkscCs|jj|||�S(N(Rtrfind(RR/R!R"((s /sys/lib/python2.7/UserString.pyRMmscCs|jj|||�S(N(Rtrindex(RR/R!R"((s /sys/lib/python2.7/UserString.pyRNoscGs|j|jj||��S(N(RRtrjust(RR-R)((s /sys/lib/python2.7/UserString.pyROqscCs|jj|�S(N(Rt
rpartition(RRH((s /sys/lib/python2.7/UserString.pyRPsscCs|j|jj|��S(N(RRtrstrip(RRF((s /sys/lib/python2.7/UserString.pyRQuscCs|jj||�S(N(Rtsplit(RRHRL((s /sys/lib/python2.7/UserString.pyRRvscCs|jj||�S(N(Rtrsplit(RRHRL((s /sys/lib/python2.7/UserString.pyRSxscCs|jj|�S(N(Rt
splitlines(Rtkeepends((s /sys/lib/python2.7/UserString.pyRTzscCs|jj|||�S(N(Rt
startswith(RtprefixR!R"((s /sys/lib/python2.7/UserString.pyRV{scCs|j|jj|��S(N(RRtstrip(RRF((s /sys/lib/python2.7/UserString.pyRX}scCs|j|jj��S(N(RRtswapcase(R((s /sys/lib/python2.7/UserString.pyRY~scCs|j|jj��S(N(RRttitle(R((s /sys/lib/python2.7/UserString.pyRZscGs|j|jj|��S(N(RRt	translate(RR)((s /sys/lib/python2.7/UserString.pyR[�scCs|j|jj��S(N(RRtupper(R((s /sys/lib/python2.7/UserString.pyR\�scCs|j|jj|��S(N(RRtzfill(RR-((s /sys/lib/python2.7/UserString.pyR]�sN(>t__name__t
__module__RR	RR
RRRRRRRRR#R%R&R(t__rmul__R*R+R,tsystmaxintR.tNoneR0R3R4R6R8RR9R:R;R<R=R>R?R@RARBRCRDRERGRIRMRNRORPRQRRRSRTRVRXRYRZR[R\R](((s /sys/lib/python2.7/UserString.pyR
sr																																						cBsheZdZdd�ZdZd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
RS(s�mutable string objects

    Python strings are immutable objects.  This has the advantage, that
    strings may be used as dictionary keys.  If this property isn't needed
    and you insist on changing string values in place instead, you may cheat
    and use MutableString.

    But the purpose of this class is an educational one: to prevent
    people from inventing their own mutable string class derived
    from UserString and than forget thereby to remove (override) the
    __hash__ method inherited from UserString.  This would lead to
    errors that would be very hard to track down.

    A faster and better solution is to rewrite your program using lists.tcCs-ddlm}|ddd�||_dS(Ni�(twarnpy3ksAthe class UserString.MutableString has been removed in Python 3.0t
stackleveli(twarningsReR(RRRe((s /sys/lib/python2.7/UserString.pyR�s	cCs\t|t�r�|t�r*|j}nt|t�sHt|�}n|jt|j��\}}}|dkr�|d|d}}|ddd�}n|dkr�td�nt	||�}|j| ||j||_no|dkr|t|j�7}n|dks,|t|j�kr5t
�n|j| ||j|d|_dS(Ni�is"invalid step in slicing assignmenti(RtsliceRRRRtindicesRt	TypeErrortmint
IndexError(RRR/R!tstoptstep((s /sys/lib/python2.7/UserString.pyt__setitem__�s$!"!	cCst|t�r�|jt|j��\}}}|dkrT|d|d}}n|dkrltd�nt||�}|j| |j||_nk|dkr�|t|j�7}n|dks�|t|j�kr��n|j| |j|d|_dS(Ni�is invalid step in slicing deletioni(RRhRiRRRjRkRl(RRR!RmRn((s /sys/lib/python2.7/UserString.pyt__delitem__�s!!	cCs�t|d�}t|d�}t|t�rR|j| |j|j||_nVt|t�r�|j| ||j||_n%|j| t|�|j||_dS(Ni(R RRRRR(RR!R"R/((s /sys/lib/python2.7/UserString.pyt__setslice__�s%"cCs=t|d�}t|d�}|j| |j||_dS(Ni(R R(RR!R"((s /sys/lib/python2.7/UserString.pyt__delslice__�scCs
t|j�S(N(RR(R((s /sys/lib/python2.7/UserString.pyt	immutable�scCs^t|t�r$|j|j7_n6t|t�rE|j|7_n|jt|�7_|S(N(RRRRR(RR$((s /sys/lib/python2.7/UserString.pyt__iadd__�scCs|j|9_|S(N(R(RR'((s /sys/lib/python2.7/UserString.pyt__imul__�scCs||||+dS(N((RRtvalue((s /sys/lib/python2.7/UserString.pytinsert�sN(R^R_t__doc__RRcRRoRpRqRrRsRtRuRw(((s /sys/lib/python2.7/UserString.pyR�s							t__main__is-q(ttest_supports
test.test_(RxRatcollectionst__all__tSequenceRtMutableSequenceRR^tostpathRRtargvt
called_in_dirt	called_astsplitexttpyttestRztverboset
__import__RD(((s /sys/lib/python2.7/UserString.pyt<module>sxW

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].