aboutsummaryrefslogtreecommitdiff
path: root/prototyping/mapsparsing.py
blob: 6caa37a4f10ca07f3fbe71363d9d95c092ac2e2a (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
import xml.etree.ElementTree as xmlp
import re
import errmsg as reeee
import os
def mapparsing(maptype,basicfilename):
    try:
        tree=xmlp.parse(basicfilename)
        root=tree.getroot()
        if maptype==1:
            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:
            filename= root[0][10][1][0].text+".kml"  
        os.rename(basicfilename,filename)
    except OSError, e:
        print reeee.os
    except xmlp.ParseError, er:
        print reeee.formaterr
        print format(er)
        os.remove(basicfilename)
        pass