Python UserString.UserString() Examples
The following are 30
code examples of UserString.UserString().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
UserString
, or try the search function
.
Example #1
Source File: Util.py From arnold-usd with Apache License 2.0 | 6 votes |
def to_String_for_subst(s, isinstance=isinstance, str=str, to_String=to_String, BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes, UserString=UserString): # Note that the test cases are sorted by order of probability. if isinstance(s, BaseStringTypes): return s elif isinstance(s, SequenceTypes): return ' '.join([to_String_for_subst(e) for e in s]) elif isinstance(s, UserString): # s.data can only be either a unicode or a regular # string. Please see the UserString initializer. return s.data else: return str(s)
Example #2
Source File: test_userstring.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_immutable(self): s = self.type2test("foobar") s2 = s.immutable() self.assertEqual(s, s2) self.assertIsInstance(s2, UserString)
Example #3
Source File: test_userstring.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_immutable(self): s = self.type2test("foobar") s2 = s.immutable() self.assertEqual(s, s2) self.assertIsInstance(s2, UserString)
Example #4
Source File: test_userstring.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_iadd(self): s = self.type2test("foo") s += "bar" self.assertEqual(s, "foobar") s += UserString("baz") self.assertEqual(s, "foobarbaz") s += 42 self.assertEqual(s, "foobarbaz42")
Example #5
Source File: demjson3.py From ru with GNU General Public License v2.0 | 5 votes |
def isstringtype( obj ): """Is the object of a Python string type?""" if isinstance(obj, basestring): return True # Must also check for some other pseudo-string types import types, UserString return isinstance(obj, types.StringTypes) \ or isinstance(obj, UserString.UserString) \ or isinstance(obj, UserString.MutableString) # ---------------------------------------------------------------------- # Numeric helpers
Example #6
Source File: demjson.py From ru with GNU General Public License v2.0 | 5 votes |
def isstringtype( obj ): """Is the object of a Python string type?""" if isinstance(obj, basestring): return True # Must also check for some other pseudo-string types import types, UserString return isinstance(obj, types.StringTypes) \ or isinstance(obj, UserString.UserString) \ or isinstance(obj, UserString.MutableString) # ---------------------------------------------------------------------- # Numeric helpers
Example #7
Source File: demjson3.py From ru with GNU General Public License v2.0 | 5 votes |
def isstringtype( obj ): """Is the object of a Python string type?""" if isinstance(obj, basestring): return True # Must also check for some other pseudo-string types import types, UserString return isinstance(obj, types.StringTypes) \ or isinstance(obj, UserString.UserString) \ or isinstance(obj, UserString.MutableString) # ---------------------------------------------------------------------- # Numeric helpers
Example #8
Source File: demjson3.py From ru with GNU General Public License v2.0 | 5 votes |
def isstringtype( obj ): """Is the object of a Python string type?""" if isinstance(obj, basestring): return True # Must also check for some other pseudo-string types import types, UserString return isinstance(obj, types.StringTypes) \ or isinstance(obj, UserString.UserString) \ or isinstance(obj, UserString.MutableString) # ---------------------------------------------------------------------- # Numeric helpers
Example #9
Source File: TestCmd.py From gyp with BSD 3-Clause "New" or "Revised" License | 5 votes |
def is_String(e): return isinstance(e, basestring) or isinstance(e, UserString)
Example #10
Source File: TestCmd.py From kawalpemilu2014 with GNU Affero General Public License v3.0 | 5 votes |
def is_String(e): return type(e) is types.StringType \ or type(e) is types.UnicodeType \ or isinstance(e, UserString)
Example #11
Source File: TestCmd.py From kawalpemilu2014 with GNU Affero General Public License v3.0 | 5 votes |
def is_String(e): return type(e) is types.StringType or isinstance(e, UserString)
Example #12
Source File: test_userstring.py From medicare-demo with Apache License 2.0 | 5 votes |
def checkequal(self, result, object, methodname, *args): result = self.fixtype(result) object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it realresult = getattr(object, methodname)(*args) self.assertEqual( result, realresult )
Example #13
Source File: test_userstring.py From medicare-demo with Apache License 2.0 | 5 votes |
def checkraises(self, exc, object, methodname, *args): object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it self.assertRaises( exc, getattr(object, methodname), *args )
Example #14
Source File: test_userstring.py From medicare-demo with Apache License 2.0 | 5 votes |
def checkcall(self, object, methodname, *args): object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it getattr(object, methodname)(*args)
Example #15
Source File: test_userstring.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_setslice(self): s = self.type2test("foo") s[:] = "bar" self.assertEqual(s, "bar") s[1:2] = "foo" self.assertEqual(s, "bfoor") s[1:-1] = UserString("a") self.assertEqual(s, "bar") s[0:10] = 42 self.assertEqual(s, "42")
Example #16
Source File: test_userstring.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_immutable(self): s = self.type2test("foobar") s2 = s.immutable() self.assertEqual(s, s2) self.assert_(isinstance(s2, UserString))
Example #17
Source File: TestCmd.py From android-xmrig-miner with GNU General Public License v3.0 | 5 votes |
def is_String(e): return type(e) is types.StringType \ or type(e) is types.UnicodeType \ or isinstance(e, UserString)
Example #18
Source File: TestCmd.py From android-xmrig-miner with GNU General Public License v3.0 | 5 votes |
def is_String(e): return type(e) is types.StringType or isinstance(e, UserString)
Example #19
Source File: test_userstring.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def checkequal(self, result, object, methodname, *args): result = self.fixtype(result) object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it realresult = getattr(object, methodname)(*args) self.assertEqual( result, realresult )
Example #20
Source File: test_userstring.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def checkraises(self, exc, object, methodname, *args): object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it self.assertRaises( exc, getattr(object, methodname), *args )
Example #21
Source File: test_userstring.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def checkcall(self, object, methodname, *args): object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it getattr(object, methodname)(*args)
Example #22
Source File: test_userstring.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_setslice(self): s = self.type2test("foo") s[:] = "bar" self.assertEqual(s, "bar") s[1:2] = "foo" self.assertEqual(s, "bfoor") s[1:-1] = UserString("a") self.assertEqual(s, "bar") s[0:10] = 42 self.assertEqual(s, "42")
Example #23
Source File: test_userstring.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_immutable(self): s = self.type2test("foobar") s2 = s.immutable() self.assertEqual(s, s2) self.assertIsInstance(s2, UserString)
Example #24
Source File: test_userstring.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def checkequal(self, result, object, methodname, *args): result = self.fixtype(result) object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it realresult = getattr(object, methodname)(*args) self.assertEqual( result, realresult )
Example #25
Source File: test_userstring.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def checkraises(self, exc, object, methodname, *args): object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it self.assertRaises( exc, getattr(object, methodname), *args )
Example #26
Source File: test_userstring.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def checkcall(self, object, methodname, *args): object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it getattr(object, methodname)(*args)
Example #27
Source File: test_userstring.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_setslice(self): s = self.type2test("foo") s[:] = "bar" self.assertEqual(s, "bar") s[1:2] = "foo" self.assertEqual(s, "bfoor") s[1:-1] = UserString("a") self.assertEqual(s, "bar") s[0:10] = 42 self.assertEqual(s, "42")
Example #28
Source File: Util.py From arnold-usd with Apache License 2.0 | 5 votes |
def to_String(s, isinstance=isinstance, str=str, UserString=UserString, BaseStringTypes=BaseStringTypes): if isinstance(s,BaseStringTypes): # Early out when already a string! return s elif isinstance(s, UserString): # s.data can only be either a unicode or a regular # string. Please see the UserString initializer. return s.data else: return str(s)
Example #29
Source File: test_userstring.py From oss-ftp with MIT License | 5 votes |
def test_setslice(self): s = self.type2test("foo") s[:] = "bar" self.assertEqual(s, "bar") s[1:2] = "foo" self.assertEqual(s, "bfoor") s[1:-1] = UserString("a") self.assertEqual(s, "bar") s[0:10] = 42 self.assertEqual(s, "42")
Example #30
Source File: test_userstring.py From ironpython2 with Apache License 2.0 | 5 votes |
def checkequal(self, result, object, methodname, *args): result = self.fixtype(result) object = self.fixtype(object) # we don't fix the arguments, because UserString can't cope with it realresult = getattr(object, methodname)(*args) self.assertEqual( result, realresult )