| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
import types |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
class DynamicDocString(types.UnicodeType): |
|---|
| 26 |
|
|---|
| 27 |
def __init__(self, obj=None): |
|---|
| 28 |
self.Obj = obj |
|---|
| 29 |
|
|---|
| 30 |
def _GetObj(self): |
|---|
| 31 |
return self._Obj |
|---|
| 32 |
|
|---|
| 33 |
def _SetObj(self, value): |
|---|
| 34 |
self._Obj = value |
|---|
| 35 |
|
|---|
| 36 |
Obj = property(_GetObj, _SetObj) |
|---|
| 37 |
|
|---|
| 38 |
def __getattribute__(self, name): |
|---|
| 39 |
assert isinstance(name, basestring) |
|---|
| 40 |
if isinstance(name, types.StringType): |
|---|
| 41 |
name = unicode(name) |
|---|
| 42 |
if name == u'Obj' or name == u'_Obj' or name == u'_GetObj' or name == u'_SetObj' or name.startswith(u'__'): |
|---|
| 43 |
return object.__getattribute__(self, name) |
|---|
| 44 |
return getattr(unicode(self._Obj), name) |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
def __add__(self, other): |
|---|
| 64 |
return unicode(self._Obj).__add__(other) |
|---|
| 65 |
|
|---|
| 66 |
def __contains__(self, other): |
|---|
| 67 |
return unicode(self._Obj).__contains__(other) |
|---|
| 68 |
|
|---|
| 69 |
def __eq__(self, other): |
|---|
| 70 |
return unicode(self._Obj).__eq__(other) |
|---|
| 71 |
|
|---|
| 72 |
def __ge__(self, other): |
|---|
| 73 |
return unicode(self._Obj).__ge__(other) |
|---|
| 74 |
|
|---|
| 75 |
def __getitem__(self, key): |
|---|
| 76 |
return unicode(self._Obj).__getitem__(key) |
|---|
| 77 |
|
|---|
| 78 |
def __getnewargs__(self, *args): |
|---|
| 79 |
raise NotImplementedError, u'DynamicDocString does not currently support pickling.' |
|---|
| 80 |
|
|---|
| 81 |
def __getslice__(self, start, end): |
|---|
| 82 |
return unicode(self._Obj).__getslice__(start, end) |
|---|
| 83 |
|
|---|
| 84 |
def __gt__(self, other): |
|---|
| 85 |
return unicode(self._Obj).__gt__(other) |
|---|
| 86 |
|
|---|
| 87 |
def __hash__(self): |
|---|
| 88 |
raise NotImplementedError, u'DynamicDocString is not hashable because it is mutable. DynamicDocString cannot serve as a dictionary key.' |
|---|
| 89 |
|
|---|
| 90 |
def __le__(self, other): |
|---|
| 91 |
return unicode(self._Obj).__le__(other) |
|---|
| 92 |
|
|---|
| 93 |
def __len__(self): |
|---|
| 94 |
return unicode(self._Obj).__len__() |
|---|
| 95 |
|
|---|
| 96 |
def __lt__(self, other): |
|---|
| 97 |
return unicode(self._Obj).__lt__(other) |
|---|
| 98 |
|
|---|
| 99 |
def __mod__(self, other): |
|---|
| 100 |
return unicode(self._Obj).__mod__(other) |
|---|
| 101 |
|
|---|
| 102 |
def __mul__(self, other): |
|---|
| 103 |
return unicode(self._Obj).__mul__(other) |
|---|
| 104 |
|
|---|
| 105 |
def __ne__(self, other): |
|---|
| 106 |
return unicode(self._Obj).__ne__(other) |
|---|
| 107 |
|
|---|
| 108 |
def __reduce__(self): |
|---|
| 109 |
raise NotImplementedError, u'DynamicDocString does not currently support pickling.' |
|---|
| 110 |
|
|---|
| 111 |
def __reduce_ex__(self, protocol): |
|---|
| 112 |
raise NotImplementedError, u'DynamicDocString does not currently support pickling.' |
|---|
| 113 |
|
|---|
| 114 |
def __radd__(self, other): |
|---|
| 115 |
return other.__add__(unicode(self._Obj)) |
|---|
| 116 |
|
|---|
| 117 |
def __repr__(self): |
|---|
| 118 |
return unicode(self._Obj).__repr__() |
|---|
| 119 |
|
|---|
| 120 |
def __rmod__(self, other): |
|---|
| 121 |
return unicode(self._Obj).__rmod__(other) |
|---|
| 122 |
|
|---|
| 123 |
def __rmul__(self, other): |
|---|
| 124 |
return unicode(self._Obj).__rmul__(other) |
|---|
| 125 |
|
|---|
| 126 |
def __str__(self): |
|---|
| 127 |
return str(self._Obj) |
|---|
| 128 |
|
|---|
| 129 |
def __unicode__(self): |
|---|
| 130 |
return unicode(self._Obj) |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
__all__ = ['DynamicDocString'] |
|---|