def unicode_startswith__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): self, substr, start, end = _convert_idx_params(space, w_self, w_substr, w_start, w_end, True) # XXX this stuff can be waaay better for ootypebased backends if # we re-use more of our rpython machinery (ie implement startswith # with additional parameters as rpython) return space.newbool(stringstartswith(self, substr, start, end))
def unicode_startswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_prefixes, w_start, w_end): unistr, _, start, end = _convert_idx_params(space, w_unistr, space.wrap(u""), w_start, w_end, True) for w_prefix in space.fixedview(w_prefixes): prefix = space.unicode_w(w_prefix) if stringstartswith(unistr, prefix, start, end): return space.w_True return space.w_False
def str_startswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end): (u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(''), w_start, w_end) for w_prefix in space.viewiterable(w_prefixes): prefix = space.str_w(w_prefix) if stringstartswith(u_self, prefix, start, end): return space.w_True return space.w_False
def unicode_startswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_prefixes, w_start, w_end): unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end, True) for w_prefix in space.fixedview(w_prefixes): prefix = space.unicode_w(w_prefix) if stringstartswith(unistr, prefix, start, end): return space.w_True return space.w_False
def PyUnicode_Tailmatch(space, w_str, w_substr, start, end, direction): """Return 1 if substr matches str[start:end] at the given tail end (direction == -1 means to do a prefix match, direction == 1 a suffix match), 0 otherwise. Return -1 if an error occurred.""" str = space.unicode_w(w_str) substr = space.unicode_w(w_substr) if rffi.cast(lltype.Signed, direction) >= 0: return stringtype.stringstartswith(str, substr, start, end) else: return stringtype.stringendswith(str, substr, start, end)
def str_startswith__String_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end): (u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(""), w_start, w_end, True) for w_prefix in space.fixedview(w_prefixes): if space.is_true(space.isinstance(w_prefix, space.w_unicode)): w_u = space.call_function(space.w_unicode, w_self) return space.call_method(w_u, "startswith", w_prefixes, w_start, w_end) prefix = space.str_w(w_prefix) if stringstartswith(u_self, prefix, start, end): return space.w_True return space.w_False
def PyUnicode_Tailmatch(space, w_str, w_substr, start, end, direction): """Return 1 if substr matches str[start:end] at the given tail end (direction == -1 means to do a prefix match, direction == 1 a suffix match), 0 otherwise. Return -1 if an error occurred.""" str = space.unicode_w(w_str) substr = space.unicode_w(w_substr) if rffi.cast(lltype.Signed, direction) <= 0: return stringtype.stringstartswith(str, substr, start, end) else: return stringtype.stringendswith(str, substr, start, end)
def str_startswith__String_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end): (u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(''), w_start, w_end, True) for w_prefix in space.fixedview(w_prefixes): if space.is_true(space.isinstance(w_prefix, space.w_unicode)): w_u = space.call_function(space.w_unicode, w_self) return space.call_method(w_u, "startswith", w_prefixes, w_start, w_end) prefix = space.str_w(w_prefix) if stringstartswith(u_self, prefix, start, end): return space.w_True return space.w_False
def str_startswith__StringSlice_String_ANY_ANY(space, w_self, w_prefix, w_start, w_end): (u_self, prefix, start, end) = _convert_idx_params(space, w_self, w_prefix, w_start, w_end) return space.newbool(stringstartswith(u_self, prefix, start, end))
def str_startswith__String_String_ANY_ANY(space, w_self, w_prefix, w_start, w_end): (u_self, prefix, start, end) = _convert_idx_params(space, w_self, w_prefix, w_start, w_end, True) return space.newbool(stringstartswith(u_self, prefix, start, end))
def str_startswith__String_String_ANY_ANY(space, w_self, w_prefix, w_start, w_end): (u_self, start, end) = _convert_idx_params(space, w_self, w_start, w_end, True) return space.newbool(stringstartswith(u_self, w_prefix._value, start, end))