1 #!/usr/bin/env python 2 3 """ 4 String objects. 5 6 Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 7 8 This program is free software; you can redistribute it and/or modify it under 9 the terms of the GNU General Public License as published by the Free Software 10 Foundation; either version 3 of the License, or (at your option) any later 11 version. 12 13 This program is distributed in the hope that it will be useful, but WITHOUT 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 details. 17 18 You should have received a copy of the GNU General Public License along with 19 this program. If not, see <http://www.gnu.org/licenses/>. 20 """ 21 22 from __builtins__.iterator import listiterator 23 from __builtins__.operator import _binary_op, _negate 24 import native 25 26 class basestring(object): 27 def __init__(self, data=None): 28 # Note member. 29 self.data = data 30 31 def __contains__(self, value): pass 32 33 def __getitem__(self, index): 34 # Note usage. 35 IndexError 36 37 def __getslice__(self, start, end=None): pass 38 39 def __iadd__(self, other): 40 "Return a new string for the operation." 41 return _binary_op(self, other, native._str_add) 42 43 __add__ = __radd__ = __iadd__ 44 45 def __mul__(self, other): pass 46 def __rmul__(self, other): pass 47 def __mod__(self, other): pass 48 def __rmod__(self, other): pass 49 50 def __lt__(self, other): 51 "Return a new boolean for the comparison." 52 return _binary_op(self, other, native._str_lt) 53 54 def __gt__(self, other): 55 "Return a new boolean for the comparison." 56 return _binary_op(self, other, native._str_gt) 57 58 def __le__(self, other): 59 "Return a new boolean for the comparison." 60 return _negate(self.__gt__(other)) 61 62 def __ge__(self, other): 63 "Return a new boolean for the comparison." 64 return _negate(self.__lt__(other)) 65 66 def __eq__(self, other): 67 "Return a new boolean for the comparison." 68 return _binary_op(self, other, native._str_eq) 69 70 def __ne__(self, other): 71 "Return a new boolean for the comparison." 72 return _negate(self.__eq__(other)) 73 74 def __len__(self): pass 75 def __str__(self): pass 76 77 def __bool__(self): 78 return _negate(native._str_eq(self, "")) 79 80 def endswith(self, s): pass 81 def find(self, sub, start=None, end=None): pass 82 def index(self, sub, start=None, end=None): pass 83 def join(self, l): pass 84 def lower(self): pass 85 def lstrip(self, chars=None): pass 86 def replace(self, old, new, count=None): pass 87 def rfind(self, sub, start=None, end=None): pass 88 def rsplit(self, sep=None, maxsplit=None): pass 89 def rstrip(self, chars=None): pass 90 def split(self, sep=None, maxsplit=None): pass 91 def splitlines(self, keepends=False): pass 92 def startswith(self, s): pass 93 def strip(self, chars=None): pass 94 def upper(self): pass 95 96 def __iter__(self): 97 98 "Return an iterator." 99 100 return listiterator(self) 101 102 class str(basestring): 103 pass 104 105 class unicode(basestring): 106 def encode(self, encoding): pass 107 108 # vim: tabstop=4 expandtab shiftwidth=4