Coverage for scripts/write_tags.py: 0%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-07-22 06:43 -0400

1import json 

2import re 

3 

4with open("scripts/tags.json", "r+", encoding="utf-8") as f: 

5 tags = json.load(f) 

6 

7tags_filled = {k: v for k, v in tags.items() if v} 

8 

9new_dict_str = json.dumps(tags_filled, indent=4).replace(":", ": ") 

10pattern = r"places_tags: dict\[str, dict\[str, str\]\]\s*=\s*\{.*\}" 

11replacement = f"places_tags: dict[str, dict[str, str]] = {new_dict_str}" 

12 

13with open("src/overturetoosm/resources.py", "r", encoding="utf-8") as f: 

14 contents = f.read() 

15 

16replace = re.sub(pattern, replacement, contents, flags=re.DOTALL) 

17 

18with open("src/overturetoosm/resources.py", "w+", encoding="utf-8") as f: 

19 f.write(replace) 

20 

21print("Done!")