Skip to content

Commit ba705b1

Browse files
reverted tools changes
1 parent 00187c0 commit ba705b1

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

tools/maintenance.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
Test Learning Path
2323
"""
2424
def check_lp(lp_path, link, debug):
25-
test_image_results = None # initialize the variable
2625
if not os.path.isdir(lp_path):
2726
lp_path = os.path.dirname(lp_path)
2827

@@ -157,13 +156,10 @@ def main():
157156
if args.stats_report:
158157
# If all test results are zero, all tests have passed
159158
patch.patch(args.instructions, results_dict, args.link)
160-
if results_dict is not None:
161-
if all(results_dict.get(k) for k in results_dict):
162-
# Errors exist
163-
logging.info("Tests failed in test suite")
164-
sys.exit(1)
165-
else:
166-
pass
159+
if all(results_dict.get(k) for k in results_dict):
160+
# Errors exist
161+
logging.info("Tests failed in test suite")
162+
sys.exit(1)
167163
elif args.spelling:
168164
logging.info(f"Checking spelling of {args.spelling}")
169165
output = parse.spelling(args.spelling)

tools/patch.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def patch(article_path: str, results: dict, link: str):
1616
article_path_pure = PurePath(re.sub(r"^.*?content/", "", article_path))
1717
article_path_parts = list(article_path_pure.parts)
1818
if "learning-paths" in article_path_parts:
19-
content_type, sw_category, content_title, *others_1 = article_path_parts
19+
content_type, sw_category, content_title = article_path_parts
2020
article_path = PurePath(article_path, "_index.md")
2121
elif "install-guides" in article_path_parts:
2222
# In case the install guide is in a subdirectory
@@ -30,33 +30,30 @@ def patch(article_path: str, results: dict, link: str):
3030
else:
3131
raise SystemExit("Unknown content path, pass learning paths or install guides only")
3232

33-
if results is not None:
34-
test_images = results.keys()
35-
results_values = defaultdict(lambda: "failed")
36-
results_values[0] = "passed"
33+
test_images = results.keys()
34+
results_values = defaultdict(lambda: "failed")
35+
results_values[0] = "passed"
3736

38-
content_data = data["sw_categories"][sw_category][content_title]
37+
content_data = data["sw_categories"][sw_category][content_title]
3938

40-
# Create 'tests_and_status' if it doesn't exist
41-
if "tests_and_status" not in content_data or not isinstance(content_data["tests_and_status"], list):
42-
content_data["tests_and_status"] = [{} for _ in range(len(test_images))]
39+
# Create 'tests_and_status' if it doesn't exist
40+
if "tests_and_status" not in content_data or not isinstance(content_data["tests_and_status"], list):
41+
content_data["tests_and_status"] = [{} for _ in range(len(test_images))]
4342

44-
# If 'tests_and_status' exists but is too short, extend it
45-
if len(content_data["tests_and_status"]) < len(test_images):
46-
additional_entries = [{} for _ in range(len(test_images) - len(content_data["tests_and_status"]))]
47-
content_data["tests_and_status"].extend(additional_entries)
43+
# If 'tests_and_status' exists but is too short, extend it
44+
if len(content_data["tests_and_status"]) < len(test_images):
45+
additional_entries = [{} for _ in range(len(test_images) - len(content_data["tests_and_status"]))]
46+
content_data["tests_and_status"].extend(additional_entries)
4847

49-
# Now safe to index
50-
for i, image in enumerate(test_images):
51-
idx = min(i, len(content_data["tests_and_status"]) - 1)
52-
content_data["tests_and_status"][idx][image] = results_values[results[image]]
48+
# Now safe to index
49+
for i, image in enumerate(test_images):
50+
idx = min(i, len(content_data["tests_and_status"]) - 1)
51+
content_data["tests_and_status"][idx][image] = results_values[results[image]]
5352

54-
if link:
55-
data["sw_categories"][sw_category][content_title]["test_link"] = link
53+
if link:
54+
data["sw_categories"][sw_category][content_title]["test_link"] = link
5655

5756

58-
with open(stats_file, mode='w') as f:
59-
yaml.dump(data, f)
60-
f.close()
61-
else:
62-
pass
57+
with open(stats_file, mode='w') as f:
58+
yaml.dump(data, f)
59+
f.close()

0 commit comments

Comments
 (0)