Skip to content

Commit e88a2da

Browse files
committed
Works for all OS
1 parent 7b40efe commit e88a2da

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

bin/annotation_workflow.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
2-
from pathlib import Path
2+
import os
33
import re
4+
from pathlib import Path
45

56
# Function to print GitHub action notice
67
def print_github_action_notice(file, url):
@@ -10,13 +11,13 @@ def print_github_action_notice(file, url):
1011
with open("bin/specification_urls.json", "r") as f:
1112
urls = json.load(f)
1213

13-
# Iterate through files in tests folder
14-
for root, dirs, files in Path("tests").walk():
15-
for file in files:
16-
if file.endswith('.json'): # Check if file is JSON
17-
file_path = root / file
14+
# Iterate through JSON files in tests folder and subdirectories
15+
for root, dirs, files in os.walk("tests"):
16+
for file_name in files:
17+
if file_name.endswith(".json"):
18+
file_path = os.path.join(root, file_name)
1819
# Read the file content
19-
with open(file_path, "r") as f:
20+
with open(file_path, 'r', encoding='utf-8') as f:
2021
changed_file_content = f.read()
2122

2223
# Parse JSON content
@@ -26,7 +27,7 @@ def print_github_action_notice(file, url):
2627
if "specification" in test:
2728
for specification_object in test["specification"]:
2829
for spec, section in specification_object.items():
29-
draft = root.split('/')[-1]
30+
draft = Path(file_path).parent.name
3031
if spec in ["core", "validation", "hyper-schema"]:
3132
print_github_action_notice(file_path, urls[draft][spec] + section)
3233
elif spec in ["quote"]:

0 commit comments

Comments
 (0)