blob: 7128f62530ae47e6a55080d78f6d4563456ac65b (
plain) (
blame)
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
26
27
28
|
import xml.etree.ElementTree as xmlp
import re
import errmsg as e
def mapparsing(maptype,basicfilename):
try:
root=tree.getroot()
if maptype==1:
tree=xmlp.parse(basicfilename)
filename=root[1][0].text+".gpx"
elif maptype==2:
thefile=open(basicfilename)
for i in range(3):
thefile.readline()
filename=re.findall(r'\|(.*?)\|', thefile.readline())[0]+".trk"
elif maptype==3:
tree=xmlp.parse(basicfilename)
filename= root[0][10][1][0].text+".kml"
os.rename(basicfilename,filename)
except OSError, e:
print e.os
except xmlp.ParseError, e:
print e.formaterr
print format(e)
os.remove(basicfilename)
pass
return filename
|