def unicode_splitlines__Unicode_ANY(space, w_self, w_keepends): self = w_self._value keepends = 0 if space.int_w(w_keepends): keepends = 1 if len(self) == 0: return space.newlist([]) start = 0 end = len(self) pos = 0 lines = [] while pos < end: if unicodedb.islinebreak(ord(self[pos])): if (self[pos] == u'\r' and pos + 1 < end and self[pos + 1] == u'\n'): # Count CRLF as one linebreak lines.append(W_UnicodeObject(self[start:pos + keepends * 2])) pos += 1 else: lines.append(W_UnicodeObject(self[start:pos + keepends])) pos += 1 start = pos else: pos += 1 if not unicodedb.islinebreak(ord(self[end - 1])): lines.append(W_UnicodeObject(self[start:])) return space.newlist(lines)
def Py_UNICODE_ISLINEBREAK(space, ch): """Return 1 or 0 depending on whether ch is a linebreak character.""" return unicodedb.islinebreak(ord(ch))
def _islinebreak(self, ch): return unicodedb.islinebreak(ord(ch))