| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -641,7 +641,7 @@ class RawDescriptionHelpFormatter(HelpFormatter): | |||
| 641 | 641 | """ | |
| 642 | 642 | ||
| 643 | 643 | def _fill_text(self, text, width, indent): | |
| 644 | - return ''.join([indent + line for line in text.splitlines(True)]) | ||
| 644 | + return ''.join(indent + line for line in text.splitlines(keepends=True)) | ||
| 645 | 645 | ||
| 646 | 646 | ||
| 647 | 647 | class RawTextHelpFormatter(RawDescriptionHelpFormatter): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -484,7 +484,7 @@ def read(self, size=-1, chars=-1, firstline=False): | |||
| 484 | 484 | if firstline: | |
| 485 | 485 | newchars, decodedbytes = \ | |
| 486 | 486 | self.decode(data[:exc.start], self.errors) | |
| 487 | - lines = newchars.splitlines(True) | ||
| 487 | + lines = newchars.splitlines(keepends=True) | ||
| 488 | 488 | if len(lines)<=1: | |
| 489 | 489 | raise | |
| 490 | 490 | else: | |
@@ -526,7 +526,7 @@ def readline(self, size=None, keepends=True): | |||
| 526 | 526 | self.charbuffer = self.linebuffer[0] | |
| 527 | 527 | self.linebuffer = None | |
| 528 | 528 | if not keepends: | |
| 529 | - line = line.splitlines(False)[0] | ||
| 529 | + line = line.splitlines(keepends=False)[0] | ||
| 530 | 530 | return line | |
| 531 | 531 | ||
| 532 | 532 | readsize = size or 72 | |
@@ -543,7 +543,7 @@ def readline(self, size=None, keepends=True): | |||
| 543 | 543 | data += self.read(size=1, chars=1) | |
| 544 | 544 | ||
| 545 | 545 | line += data | |
| 546 | - lines = line.splitlines(True) | ||
| 546 | + lines = line.splitlines(keepends=True) | ||
| 547 | 547 | if lines: | |
| 548 | 548 | if len(lines) > 1: | |
| 549 | 549 | # More than one line result; the first line is a full line | |
@@ -559,10 +559,10 @@ def readline(self, size=None, keepends=True): | |||
| 559 | 559 | # only one remaining line, put it back into charbuffer | |
| 560 | 560 | self.charbuffer = lines[0] + self.charbuffer | |
| 561 | 561 | if not keepends: | |
| 562 | - line = line.splitlines(False)[0] | ||
| 562 | + line = line.splitlines(keepends=False)[0] | ||
| 563 | 563 | break | |
| 564 | 564 | line0withend = lines[0] | |
| 565 | - line0withoutend = lines[0].splitlines(False)[0] | ||
| 565 | + line0withoutend = lines[0].splitlines(keepends=False)[0] | ||
| 566 | 566 | if line0withend != line0withoutend: # We really have a line end | |
| 567 | 567 | # Put the rest back together and keep it until the next call | |
| 568 | 568 | self.charbuffer = self._empty_charbuffer.join(lines[1:]) + \ | |
@@ -575,7 +575,7 @@ def readline(self, size=None, keepends=True): | |||
| 575 | 575 | # we didn't get anything or this was our only try | |
| 576 | 576 | if not data or size is not None: | |
| 577 | 577 | if line and not keepends: | |
| 578 | - line = line.splitlines(False)[0] | ||
| 578 | + line = line.splitlines(keepends=False)[0] | ||
| 579 | 579 | break | |
| 580 | 580 | if readsize < 8000: | |
| 581 | 581 | readsize *= 2 | |
@@ -803,7 +803,7 @@ def readlines(self, sizehint=None): | |||
| 803 | 803 | ||
| 804 | 804 | data = self.reader.read() | |
| 805 | 805 | data, bytesencoded = self.encode(data, self.errors) | |
| 806 | - return data.splitlines(1) | ||
| 806 | + return data.splitlines(keepends=True) | ||
| 807 | 807 | ||
| 808 | 808 | def __next__(self): | |
| 809 | 809 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1045,7 +1045,7 @@ def split(self, sep=None, maxsplit=-1): | |||
| 1045 | 1045 | return self.data.split(sep, maxsplit) | |
| 1046 | 1046 | def rsplit(self, sep=None, maxsplit=-1): | |
| 1047 | 1047 | return self.data.rsplit(sep, maxsplit) | |
| 1048 | - def splitlines(self, keepends=0): return self.data.splitlines(keepends) | ||
| 1048 | + def splitlines(self, keepends=False): return self.data.splitlines(keepends) | ||
| 1049 | 1049 | def startswith(self, prefix, start=0, end=_sys.maxsize): | |
| 1050 | 1050 | return self.data.startswith(prefix, start, end) | |
| 1051 | 1051 | def strip(self, chars=None): return self.__class__(self.data.strip(chars)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -800,7 +800,7 @@ class Differ: | |||
| 800 | 800 | ... 2. Explicit is better than implicit. | |
| 801 | 801 | ... 3. Simple is better than complex. | |
| 802 | 802 | ... 4. Complex is better than complicated. | |
| 803 | - ... '''.splitlines(1) | ||
| 803 | + ... '''.splitlines(keepends=True) | ||
| 804 | 804 | >>> len(text1) | |
| 805 | 805 | 4 | |
| 806 | 806 | >>> text1[0][-1] | |
@@ -809,7 +809,7 @@ class Differ: | |||
| 809 | 809 | ... 3. Simple is better than complex. | |
| 810 | 810 | ... 4. Complicated is better than complex. | |
| 811 | 811 | ... 5. Flat is better than nested. | |
| 812 | - ... '''.splitlines(1) | ||
| 812 | + ... '''.splitlines(keepends=True) | ||
| 813 | 813 | ||
| 814 | 814 | Next we instantiate a Differ object: | |
| 815 | 815 | ||
@@ -896,8 +896,8 @@ def compare(self, a, b): | |||
| 896 | 896 | ||
| 897 | 897 | Example: | |
| 898 | 898 | ||
| 899 | - >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1), | ||
| 900 | - ... 'ore\ntree\nemu\n'.splitlines(1))), | ||
| 899 | + >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(True), | ||
| 900 | + ... 'ore\ntree\nemu\n'.splitlines(True))), | ||
| 901 | 901 | ... end="") | |
| 902 | 902 | - one | |
| 903 | 903 | ? ^ | |
@@ -1269,8 +1269,8 @@ def context_diff(a, b, fromfile='', tofile='', | |||
| 1269 | 1269 | ||
| 1270 | 1270 | Example: | |
| 1271 | 1271 | ||
| 1272 | - >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1), | ||
| 1273 | - ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current')), | ||
| 1272 | + >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(True), | ||
| 1273 | + ... 'zero\none\ntree\nfour\n'.splitlines(True), 'Original', 'Current')), | ||
| 1274 | 1274 | ... end="") | |
| 1275 | 1275 | *** Original | |
| 1276 | 1276 | --- Current | |
@@ -1339,8 +1339,8 @@ def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK): | |||
| 1339 | 1339 | ||
| 1340 | 1340 | Example: | |
| 1341 | 1341 | ||
| 1342 | - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), | ||
| 1343 | - ... 'ore\ntree\nemu\n'.splitlines(1)) | ||
| 1342 | + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), | ||
| 1343 | + ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) | ||
| 1344 | 1344 | >>> print(''.join(diff), end="") | |
| 1345 | 1345 | - one | |
| 1346 | 1346 | ? ^ | |
@@ -2034,8 +2034,8 @@ def restore(delta, which): | |||
| 2034 | 2034 | ||
| 2035 | 2035 | Examples: | |
| 2036 | 2036 | ||
| 2037 | - >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), | ||
| 2038 | - ... 'ore\ntree\nemu\n'.splitlines(1)) | ||
| 2037 | + >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), | ||
| 2038 | + ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) | ||
| 2039 | 2039 | >>> diff = list(diff) | |
| 2040 | 2040 | >>> print(''.join(restore(diff, 1)), end="") | |
| 2041 | 2041 | one | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1332,7 +1332,7 @@ def __patched_linecache_getlines(self, filename, module_globals=None): | |||
| 1332 | 1332 | m = self.__LINECACHE_FILENAME_RE.match(filename) | |
| 1333 | 1333 | if m and m.group('name') == self.test.name: | |
| 1334 | 1334 | example = self.test.examples[int(m.group('examplenum'))] | |
| 1335 | - return example.source.splitlines(True) | ||
| 1335 | + return example.source.splitlines(keepends=True) | ||
| 1336 | 1336 | else: | |
| 1337 | 1337 | return self.save_linecache_getlines(filename, module_globals) | |
| 1338 | 1338 | ||
@@ -1595,8 +1595,8 @@ def output_difference(self, example, got, optionflags): | |||
| 1595 | 1595 | # Check if we should use diff. | |
| 1596 | 1596 | if self._do_a_fancy_diff(want, got, optionflags): | |
| 1597 | 1597 | # Split want & got into lines. | |
| 1598 | - want_lines = want.splitlines(True) # True == keep line ends | ||
| 1599 | - got_lines = got.splitlines(True) | ||
| 1598 | + want_lines = want.splitlines(keepends=True) | ||
| 1599 | + got_lines = got.splitlines(keepends=True) | ||
| 1600 | 1600 | # Use difflib to find their differences. | |
| 1601 | 1601 | if optionflags & REPORT_UDIFF: | |
| 1602 | 1602 | diff = difflib.unified_diff(want_lines, got_lines, n=2) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -560,7 +560,7 @@ def refactor_docstring(self, input, filename): | |||
| 560 | 560 | block_lineno = None | |
| 561 | 561 | indent = None | |
| 562 | 562 | lineno = 0 | |
| 563 | - for line in input.splitlines(True): | ||
| 563 | + for line in input.splitlines(keepends=True): | ||
| 564 | 564 | lineno += 1 | |
| 565 | 565 | if line.lstrip().startswith(self.PS1): | |
| 566 | 566 | if block is not None: | |
@@ -604,7 +604,7 @@ def refactor_doctest(self, block, lineno, indent, filename): | |||
| 604 | 604 | filename, lineno, err.__class__.__name__, err) | |
| 605 | 605 | return block | |
| 606 | 606 | if self.refactor_tree(tree, filename): | |
| 607 | - new = str(tree).splitlines(True) | ||
| 607 | + new = str(tree).splitlines(keepends=True) | ||
| 608 | 608 | # Undo the adjustment of the line numbers in wrap_toks() below. | |
| 609 | 609 | clipped, new = new[:lineno-1], new[lineno-1:] | |
| 610 | 610 | assert clipped == ["\n"] * (lineno-1), clipped | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,7 +84,7 @@ def __init__(self, template): | |||
| 84 | 84 | ||
| 85 | 85 | def _invalid(self, mo): | |
| 86 | 86 | i = mo.start('invalid') | |
| 87 | - lines = self.template[:i].splitlines(True) | ||
| 87 | + lines = self.template[:i].splitlines(keepends=True) | ||
| 88 | 88 | if not lines: | |
| 89 | 89 | colno = 1 | |
| 90 | 90 | lineno = 1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -177,7 +177,7 @@ def neitherspacenordigit(c): | |||
| 177 | 177 | return not c.isspace() and not c.isdigit() | |
| 178 | 178 | ||
| 179 | 179 | lines = [] | |
| 180 | - for line in s.splitlines(False): | ||
| 180 | + for line in s.splitlines(keepends=False): | ||
| 181 | 181 | # Drop texts, as they are locale dependent | |
| 182 | 182 | if line and not filter(neitherspacenordigit, line): | |
| 183 | 183 | lines.append(line) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ def _msgobj(self, filename): | |||
| 38 | 38 | return email.message_from_file(fp) | |
| 39 | 39 | ||
| 40 | 40 | def _bytes_repr(self, b): | |
| 41 | - return [repr(x) for x in b.splitlines(True)] | ||
| 41 | + return [repr(x) for x in b.splitlines(keepends=True)] | ||
| 42 | 42 | ||
| 43 | 43 | def assertBytesEqual(self, first, second, msg): | |
| 44 | 44 | """Our byte strings are really encoded strings; improve diff output""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,7 +139,7 @@ def test_buffered_reader(self): | |||
| 139 | 139 | with io.BufferedReader(f) as r: | |
| 140 | 140 | lines = [line for line in r] | |
| 141 | 141 | ||
| 142 | - self.assertEqual(lines, 50 * data1.splitlines(True)) | ||
| 142 | + self.assertEqual(lines, 50 * data1.splitlines(keepends=True)) | ||
| 143 | 143 | ||
| 144 | 144 | def test_readline(self): | |
| 145 | 145 | self.test_write() | |
@@ -340,7 +340,7 @@ def sizes(): | |||
| 340 | 340 | ||
| 341 | 341 | def test_textio_readlines(self): | |
| 342 | 342 | # Issue #10791: TextIOWrapper.readlines() fails when wrapping GzipFile. | |
| 343 | - lines = (data1 * 50).decode("ascii").splitlines(True) | ||
| 343 | + lines = (data1 * 50).decode("ascii").splitlines(keepends=True) | ||
| 344 | 344 | self.test_write() | |
| 345 | 345 | with gzip.GzipFile(self.filename, 'r') as f: | |
| 346 | 346 | with io.TextIOWrapper(f, encoding="ascii") as t: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments