Skip to content

Commit 1dd35f5

Browse files
committed
uses duplicates.items() instead of duplicates
1 parent a7610ca commit 1dd35f5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/metadata/check_uuids.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@
99
import os
1010
import io
1111

12+
1213
def get_header(exfile: Path) -> str:
1314
text = exfile.read_text(encoding="utf-8")
1415
header = re.search(r"^---$(.+?)^---$", text, flags=re.M | re.S)
1516
if header is None:
1617
raise Exception(f"{exfile} does not contain a YAML header")
1718
if header.start() != 0:
18-
raise Exception(f"{exfile} has a YAML block, which is not at the beginning of the file but at postion {header.start()}")
19+
raise Exception(
20+
f"{exfile} has a YAML block, which is not at the beginning of the file but at postion {header.start()}"
21+
)
1922
return header.group(1)
2023

24+
2125
def find_duplicates(lst: List[Tuple[Path, str]]) -> List[Tuple[str, List[Path]]]:
2226
count = {}
2327
for path, id in lst:
2428
count.setdefault(id, [])
2529
count[id].append(path)
26-
duplicates = { i: l for i, l in count.items() if len(l) > 1}
27-
return list(duplicates)
30+
duplicates = {i: l for i, l in count.items() if len(l) > 1}
31+
return list(duplicates.items())
32+
2833

2934
if __name__ == "__main__":
3035
os.chdir(Path(__file__).parent)
31-
exercises = Path("../../exercises").glob("*/*/*/*.md")
36+
exercises = Path("../../exercises").glob("*/*/*/*.md")
3237
headers = [(p, yaml.safe_load(io.StringIO(get_header(p)))) for p in exercises]
3338
noid = [(p, h) for p, h in headers if "id" not in h]
3439
ids = [(p, h["id"]) for p, h in headers if "id" in h]

0 commit comments

Comments
 (0)