Skip to content

Commit 470170d

Browse files
committed
Use pathlib
1 parent 9ef369a commit 470170d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.github/workflows/labels.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import json
2-
import os
3-
import shutil
1+
from pathlib import Path
42

53
import requests
64

7-
# Delete and recreate the labels/ directory
8-
shutil.rmtree('labels')
9-
os.mkdir('labels')
5+
dir = Path('labels')
6+
7+
# Remove labels/*.txt.
8+
for child in dir.iterdir():
9+
if child.suffix == '.txt':
10+
child.unlink()
1011

1112
# Fetch the list of all labels from wpt.fyi.
1213
data = requests.get('https://wpt.fyi/api/metadata?includeTestLevel=true&product=chrome').json()
1314

14-
1515
# Invert the data structure to a mapping from label to tests.
1616
labels = {}
1717
for test, links in data.items():
@@ -25,8 +25,7 @@
2525
# Write one file for every label.
2626
for label, tests in labels.items():
2727
tests.sort()
28-
filename = os.path.join('labels', f'{label}.txt')
29-
with open(filename, 'w') as f:
28+
with dir.joinpath(f'{label}.txt').open(mode='w') as f:
3029
for test in tests:
3130
f.write(test)
3231
f.write('\n')

labels/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory tracks all tests that have a label starting with "interop-". It's updated automatically and is used to ensure that labels aren't added or removed without the interop team being aware of the change.

0 commit comments

Comments
 (0)