Skip to content

Commit 88f5555

Browse files
committed
[roottest] Make ruff happier with custom_diff.py
1 parent ea7f5e5 commit 88f5555

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

roottest/scripts/custom_diff.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
""" Clever (with filters) compare command using difflib.py providing diffs in four formats:
2-
2+
33
* ndiff: lists every line and highlights interline changes.
44
* context: highlights clusters of changes in a before/after format.
55
* unified: highlights clusters of changes in an inline format.
66
* html: generates side by side comparison with change highlights.
7-
7+
88
"""
9-
import sys, os, time, difflib, optparse, re
9+
import difflib
10+
import optparse
11+
import os
12+
import re
13+
import sys
14+
import time
15+
1016
#---------------------------------------------------------------------------------------------------------------------------
1117
#---Filter and substitutions------------------------------------------------------------------------------------------------
1218

@@ -67,16 +73,16 @@ def main():
6773
parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff')
6874
parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)')
6975
(options, args) = parser.parse_args()
70-
76+
7177
if len(args) == 0:
7278
parser.print_help()
7379
sys.exit(1)
7480
if len(args) != 2:
7581
parser.error("need to specify both a fromfile and tofile")
76-
82+
7783
n = options.lines
7884
fromfile, tofile = args
79-
85+
8086
fromdate = time.ctime(os.stat(fromfile).st_mtime)
8187
todate = time.ctime(os.stat(tofile).st_mtime)
8288
if sys.platform == 'win32':
@@ -91,7 +97,7 @@ def main():
9197

9298
check = difflib.context_diff(nows_fromlines, nows_tolines)
9399
try:
94-
first = next(check)
100+
_ = next(check)
95101
except StopIteration:
96102
sys.exit(0)
97103

@@ -106,12 +112,14 @@ def main():
106112
diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile,tofile,context=options.c,numlines=n)
107113
else:
108114
diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
109-
115+
110116
difflines = [line for line in diff]
111117
sys.stdout.writelines(difflines)
112118

113-
if difflines : sys.exit(1)
114-
else : sys.exit(0)
119+
if difflines:
120+
sys.exit(1)
121+
else:
122+
sys.exit(0)
115123

116124
if __name__ == '__main__':
117125
main()

0 commit comments

Comments
 (0)