Skip to content

Commit fcded52

Browse files
authored
Rollup merge of rust-lang#45121 - johnthagen:pep8-bootstrap, r=alexcrichton
Fix PEP8 style issues in bootstrap code This fixes PEP8 style issues (other than line-length) in the bootstrap Python code. The most important fix is in the `set` function where the code was indented with 6 spaces instead of 4.
2 parents a460ceb + 3cb5294 commit fcded52

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

src/bootstrap/bootstrap.py

+1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def default_build_triple():
302302

303303
return "{}-{}".format(cputype, ostype)
304304

305+
305306
class RustBuild(object):
306307
"""Provide all the methods required to build Rust"""
307308
def __init__(self):

src/bootstrap/configure.py

+31-17
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,26 @@
1919
sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
2020
import bootstrap
2121

22+
2223
class Option:
2324
def __init__(self, name, rustbuild, desc, value):
2425
self.name = name
2526
self.rustbuild = rustbuild
2627
self.desc = desc
2728
self.value = value
2829

30+
2931
options = []
3032

33+
3134
def o(*args):
3235
options.append(Option(*args, value=False))
3336

37+
3438
def v(*args):
3539
options.append(Option(*args, value=True))
3640

41+
3742
o("debug", "rust.debug", "debug mode; disables optimization unless `--enable-optimize` given")
3843
o("docs", "build.docs", "build standard library documentation")
3944
o("compiler-docs", "build.compiler-docs", "build compiler documentation")
@@ -136,13 +141,16 @@ def v(*args):
136141

137142
v("set", None, "set arbitrary key/value pairs in TOML configuration")
138143

144+
139145
def p(msg):
140146
print("configure: " + msg)
141147

148+
142149
def err(msg):
143150
print("configure: error: " + msg)
144151
sys.exit(1)
145152

153+
146154
if '--help' in sys.argv or '-h' in sys.argv:
147155
print('Usage: ./configure [options]')
148156
print('')
@@ -208,7 +216,7 @@ def err(msg):
208216
continue
209217

210218
found = True
211-
if not option.name in known_args:
219+
if option.name not in known_args:
212220
known_args[option.name] = []
213221
known_args[option.name].append((option, value))
214222
break
@@ -227,27 +235,30 @@ def err(msg):
227235
# TOML we're going to write out
228236
config = {}
229237

238+
230239
def build():
231240
if 'build' in known_args:
232241
return known_args['build'][0][1]
233242
return bootstrap.default_build_triple()
234243

244+
235245
def set(key, value):
236-
s = "{:20} := {}".format(key, value)
237-
if len(s) < 70:
238-
p(s)
239-
else:
240-
p(s[:70] + " ...")
241-
242-
arr = config
243-
parts = key.split('.')
244-
for i, part in enumerate(parts):
245-
if i == len(parts) - 1:
246-
arr[part] = value
247-
else:
248-
if not part in arr:
249-
arr[part] = {}
250-
arr = arr[part]
246+
s = "{:20} := {}".format(key, value)
247+
if len(s) < 70:
248+
p(s)
249+
else:
250+
p(s[:70] + " ...")
251+
252+
arr = config
253+
parts = key.split('.')
254+
for i, part in enumerate(parts):
255+
if i == len(parts) - 1:
256+
arr[part] = value
257+
else:
258+
if part not in arr:
259+
arr[part] = {}
260+
arr = arr[part]
261+
251262

252263
for key in known_args:
253264
# The `set` option is special and can be passed a bunch of times
@@ -345,6 +356,7 @@ def set(key, value):
345356
targets[target] = sections['target'][:]
346357
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target)
347358

359+
348360
# Here we walk through the constructed configuration we have from the parsed
349361
# command line arguments. We then apply each piece of configuration by
350362
# basically just doing a `sed` to change the various configuration line to what
@@ -362,6 +374,7 @@ def to_toml(value):
362374
else:
363375
raise RuntimeError('no toml')
364376

377+
365378
def configure_section(lines, config):
366379
for key in config:
367380
value = config[key]
@@ -375,9 +388,10 @@ def configure_section(lines, config):
375388
if not found:
376389
raise RuntimeError("failed to find config line for {}".format(key))
377390

391+
378392
for section_key in config:
379393
section_config = config[section_key]
380-
if not section_key in sections:
394+
if section_key not in sections:
381395
raise RuntimeError("config key {} not in sections".format(section_key))
382396

383397
if section_key == 'target':

0 commit comments

Comments
 (0)