Skip to content

Commit 867ecf2

Browse files
keeskuba-moo
authored andcommittedOct 4, 2021
style: Apply style diff from yapf3
This is generated from: yapf3 --recursive -d . which ends up with some trade-offs between human and machine readability. Signed-off-by: Kees Cook <[email protected]>
1 parent 776e7a8 commit 867ecf2

File tree

18 files changed

+56
-73
lines changed

18 files changed

+56
-73
lines changed
 

‎core/cmd.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class CmdError(Exception):
2525
stderr : str
2626
standard output of the command which failed
2727
"""
28-
2928
def __init__(self, cmd, retcode, stdout, stderr):
3029
super().__init__(cmd, retcode, stdout, stderr)
3130

@@ -35,8 +34,7 @@ def __init__(self, cmd, retcode, stdout, stderr):
3534
self.stderr = stderr
3635

3736

38-
def cmd_run(cmd: list[str], shell=False, include_stderr=False, add_env=None, cwd=None,
39-
pass_fds=()):
37+
def cmd_run(cmd: list[str], shell=False, include_stderr=False, add_env=None, cwd=None, pass_fds=()):
4038
"""Run a command.
4139
4240
Run a command in subprocess and return the stdout;
@@ -74,8 +72,8 @@ def cmd_run(cmd: list[str], shell=False, include_stderr=False, add_env=None, cwd
7472

7573
core.log("START", datetime.datetime.now().strftime("%H:%M:%S.%f"))
7674

77-
process = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE,
78-
stderr=subprocess.PIPE, env=env, cwd=cwd, pass_fds=pass_fds)
75+
process = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
76+
env=env, cwd=cwd, pass_fds=pass_fds)
7977

8078
core.log_open_sec("CMD " + str(process.args))
8179

@@ -98,8 +96,8 @@ def cmd_run(cmd: list[str], shell=False, include_stderr=False, add_env=None, cwd
9896
if process.returncode != 0:
9997
if stderr and stderr[-1] == "\n":
10098
stderr = stderr[:-1]
101-
raise CmdError("Command failed: %s" % (str(process.args), ),
102-
process.returncode, stdout, stderr)
99+
raise CmdError("Command failed: %s" % (str(process.args), ), process.returncode, stdout,
100+
stderr)
103101

104102
if not include_stderr:
105103
return stdout

‎core/logger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def log_init(name, path, force_single_thread=False):
205205
global tls
206206

207207
if force_single_thread:
208-
tls = type('nothing', (object,), {})()
208+
tls = type('nothing', (object, ), {})()
209209

210210
if name.lower() == 'stdout':
211211
tls.logger = StdoutLogger()

‎core/patch.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class Patch(object):
2929
write_out(fp)
3030
Write the raw patch into the given file pointer.
3131
"""
32-
3332
def __init__(self, raw_patch, ident=None, title=""):
3433
self.raw_patch = raw_patch
3534
self.title = title

‎core/series.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class Series(object):
1414
"""Patch series class
1515
1616
"""
17-
1817
def __init__(self, ident=None, title=""):
1918
self.cover_letter = None
2019
self.cover_pull = None

‎core/test.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Test(object):
1818
"""Test class
1919
2020
"""
21-
2221
def __init__(self, path, name):
2322
self.path = path
2423
self.name = name
@@ -30,9 +29,7 @@ def __init__(self, path, name):
3029
# Load dynamically the python func
3130
if "pymod" in self.info:
3231
test_group = os.path.basename(os.path.dirname(path))
33-
m = importlib.import_module("tests.%s.%s.%s" %
34-
(test_group, name,
35-
self.info["pymod"]))
32+
m = importlib.import_module("tests.%s.%s.%s" % (test_group, name, self.info["pymod"]))
3633
self._exec_pyfunc = getattr(m, self.info["pyfunc"])
3734
if "run" in self.info:
3835
# If the test to run is not a fully qualified path, add the
@@ -74,7 +71,7 @@ def write_result(self, result_dir, retcode=0, out="", err="", desc=""):
7471
elif retcode == 250:
7572
fp.write("%s - WARNING\n" % (self.name, ))
7673
else:
77-
fp.write("%s - FAILED\n" % (self.name,))
74+
fp.write("%s - FAILED\n" % (self.name, ))
7875
fp.write("\n")
7976
if err.strip():
8077
if err[:-1] != '\n':
@@ -119,9 +116,8 @@ def _exec_run(self, tree, thing, result_dir):
119116
try:
120117
rfd, wfd = os.pipe()
121118

122-
out, err = CMD.cmd_run(self.info["run"],
123-
include_stderr=True, cwd=tree.path, pass_fds=[wfd],
124-
add_env={"DESC_FD": str(wfd)})
119+
out, err = CMD.cmd_run(self.info["run"], include_stderr=True, cwd=tree.path,
120+
pass_fds=[wfd], add_env={"DESC_FD": str(wfd)})
125121
except core.cmd.CmdError as e:
126122
retcode = e.retcode
127123
out = e.stdout

‎core/tester.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def run(self) -> None:
6565
config = configparser.ConfigParser()
6666
config.read(['nipa.config', 'pw.config', 'tester.config'])
6767

68-
core.log_init(config.get('log', 'type', fallback='org'),
69-
config.get('log', 'file', fallback=os.path.join(core.NIPA_DIR,
70-
f"{self.tree.name}.org")))
68+
core.log_init(
69+
config.get('log', 'type', fallback='org'),
70+
config.get('log', 'file', fallback=os.path.join(core.NIPA_DIR, f"{self.tree.name}.org")))
7171

7272
core.log_open_sec("Tester init")
7373
if not os.path.exists(self.result_dir):
@@ -102,8 +102,7 @@ def test_series(self, tree, series):
102102
mark_done(self.result_dir, series)
103103

104104
def _test_series(self, tree, series):
105-
core.log_open_sec("Running tests in tree %s for %s" %
106-
(tree.name, series.title))
105+
core.log_open_sec("Running tests in tree %s for %s" % (tree.name, series.title))
107106

108107
series_dir = os.path.join(self.result_dir, str(series.id))
109108
if not os.path.exists(series_dir):

‎core/tree.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Tree:
2626
2727
Git tree class which controls a git tree
2828
"""
29-
3029
def __init__(self, name, pfx, fspath, remote=None, branch=None):
3130
self.name = name
3231
self.pfx = pfx
@@ -71,8 +70,9 @@ def git_reset(self, target, hard=False):
7170
return self.git(cmd)
7271

7372
def git_find_patch(self, needle, depth=1000):
74-
cmd = ["log", "--pretty=format:'%h'", f"HEAD~{depth}..HEAD",
75-
f"--grep={needle}", "--fixed-string"]
73+
cmd = [
74+
"log", "--pretty=format:'%h'", f"HEAD~{depth}..HEAD", f"--grep={needle}", "--fixed-string"
75+
]
7676
return self.git(cmd)
7777

7878
def _check_tree(self):
@@ -153,8 +153,7 @@ def apply(self, thing):
153153
for patch in thing.patches:
154154
self._apply_patch_safe(patch)
155155
else:
156-
raise Exception("Can't apply object '%s' to the git tree" %
157-
(type(thing),))
156+
raise Exception("Can't apply object '%s' to the git tree" % (type(thing), ))
158157

159158
def check_applies(self, thing):
160159
core.log_open_sec("Test-applying " + thing.title)

‎ingest_mdir.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@
2626
config = configparser.ConfigParser()
2727
config.read(['nipa.config', "tester.config"])
2828

29-
results_dir = config.get('results', 'dir',
30-
fallback=os.path.join(NIPA_DIR, "results"))
29+
results_dir = config.get('results', 'dir', fallback=os.path.join(NIPA_DIR, "results"))
3130

3231
# TODO: use config
3332
parser = argparse.ArgumentParser()
34-
parser.add_argument('--mdir', required=True,
35-
help='path to the directory with the patches')
36-
parser.add_argument('--tree', required=True,
37-
help='path to the tree to test on')
38-
parser.add_argument('--tree-name', default='unknown',
39-
help='the tree name to expect')
33+
parser.add_argument('--mdir', required=True, help='path to the directory with the patches')
34+
parser.add_argument('--tree', required=True, help='path to the tree to test on')
35+
parser.add_argument('--tree-name', default='unknown', help='the tree name to expect')
4036
parser.add_argument('--tree-branch', default='master',
4137
help='the branch or commit to use as a base for applying patches')
4238
parser.add_argument('--result-dir', default=results_dir,
@@ -100,4 +96,5 @@
10096
tester.join()
10197

10298
# Summary hack
103-
os.system(f'for i in $(find {args.result_dir} -type f -name summary); do dir=$(dirname "$i"); head -n2 "$dir"/summary; cat "$dir"/desc 2>/dev/null; done')
99+
os.system(f'for i in $(find {args.result_dir} -type f -name summary); do dir=$(dirname "$i"); head -n2 "$dir"/summary; cat "$dir"/desc 2>/dev/null; done'
100+
)

‎pw/patchwork.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def get_projects_all(self):
118118
def get_series_all(self, project=None, since=None):
119119
if project is None:
120120
project = self._project
121-
return self.get_all('series', {'project': project,
122-
'since': since})
121+
return self.get_all('series', {'project': project, 'since': since})
123122

124123
def post_check(self, patch, name, state, url, desc):
125124
headers = {}

‎pw/pw_series.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def __init__(self, pw, pw_series):
1919
self.pw_series = pw_series
2020

2121
if pw_series['cover_letter']:
22-
pw_cover_letter = pw.get_mbox('cover',
23-
pw_series['cover_letter']['id'])
22+
pw_cover_letter = pw.get_mbox('cover', pw_series['cover_letter']['id'])
2423
self.set_cover_letter(pw_cover_letter)
2524
elif self.pw_series['patches']:
2625
self.subject = self.pw_series['patches'][0]['name']
@@ -92,7 +91,7 @@ def fixup_pull_covers(self):
9291
reply_to = None
9392

9493
for line in lines:
95-
if line == "": # end of headers
94+
if line == "": # end of headers
9695
if reply_to is None:
9796
log("Patch had no reply header", "")
9897
all_reply = False
@@ -110,8 +109,7 @@ def fixup_pull_covers(self):
110109
log("Mismatch in replies", "")
111110
log("Result", all_reply)
112111
if all_reply:
113-
covers = self.pw.get_all('patches', filters={'msgid': all_reply},
114-
api='1.2')
112+
covers = self.pw.get_all('patches', filters={'msgid': all_reply}, api='1.2')
115113
if len(covers) != 1:
116114
log('Unique cover letter not found', len(covers))
117115
else:

‎pw_poller.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def __init__(self) -> None:
3333
config.read(['nipa.config', 'pw.config', 'poller.config'])
3434

3535
log_init(config.get('log', 'type', fallback='org'),
36-
config.get('log', 'file', fallback=os.path.join(NIPA_DIR,
37-
"poller.org")))
36+
config.get('log', 'file', fallback=os.path.join(NIPA_DIR, "poller.org")))
3837

3938
# TODO: make this non-static / read from a config
4039
self._trees = {
@@ -49,7 +48,8 @@ def __init__(self) -> None:
4948
self._done_queue = queue.Queue()
5049
self._workers = {}
5150
for k, tree in self._trees.items():
52-
self._workers[k] = Tester(self.result_dir, tree, queue.Queue(), self._done_queue, self._barrier)
51+
self._workers[k] = Tester(self.result_dir, tree, queue.Queue(), self._done_queue,
52+
self._barrier)
5353
self._workers[k].start()
5454
log(f"Started worker {self._workers[k].name} for {k}")
5555

@@ -127,11 +127,9 @@ def _process_series(self, pw_series) -> None:
127127

128128
s = PwSeries(self._pw, pw_series)
129129

130-
log("Series info",
131-
f"Series ID {s['id']}\n" +
132-
f"Series title {s['name']}\n" +
133-
f"Author {s['submitter']['name']}\n" +
134-
f"Date {s['date']}")
130+
log(
131+
"Series info", f"Series ID {s['id']}\n" + f"Series title {s['name']}\n" +
132+
f"Author {s['submitter']['name']}\n" + f"Date {s['date']}")
135133
log_open_sec('Patches')
136134
for p in s['patches']:
137135
log(p['name'], "")

‎pw_upload.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def _pw_upload_results(series_dir, pw, config):
8686
for _, test_dirs, _ in os.walk(patch_dir):
8787
for test in test_dirs:
8888
tr = PwTestResult(test, patch_dir, f"{result_server}/{series}/{patch}/{test}")
89-
pw.post_check(patch=patch, name=tr.test, state=tr.state, url=tr.url, desc=tr.desc)
89+
pw.post_check(patch=patch, name=tr.test, state=tr.state, url=tr.url,
90+
desc=tr.desc)
9091

9192
log(f"Patch {patch} - found {len(test_dirs)} results")
9293
break
@@ -194,19 +195,19 @@ def main():
194195
config.read(['nipa.config', 'pw.config', 'upload.config'])
195196

196197
log_init(config.get('log', 'type', fallback='org'),
197-
config.get('log', 'file', fallback=os.path.join(NIPA_DIR,
198-
"upload.org")),
198+
config.get('log', 'file', fallback=os.path.join(NIPA_DIR, "upload.org")),
199199
force_single_thread=True)
200200

201-
results_dir = config.get('results', 'dir',
202-
fallback=os.path.join(NIPA_DIR, "results"))
201+
results_dir = config.get('results', 'dir', fallback=os.path.join(NIPA_DIR, "results"))
203202

204203
pw = Patchwork(config)
205204

206205
signal.signal(signal.SIGTERM, handler)
207206
signal.signal(signal.SIGINT, handler)
208-
tw = TestWatcher(results_dir, '.tester_done', '.pw_done',
209-
pw_upload_results_cb, {'pw': pw, 'config': config})
207+
tw = TestWatcher(results_dir, '.tester_done', '.pw_done', pw_upload_results_cb, {
208+
'pw': pw,
209+
'config': config
210+
})
210211
tw.initial_scan()
211212
tw.watch()
212213

‎tests/patch/cc_maintainers/test.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@
88
import subprocess
99
import tempfile
1010
import re
11-
1211
""" Test if relevant maintainers were CCed """
1312

1413
emailpat = re.compile(r'([^ <"]*@[^ >"]*)')
1514

16-
ignore_emails = {'linux-kernel@vger.kernel.org', # Don't expect people to CC LKML on everything
17-
'nipa@patchwork.hopto.org', # For new files NIPA will get marked as committer
18-
'jeffrey.t.kirsher@intel.com'}
15+
ignore_emails = {
16+
'linux-kernel@vger.kernel.org', # Don't expect people to CC LKML on everything
17+
'nipa@patchwork.hopto.org', # For new files NIPA will get marked as committer
18+
'jeffrey.t.kirsher@intel.com'
19+
}
1920

2021
# Maintainers who don't CC their co-employees
21-
maintainers = {'michael.chan@broadcom.com': ['@broadcom.com'],
22-
'huangguangbin2@huawei.com': ['@huawei.com', '@hisilicon.com'],
23-
'anthony.l.nguyen@intel.com': ['@intel.com', '@lists.osuosl.org'],
24-
'saeed@kernel.org': ['@nvidia.com', '@mellanox.com',
25-
'leon@kernel.org', 'linux-rdma@vger.kernel.org' ]}
22+
maintainers = {
23+
'michael.chan@broadcom.com': ['@broadcom.com'],
24+
'huangguangbin2@huawei.com': ['@huawei.com', '@hisilicon.com'],
25+
'anthony.l.nguyen@intel.com': ['@intel.com', '@lists.osuosl.org'],
26+
'saeed@kernel.org': [
27+
'@nvidia.com', '@mellanox.com', 'leon@kernel.org', 'linux-rdma@vger.kernel.org'
28+
]
29+
}
2630

2731

2832
def cc_maintainers(tree, thing, result_dir) -> Tuple[int, str]:

‎tests/patch/signed/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from typing import Tuple
66
import subprocess
7-
87
""" Test if the patch passes signature checks """
98

9+
1010
def signed(tree, thing, result_dir) -> Tuple[int, str]:
1111
command = ['patatt', 'validate']
1212
p = subprocess.run(command, cwd=tree.path, input=thing.raw_patch.encode(),

‎tests/series/cover_letter/test.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Copyright (C) 2019 Netronome Systems, Inc.
44

55
from typing import Tuple
6-
76
""" Test presence of a cover letter """
87

98

‎tests/series/fixes_present/test.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66

77
from typing import Tuple
8-
98
""" Test presence of the Fixes tag in non *-next patches """
109

1110

‎tests/series/patch_count/test.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Copyright (C) 2019 Netronome Systems, Inc.
44

55
from typing import Tuple
6-
76
""" Test number of patches, we have a 15 patch limit on netdev """
87

98

‎tests/series/subject_prefix/test.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Copyright (C) 2019 Netronome Systems, Inc.
44

55
from typing import Tuple
6-
76
""" Test if subject prefix (tree designation) is present """
87

98

0 commit comments

Comments
 (0)
Please sign in to comment.