def unicode_index__RopeUnicode_RopeUnicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): self, start, end = _convert_idx_params(space, w_self, w_start, w_end) sub = w_substr._node res = rope.find(self, sub, start, end) if res < 0: raise OperationError(space.w_ValueError, space.wrap("substring not found in string.index")) return space.wrap(res)
def str_index__Rope_Rope_ANY_ANY(space, w_self, w_sub, w_start, w_end): (self, sub, start, end) = _convert_idx_params(space, w_self, w_sub, w_start, w_end) res = rope.find(self, sub, start, end) if res < 0: raise OperationError(space.w_ValueError, space.wrap("substring not found in string.index")) return wrapint(space, res)
def str_partition__Rope_Rope(space, w_self, w_sub): self = w_self._node sub = w_sub._node if not sub.length(): raise OperationError(space.w_ValueError, space.wrap("empty separator")) pos = rope.find(self, sub) if pos == -1: return space.newtuple([w_self, W_RopeObject.EMPTY, W_RopeObject.EMPTY]) else: return space.newtuple([ W_RopeObject(rope.getslice_one(self, 0, pos)), w_sub, W_RopeObject( rope.getslice_one(self, pos + sub.length(), self.length())) ])
def unicode_partition__RopeUnicode_RopeUnicode(space, w_unistr, w_unisub): self = w_unistr._node sub = w_unisub._node if not sub.length(): raise OperationError(space.w_ValueError, space.wrap("empty separator")) pos = rope.find(self, sub) if pos == -1: return space.newtuple([w_unistr, W_RopeUnicodeObject.EMPTY, W_RopeUnicodeObject.EMPTY]) else: return space.newtuple( [W_RopeUnicodeObject(rope.getslice_one(self, 0, pos)), w_unisub, W_RopeUnicodeObject(rope.getslice_one(self, pos + sub.length(), self.length()))])
def str_find__Rope_Rope_ANY_ANY(space, w_self, w_sub, w_start, w_end): (self, sub, start, end) = _convert_idx_params(space, w_self, w_sub, w_start, w_end) res = rope.find(self, sub, start, end) return wrapint(space, res)
def contains__Rope_Rope(space, w_self, w_sub): self = w_self._node sub = w_sub._node return space.newbool(rope.find(self, sub) >= 0)
def unicode_find__RopeUnicode_RopeUnicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): self, start, end = _convert_idx_params(space, w_self, w_start, w_end) sub = w_substr._node return space.wrap(rope.find(self, sub, start, end))
def contains__RopeUnicode_RopeUnicode(space, w_container, w_item): item = w_item._node container = w_container._node return space.newbool(rope.find(container, item) != -1)