#!/usr/bin/python ''' authors: Pau1us license: gpl v2 or later This is a Class to create *.gpx Files Usage: open new file: file = WriteGPX(filename) write trackpint: file.write(lat, lon, alt, utctime) close file: file.close() The file musst be closed, otherwise the file will be incomplete ''' from __future__ import with_statement <<<<<<< .mine ======= from __future__ import with_statement >>>>>>> .r158 class WriteGPX: def __init__(self, filename): self.filename = filename self.header = '\n\ \n\ \n\ \n' self.footer = '\n\n\n' with open(self.filename,'a') as file: file.write(self.header) def write(self, lat, lon, ele, time): self.trackpoint = '\n\ %s\n\ \n\ \n' % (lat, lon, ele, time) with open(self.filename,'a') as file: file.write(self.trackpoint) def close(self): with open(self.filename,'a') as file: file.write(self.footer)