summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/compat/_UserString.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2007-01-21 20:13:49 (GMT)
committerSteven Knight <knight@baldmt.com>2007-01-21 20:13:49 (GMT)
commit373a4788e2959fea72a6d5875bb8b59f04339961 (patch)
tree2da695bd6cd3956319741b8d251129cbe51fab22 /src/engine/SCons/compat/_UserString.py
parent75e1b1228eeefa79a360e6056365d74a5d39ce65 (diff)
downloadSCons-373a4788e2959fea72a6d5875bb8b59f04339961.zip
SCons-373a4788e2959fea72a6d5875bb8b59f04339961.tar.gz
SCons-373a4788e2959fea72a6d5875bb8b59f04339961.tar.bz2
Merged revisions 1767-1783 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r1771 | stevenknight | 2007-01-11 10:42:17 -0600 (Thu, 11 Jan 2007) | 1 line 0.96.D544 - Fix maximum recursion depth exceeded when writing .sconsign files after using Nodes on two different Windows drive letters. ........ r1772 | stevenknight | 2007-01-11 12:15:07 -0600 (Thu, 11 Jan 2007) | 1 line 0.96.D545 - Restore caching of file contents in Node.FS.File.get_contents(). ........ r1773 | stevenknight | 2007-01-12 10:22:40 -0600 (Fri, 12 Jan 2007) | 1 line 0.96.D405 - Add MergeFlags() and AddFlags() methods. (Greg Noel) Support recognizing compiler flags that begin with +. (Kent Boortz) ........ r1774 | stevenknight | 2007-01-16 15:58:39 -0600 (Tue, 16 Jan 2007) | 2 lines Back out previous modification; the wrong change was distributed. ........ r1775 | stevenknight | 2007-01-16 16:08:26 -0600 (Tue, 16 Jan 2007) | 1 line 0.96.D546 - Back out previous change that cached get_contents(). ........ r1776 | stevenknight | 2007-01-17 14:30:59 -0600 (Wed, 17 Jan 2007) | 1 line 0.96.D547 - Document the use of ${} to evaluate arbitrary Python code. (Gary Oberbrunner) ........ r1777 | stevenknight | 2007-01-17 15:43:18 -0600 (Wed, 17 Jan 2007) | 1 line 0.96.D548 - Better man page Scanner example (Matt Doar); add FindPathDirs() to the publicly-available functions, and document it. ........ r1778 | stevenknight | 2007-01-17 17:01:03 -0600 (Wed, 17 Jan 2007) | 1 line 0.96.D549 - Return MSVC default paths for versions >= 8.0. (Anonymous) ........ r1779 | stevenknight | 2007-01-18 08:37:58 -0600 (Thu, 18 Jan 2007) | 1 line 0.96.D550 - Windows fix for the rel_path() unit test. ........ r1780 | stevenknight | 2007-01-18 14:01:32 -0600 (Thu, 18 Jan 2007) | 1 line 0.96.D551 - Fix use of __builtins__ in Subst.py. ........ r1781 | stevenknight | 2007-01-18 16:00:27 -0600 (Thu, 18 Jan 2007) | 1 line 0.96.D552 - Collect compatibility code in its own SCons.compat subpackage. ........ r1782 | stevenknight | 2007-01-18 16:22:52 -0600 (Thu, 18 Jan 2007) | 1 line 0.96.D553 - Add the vanilla Python 2.5 subprocess.py module (currently unused) as a baseline for our backwards-compatibility changes to that module. ........ r1783 | stevenknight | 2007-01-18 17:09:39 -0600 (Thu, 18 Jan 2007) | 1 line 0.96.D554 - Change env.ParseConfig() to use the new subprocess module. ........
Diffstat (limited to 'src/engine/SCons/compat/_UserString.py')
-rw-r--r--src/engine/SCons/compat/_UserString.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/engine/SCons/compat/_UserString.py b/src/engine/SCons/compat/_UserString.py
new file mode 100644
index 0000000..4adffa2
--- /dev/null
+++ b/src/engine/SCons/compat/_UserString.py
@@ -0,0 +1,92 @@
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+__doc__ = """
+A user-defined wrapper around string objects
+
+This class is "borrowed" from the Python 2.2 UserString and modified
+slightly for use with SCons. It is *NOT* guaranteed to be fully compliant
+with the standard UserString class from all later versions of Python.
+In particular, it does not necessarily contain all of the methods found
+in later versions.
+"""
+
+import types
+
+StringType = types.StringType
+
+if hasattr(types, 'UnicodeType'):
+ UnicodeType = types.UnicodeType
+ def is_String(obj):
+ return type(obj) in (StringType, UnicodeType)
+else:
+ def is_String(obj):
+ return type(obj) is StringType
+
+class UserString:
+ def __init__(self, seq):
+ if is_String(seq):
+ self.data = seq
+ elif isinstance(seq, UserString):
+ self.data = seq.data[:]
+ else:
+ self.data = str(seq)
+ def __str__(self): return str(self.data)
+ def __repr__(self): return repr(self.data)
+ def __int__(self): return int(self.data)
+ def __long__(self): return long(self.data)
+ def __float__(self): return float(self.data)
+ def __complex__(self): return complex(self.data)
+ def __hash__(self): return hash(self.data)
+
+ def __cmp__(self, string):
+ if isinstance(string, UserString):
+ return cmp(self.data, string.data)
+ else:
+ return cmp(self.data, string)
+ def __contains__(self, char):
+ return char in self.data
+
+ def __len__(self): return len(self.data)
+ def __getitem__(self, index): return self.__class__(self.data[index])
+ def __getslice__(self, start, end):
+ start = max(start, 0); end = max(end, 0)
+ return self.__class__(self.data[start:end])
+
+ def __add__(self, other):
+ if isinstance(other, UserString):
+ return self.__class__(self.data + other.data)
+ elif is_String(other):
+ return self.__class__(self.data + other)
+ else:
+ return self.__class__(self.data + str(other))
+ def __radd__(self, other):
+ if is_String(other):
+ return self.__class__(other + self.data)
+ else:
+ return self.__class__(str(other) + self.data)
+ def __mul__(self, n):
+ return self.__class__(self.data*n)
+ __rmul__ = __mul__