From 0cd2bd3168849eecb7ea2e7e61547fe5d7666234 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 12 Jul 2012 09:03:05 -0400 Subject: [PATCH] Some bugfixes and additions to the MixIn. (Don't mind me, just developing software on Amtrak on the way to Wikimania). --- mwparserfromhell/string_mixin.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/mwparserfromhell/string_mixin.py b/mwparserfromhell/string_mixin.py index c0a4460..8ddf699 100644 --- a/mwparserfromhell/string_mixin.py +++ b/mwparserfromhell/string_mixin.py @@ -30,34 +30,47 @@ class StringMixIn(object): # UnicodeMixIn? return repr(unicode(self)) def __lt__(self, other): - if isinstance(other, unicodeingMixin): + if isinstance(other, StringMixin): return unicode(self) < unicode(other) return unicode(self) < other def __le__(self, other): - if isinstance(other, unicodeingMixin): + if isinstance(other, StringMixin): return unicode(self) <= unicode(other) return unicode(self) <= other def __eq__(self, other): - if isinstance(other, unicodeingMixin): + if isinstance(other, StringMixin): return unicode(self) == unicode(other) return unicode(self) == other def __ne__(self, other): - if isinstance(other, unicodeingMixin): + if isinstance(other, StringMixin): return unicode(self) != unicode(other) return unicode(self) != other def __gt__(self, other): - if isinstance(other, unicodeingMixin): + if isinstance(other, StringMixin): return unicode(self) > unicode(other) return unicode(self) > other def __ge__(self, other): - if isinstance(other, unicodeingMixin): + if isinstance(other, StringMixin): return unicode(self) >= unicode(other) return unicode(self) >= other + def __nonzero__(self): + return bool(unicode(self)) + + def __len__(self): + return len(unicode(self)) + + def __iter__(self): + for char in unicode(self): + yield char + def __getitem__(self, index): return unicode(self)[index] + + def __contains__(self, item): + return item in unicode(self)