diff options
author | Lionel <lionel.miquel46@gmail.com> | 2018-10-21 14:53:51 +0200 |
---|---|---|
committer | Lionel <lionel.miquel46@gmail.com> | 2018-10-21 14:53:51 +0200 |
commit | b3ee49d174a35bbf4da6b1c60059795fdb88f710 (patch) | |
tree | 8b6c371d02eb30cd0ec874004dbabb0d8e93d33f /prototyping/mapsparsing.py | |
parent | 7fbd76c1e51bf1cc3094b7d2286668cd839675fe (diff) | |
download | randopitons-b3ee49d174a35bbf4da6b1c60059795fdb88f710.tar.gz randopitons-b3ee49d174a35bbf4da6b1c60059795fdb88f710.zip |
Finally I'll rewrite it in bash i find it more readable than my python scripts. Will plan on a powershell version too
Diffstat (limited to 'prototyping/mapsparsing.py')
-rw-r--r-- | prototyping/mapsparsing.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/prototyping/mapsparsing.py b/prototyping/mapsparsing.py new file mode 100644 index 0000000..6caa37a --- /dev/null +++ b/prototyping/mapsparsing.py @@ -0,0 +1,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 + + |