Skip to content

Commit 492f8f9

Browse files
authored
Merge pull request #4698 from mwichmann/tools/progress
Update progress-printing for tools
2 parents 7c427ad + 2d27400 commit 492f8f9

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3030
present in three of the 11 "live" tests, but not the other eight.
3131
Also, all 11 now pass the test-discovered xslt processor the same
3232
way, which was not the case previously.
33+
- Update progress printing on three tools for SCons developers -
34+
the test runner and two of the doc generators.
3335

3436

3537
RELEASE 4.9.0 - Sun, 02 Mar 2025 17:22:20 -0700

bin/SConsDoc.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,11 @@ def __init__(self, name_, uri_):
199199
self.name = name_
200200
self.uri = uri_
201201

202-
def getEntityString(self):
203-
txt = """ <!ENTITY %(perc)s %(name)s SYSTEM "%(uri)s">
204-
%(perc)s%(name)s;
205-
""" % {'perc': perc, 'name': self.name, 'uri': self.uri}
206-
207-
return txt
202+
def getEntityString(self) -> str:
203+
return f"""\
204+
<!ENTITY % {self.name} SYSTEM "{self.uri}">
205+
%{self.name};
206+
"""
208207

209208

210209
class DoctypeDeclaration:
@@ -417,8 +416,6 @@ def __del__(self):
417416
if self.xpath_context is not None:
418417
self.xpath_context.xpathFreeContext()
419418

420-
perc = "%"
421-
422419
def validate_all_xml(dpaths, xsdfile=default_xsd):
423420
xmlschema_context = etree.parse(xsdfile)
424421

@@ -438,10 +435,7 @@ def validate_all_xml(dpaths, xsdfile=default_xsd):
438435
fails = []
439436
fpaths = sorted(fpaths)
440437
for idx, fp in enumerate(fpaths):
441-
fpath = os.path.join(path, fp)
442-
print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 /float(len(fpaths)),
443-
perc, idx + 1, len(fpaths), fp))
444-
438+
print(f"{(idx + 1) / len(fpaths):7.2%} ({idx + 1}/{len(fpaths)}) {fp}")
445439
if not tf.validateXml(fp, xmlschema_context):
446440
fails.append(fp)
447441
continue

bin/SConsExamples.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ def createAllExampleOutputs(dpath):
309309

310310
for key, value in examples.items():
311311
# Process all scons_output tags
312-
print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total),
313-
perc, idx + 1, total, key))
314-
312+
print(f"{(idx + 1) / total:7.2%} ({idx + 1}/{total}) {key}")
315313
create_scons_output(value)
316314
# Process all scons_example_file tags
317315
for r in value.files:

runtest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,9 @@ def run_test(t, io_lock=None, run_async=True):
796796
t.command_str = " ".join(t.command_args)
797797
if args.printcommand:
798798
if args.print_progress:
799-
t.headline += "%d/%d (%.2f%s) %s\n" % (
800-
t.testno, total_num_tests,
801-
float(t.testno) * 100.0 / float(total_num_tests),
802-
"%",
803-
t.command_str,
799+
t.headline += (
800+
f"{t.testno}/{total_num_tests} "
801+
f"({t.testno / total_num_tests:7.2%}) {t.command_str}\n"
804802
)
805803
else:
806804
t.headline += t.command_str + "\n"

0 commit comments

Comments
 (0)