mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 04:27:16 +02:00
Merge pull request #458 from Kelketek/master
Made __radd__ work properly for ANSIString.
This commit is contained in:
commit
cf39c955a0
1 changed files with 9 additions and 3 deletions
|
|
@ -377,6 +377,12 @@ class ANSIString(unicode):
|
|||
def __len__(self):
|
||||
return len(self.clean_string)
|
||||
|
||||
def __radd__(self, other):
|
||||
if not isinstance(other, basestring):
|
||||
return NotImplemented
|
||||
return ANSIString(self.raw_string + getattr(
|
||||
other, 'raw_string', other), decoded=True)
|
||||
|
||||
def __getslice__(self, i, j):
|
||||
return self.__getitem__(slice(i, j))
|
||||
|
||||
|
|
@ -528,7 +534,7 @@ def _on_raw(func_name):
|
|||
except IndexError:
|
||||
pass
|
||||
result = _query_super(func_name)(self, *args, **kwargs)
|
||||
if isinstance(result, unicode):
|
||||
if isinstance(result, basestring):
|
||||
return ANSIString(result, decoded=True)
|
||||
return result
|
||||
return wrapped
|
||||
|
|
@ -559,8 +565,8 @@ for func_name in [
|
|||
'rfind', 'rindex']:
|
||||
setattr(ANSIString, func_name, _query_super(func_name))
|
||||
for func_name in [
|
||||
'__mul__', '__mod__', '__add__', 'expandtabs',
|
||||
'__rmul__', 'join', 'decode', 'replace', 'format']:
|
||||
'__mul__', '__mod__', '__add__', 'expandtabs', '__rmul__', 'join',
|
||||
'decode', 'replace', 'format']:
|
||||
setattr(ANSIString, func_name, _on_raw(func_name))
|
||||
for func_name in [
|
||||
'capitalize', 'translate', 'lower', 'upper', 'swapcase']:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue