Coverage for scripts/write_wiki.py: 0%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2024-07-28 10:12 -0400

1"""Write the tags to a wiki formatted table.""" 

2 

3import json 

4 

5 

6def write_wiki(table: str) -> str: 

7 """Write the table to a wiki formatted string.""" 

8 return f"""[[Overture Maps|Overture]] categories are described [https://github.com/OvertureMaps/schema/blob/main/task-force-docs/places/overture_categories.csv here], unfortunately there are no descriptions. We can however infer some details from the hierarchy. The following are "root"/"top level tags" in Overture. 

9* eat_and_drink 

10* accommodation 

11* automotive 

12* arts_and_entertainment 

13* attractions_and_activities 

14* active_life 

15* beauty_and_spa 

16* education 

17* financial_service 

18* private_establishments_and_corporates 

19* retail 

20* health_and_medical 

21* pets 

22* business_to_business 

23* public_service_and_government 

24* religious_organization 

25* real_estate 

26* travel 

27* mass_media 

28* home_service 

29* professional_services 

30* structure_and_geography 

31 

32== Mapping == 

33 

34{ | class="wikitable" id="mapping_table" 

35!Overture!!OSM 

36{table} 

37|} 

38 

39[[Category:Overture Maps]] 

40 """ 

41 

42 

43def main() -> None: 

44 text = [] 

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

46 tags = json.load(f) 

47 

48 for k, v in tags.items(): 

49 sec = " ".join([f"{ { tag|{k1}|{v1}} } " for k1, v1 in v.items()]) 

50 text.append(f"|-\n|{k}||{sec}") 

51 

52 with open("scripts/wiki.txt", "w+", encoding="utf-8") as f: 

53 f.write(write_wiki("\n".join(text))) 

54 

55 

56if __name__ == "__main__": 

57 main()