forked from VATGER-Nav/mapbuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_kml.py
More file actions
25 lines (18 loc) · 650 Bytes
/
fix_kml.py
File metadata and controls
25 lines (18 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
import sys
if len(sys.argv) != 2:
print("Usage: python fix_kml.py CYHZ_ground.kml")
sys.exit(1)
filename = sys.argv[1]
with open(filename, 'r', encoding='utf-8') as f:
content = f.read()
# Replace short tag with full tag
old_open = chr(60) + 'n' + chr(62) # <n>
new_open = chr(60) + 'name' + chr(62) # <name>
old_close = chr(60) + '/' + 'n' + chr(62) # </n>
new_close = chr(60) + '/' + 'name' + chr(62) # </name>
content = content.replace(old_open, new_open)
content = content.replace(old_close, new_close)
with open(filename, 'w', encoding='utf-8') as f:
f.write(content)
print(f"Fixed {filename}")