1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 __revision__ = "src/engine/SCons/compat/_scons_UserString.py 5110 2010/07/25 16:14:38 bdeegan"
25
26 __doc__ = """
27 A user-defined wrapper around string objects
28
29 This class is "borrowed" from the Python 2.2 UserString and modified
30 slightly for use with SCons. It is *NOT* guaranteed to be fully compliant
31 with the standard UserString class from all later versions of Python.
32 In particular, it does not necessarily contain all of the methods found
33 in later versions.
34 """
35
36 import types
37
38 StringType = types.StringType
39
40 if hasattr(types, 'UnicodeType'):
41 UnicodeType = types.UnicodeType
44 else:
46 return type(obj) is StringType
47
50 if is_String(seq):
51 self.data = seq
52 elif isinstance(seq, UserString):
53 self.data = seq.data[:]
54 else:
55 self.data = str(seq)
56 - def __str__(self): return str(self.data)
57 - def __repr__(self): return repr(self.data)
58 - def __int__(self): return int(self.data)
59 - def __long__(self): return long(self.data)
62 - def __hash__(self): return hash(self.data)
63
70 return char in self.data
71
72 - def __len__(self): return len(self.data)
75 start = max(start, 0); end = max(end, 0)
76 return self.__class__(self.data[start:end])
77
79 if isinstance(other, UserString):
80 return self.__class__(self.data + other.data)
81 elif is_String(other):
82 return self.__class__(self.data + other)
83 else:
84 return self.__class__(self.data + str(other))
86 if is_String(other):
87 return self.__class__(other + self.data)
88 else:
89 return self.__class__(str(other) + self.data)
91 return self.__class__(self.data*n)
92 __rmul__ = __mul__
93
94
95
96
97
98
99