Lichen

lib/__builtins__/str.py

219:575d530042c6
2016-11-23 Paul Boddie Prevent iteration over strings. Added a docstring to NoneType.
     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__ = ""    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):    75         return native._str_len(self)    76     77     def __str__(self):    78         return self    79     80     def __bool__(self):    81         return native._str_nonempty(self)    82     83     def endswith(self, s): pass    84     def find(self, sub, start=None, end=None): pass    85     def index(self, sub, start=None, end=None): pass    86     def join(self, l): pass    87     def lower(self): pass    88     def lstrip(self, chars=None): pass    89     def replace(self, old, new, count=None): pass    90     def rfind(self, sub, start=None, end=None): pass    91     def rsplit(self, sep=None, maxsplit=None): pass    92     def rstrip(self, chars=None): pass    93     def split(self, sep=None, maxsplit=None): pass    94     def splitlines(self, keepends=False): pass    95     def startswith(self, s): pass    96     def strip(self, chars=None): pass    97     def upper(self): pass    98     99 class string(basestring):   100     pass   101    102 class unicode(basestring):   103     def encode(self, encoding): pass   104    105 def str(obj):   106    107     "Return the string representation of 'obj'."   108    109     return obj.__str__()   110    111 # vim: tabstop=4 expandtab shiftwidth=4