Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afb5f94

Browse files
committed
Reverting whitespace normalization. test_difflib fails with it -- the
test depends on invisible trailing whitespace in .py files. The author will have to repair that.
1 parent 45e77c5 commit afb5f94

2 files changed

Lines changed: 47 additions & 47 deletions

File tree

Lib/difflib.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
12891289
if None, all from/to text lines will be generated.
12901290
linejunk -- passed on to ndiff (see ndiff documentation)
12911291
charjunk -- passed on to ndiff (see ndiff documentation)
1292-
1292+
12931293
This function returns an interator which returns a tuple:
12941294
(from line tuple, to line tuple, boolean flag)
12951295
@@ -1300,7 +1300,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
13001300
'\0-' -- marks start of deleted text
13011301
'\0^' -- marks start of changed text
13021302
'\1' -- marks end of added/deleted/changed text
1303-
1303+
13041304
boolean flag -- None indicates context separation, True indicates
13051305
either "from" or "to" line contains a change, otherwise False.
13061306
@@ -1310,13 +1310,13 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
13101310
13111311
Note, this function utilizes the ndiff function to generate the side by
13121312
side difference markup. Optional ndiff arguments may be passed to this
1313-
function and they in turn will be passed to ndiff.
1313+
function and they in turn will be passed to ndiff.
13141314
"""
1315-
import re
1315+
import re
13161316

13171317
# regular expression for finding intraline change indices
13181318
change_re = re.compile('(\++|\-+|\^+)')
1319-
1319+
13201320
# create the difference iterator to generate the differences
13211321
diff_lines_iterator = ndiff(fromlines,tolines,linejunk,charjunk)
13221322

@@ -1375,7 +1375,7 @@ def record_sub_info(match_object,sub_info=sub_info):
13751375
# thing (such as adding the line number) then replace the special
13761376
# marks with what the user's change markup.
13771377
return (num_lines[side],text)
1378-
1378+
13791379
def _line_iterator():
13801380
"""Yields from/to lines of text with a change indication.
13811381
@@ -1392,7 +1392,7 @@ def _line_iterator():
13921392
"""
13931393
lines = []
13941394
num_blanks_pending, num_blanks_to_yield = 0, 0
1395-
while True:
1395+
while True:
13961396
# Load up next 4 lines so we can look ahead, create strings which
13971397
# are a concatenation of the first character of each of the 4 lines
13981398
# so we can do some very readable comparisons.
@@ -1550,7 +1550,7 @@ def _line_pair_iterator():
15501550
<html>
15511551
15521552
<head>
1553-
<meta http-equiv="Content-Type"
1553+
<meta http-equiv="Content-Type"
15541554
content="text/html; charset=ISO-8859-1" />
15551555
<title></title>
15561556
<style type="text/css">%(styles)s
@@ -1573,9 +1573,9 @@ def _line_pair_iterator():
15731573
.diff_sub {background-color:#ffaaaa}"""
15741574

15751575
_table_template = """
1576-
<table class="diff" id="difflib_chg_%(prefix)s_top"
1577-
cellspacing="0" cellpadding="0" rules="groups" >
1578-
<colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup>
1576+
<table class="diff" id="difflib_chg_%(prefix)s_top"
1577+
cellspacing="0" cellpadding="0" rules="groups" >
1578+
<colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup>
15791579
<colgroup></colgroup> <colgroup></colgroup> <colgroup></colgroup>
15801580
%(header_row)s
15811581
<tbody>
@@ -1604,23 +1604,23 @@ class HtmlDiff(object):
16041604
16051605
This class can be used to create an HTML table (or a complete HTML file
16061606
containing the table) showing a side by side, line by line comparision
1607-
of text with inter-line and intra-line change highlights. The table can
1607+
of text with inter-line and intra-line change highlights. The table can
16081608
be generated in either full or contextual difference mode.
1609-
1609+
16101610
The following methods are provided for HTML generation:
16111611
16121612
make_table -- generates HTML for a single side by side table
16131613
make_file -- generates complete HTML file with a single side by side table
16141614
1615-
See tools/scripts/diff.py for an example usage of this class.
1615+
See tools/scripts/diff.py for an example usage of this class.
16161616
"""
16171617

16181618
_file_template = _file_template
16191619
_styles = _styles
16201620
_table_template = _table_template
16211621
_legend = _legend
16221622
_default_prefix = 0
1623-
1623+
16241624
def __init__(self,tabsize=8,wrapcolumn=None,linejunk=None,
16251625
charjunk=IS_CHARACTER_JUNK):
16261626
"""HtmlDiff instance initializer
@@ -1630,7 +1630,7 @@ def __init__(self,tabsize=8,wrapcolumn=None,linejunk=None,
16301630
wrapcolumn -- column number where lines are broken and wrapped,
16311631
defaults to None where lines are not wrapped.
16321632
linejunk,charjunk -- keyword arguments passed into ndiff() (used to by
1633-
HtmlDiff() to generate the side by side HTML differences). See
1633+
HtmlDiff() to generate the side by side HTML differences). See
16341634
ndiff() documentation for argument default values and descriptions.
16351635
"""
16361636
self._tabsize = tabsize
@@ -1655,13 +1655,13 @@ def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False,
16551655
the "next" link anchors before the next change (so click of
16561656
"next" link jumps to just before the change).
16571657
"""
1658-
1658+
16591659
return self._file_template % dict(
16601660
styles = self._styles,
16611661
legend = self._legend,
16621662
table = self.make_table(fromlines,tolines,fromdesc,todesc,
16631663
context=context,numlines=numlines))
1664-
1664+
16651665
def _tab_newline_replace(self,fromlines,tolines):
16661666
"""Returns from/to line lists with tabs expanded and newlines removed.
16671667
@@ -1734,10 +1734,10 @@ def _split_line(self,data_list,line_num,text):
17341734
line1 = line1 + '\1'
17351735
line2 = '\0' + mark + line2
17361736

1737-
# tack on first line onto the output list
1737+
# tack on first line onto the output list
17381738
data_list.append((line_num,line1))
17391739

1740-
# use this routine again to wrap the remaining text
1740+
# use this routine again to wrap the remaining text
17411741
self._split_line(data_list,'>',line2)
17421742

17431743
def _line_wrapper(self,diffs):
@@ -1776,7 +1776,7 @@ def _collect_lines(self,diffs):
17761776
"""
17771777

17781778
fromlist,tolist,flaglist = [],[],[]
1779-
# pull from/to data and flags from mdiff style iterator
1779+
# pull from/to data and flags from mdiff style iterator
17801780
for fromdata,todata,flag in diffs:
17811781
try:
17821782
# store HTML markup of the lines into the lists
@@ -1788,7 +1788,7 @@ def _collect_lines(self,diffs):
17881788
tolist.append(None)
17891789
flaglist.append(flag)
17901790
return fromlist,tolist,flaglist
1791-
1791+
17921792
def _format_line(self,side,flag,linenum,text):
17931793
"""Returns HTML markup of "from" / "to" text lines
17941794
@@ -1802,7 +1802,7 @@ def _format_line(self,side,flag,linenum,text):
18021802
id = ' id="%s%s"' % (self._prefix[side],linenum)
18031803
except TypeError:
18041804
# handle blank lines where linenum is '>' or ''
1805-
id = ''
1805+
id = ''
18061806
# replace those things that would get confused with HTML symbols
18071807
text=text.replace("&","&amp;").replace(">","&gt;").replace("<","&lt;")
18081808

@@ -1825,10 +1825,10 @@ def _make_prefix(self):
18251825

18261826
def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
18271827
"""Makes list of "next" links"""
1828-
1828+
18291829
# all anchor names will be generated using the unique "to" prefix
18301830
toprefix = self._prefix[1]
1831-
1831+
18321832
# process change flags, generating middle column of next anchors/links
18331833
next_id = ['']*len(flaglist)
18341834
next_href = ['']*len(flaglist)
@@ -1840,11 +1840,11 @@ def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
18401840
in_change = True
18411841
last = i
18421842
# at the beginning of a change, drop an anchor a few lines
1843-
# (the context lines) before the change for the previous
1843+
# (the context lines) before the change for the previous
18441844
# link
18451845
i = max([0,i-numlines])
18461846
next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg)
1847-
# at the beginning of a change, drop a link to the next
1847+
# at the beginning of a change, drop a link to the next
18481848
# change
18491849
num_chg += 1
18501850
next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % (
@@ -1891,11 +1891,11 @@ def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
18911891
# make unique anchor prefixes so that multiple tables may exist
18921892
# on the same page without conflict.
18931893
self._make_prefix()
1894-
1894+
18951895
# change tabs to spaces before it gets more difficult after we insert
18961896
# markkup
18971897
fromlines,tolines = self._tab_newline_replace(fromlines,tolines)
1898-
1898+
18991899
# create diffs iterator which generates side by side from/to data
19001900
if context:
19011901
context_lines = numlines
@@ -1907,7 +1907,7 @@ def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
19071907
# set up iterator to wrap lines that exceed desired width
19081908
if self._wrapcolumn:
19091909
diffs = self._line_wrapper(diffs)
1910-
1910+
19111911
# collect up from/to lines and flags into lists (also format the lines)
19121912
fromlist,tolist,flaglist = self._collect_lines(diffs)
19131913

@@ -1947,7 +1947,7 @@ def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
19471947
replace('\0^','<span class="diff_chg">'). \
19481948
replace('\1','</span>'). \
19491949
replace('\t','&nbsp;')
1950-
1950+
19511951
del re
19521952

19531953
def restore(delta, which):

Lib/test/test_difflib.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ def test_comparing_empty_lists(self):
4646
\tLine 2: preceeded by from:[sstt] to:[sssst]
4747
Line 3: preceeded by from:[sstst] to:[ssssss]
4848
Line 4: has from:[sst] to:[sss] after :
49-
Line 5: has from:[t] to:[ss] at end
49+
Line 5: has from:[t] to:[ss] at end
5050
"""
5151

5252
patch914575_from3 = """line 0
5353
1234567890123456789012345689012345
5454
line 1
5555
line 2
5656
line 3
57-
line 4 changed
58-
line 5 changed
59-
line 6 changed
57+
line 4 changed
58+
line 5 changed
59+
line 6 changed
6060
line 7
6161
line 8 subtracted
6262
line 9
@@ -71,9 +71,9 @@ def test_comparing_empty_lists(self):
7171
line 1
7272
line 2 added
7373
line 3
74-
line 4 chanGEd
75-
line 5a chanGed
76-
line 6a changEd
74+
line 4 chanGEd
75+
line 5a chanGed
76+
line 6a changEd
7777
line 7
7878
line 8
7979
line 9
@@ -102,21 +102,21 @@ def test_html_diff(self):
102102
i = difflib.HtmlDiff()
103103
j = difflib.HtmlDiff(tabsize=2)
104104
k = difflib.HtmlDiff(wrapcolumn=14)
105-
105+
106106
full = i.make_file(f1a,t1a,'from','to',context=False,numlines=5)
107107
tables = '\n'.join(
108108
[
109-
'<h2>Context (first diff within numlines=5(default))</h2>',
109+
'<h2>Context (first diff within numlines=5(default))</h2>',
110110
i.make_table(f1a,t1a,'from','to',context=True),
111-
'<h2>Context (first diff after numlines=5(default))</h2>',
111+
'<h2>Context (first diff after numlines=5(default))</h2>',
112112
i.make_table(f1b,t1b,'from','to',context=True),
113-
'<h2>Context (numlines=6)</h2>',
113+
'<h2>Context (numlines=6)</h2>',
114114
i.make_table(f1a,t1a,'from','to',context=True,numlines=6),
115-
'<h2>Context (numlines=0)</h2>',
115+
'<h2>Context (numlines=0)</h2>',
116116
i.make_table(f1a,t1a,'from','to',context=True,numlines=0),
117-
'<h2>Same Context</h2>',
117+
'<h2>Same Context</h2>',
118118
i.make_table(f1a,f1a,'from','to',context=True),
119-
'<h2>Same Full</h2>',
119+
'<h2>Same Full</h2>',
120120
i.make_table(f1a,f1a,'from','to',context=False),
121121
'<h2>Empty Context</h2>',
122122
i.make_table([],[],'from','to',context=True),
@@ -139,8 +139,8 @@ def test_html_diff(self):
139139
#f.write(actual)
140140
#f.close()
141141
expect = open(findfile('test_difflib_expect.html')).read()
142-
143-
142+
143+
144144
self.assertEqual(actual,expect)
145145

146146
Doctests = doctest.DocTestSuite(difflib)

0 commit comments

Comments
 (0)