1
0
Fork 0

Use sys.stdin instead of the literal '/dev/stdin' for cross platform compatibility. Changed the shebang line so that gpx2svg will also work on Mac.

This commit is contained in:
Tobias Leupold 2014-09-03 17:33:34 +02:00
parent 1f29891b5d
commit d8c6c0f470
1 changed files with 13 additions and 1 deletions

14
gpx2svg
View File

@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
# Copyright (c) 2012-2014 Tobias Leupold <tobias.leupold@web.de>
#
@ -23,10 +23,14 @@ import argparse
import sys
import math
from xml.dom.minidom import parse as parseXml
from os.path import abspath
def parseGpx(gpxFile):
"""Get the latitude and longitude data of all track segments in a GPX file"""
if gpxFile == '/dev/stdin':
gpxFile = sys.stdin
# Get the XML information
try:
gpx = parseXml(gpxFile)
@ -315,6 +319,14 @@ def main():
if cmdArgs.o == '-':
cmdArgs.o = '/dev/stdout'
# Check if a given input or output file name is a relative representation of STDIN or STDOUT
if cmdArgs.i != '/dev/stdin':
if abspath(cmdArgs.i) == '/dev/stdin':
cmdArgs.i = '/dev/stdin'
if cmdArgs.o != '/dev/stdout':
if abspath(cmdArgs.o) == '/dev/stdout':
cmdArgs.o = '/dev/stdout'
# Get the latitude and longitude data from the given GPX file or STDIN
gpsData = parseGpx(cmdArgs.i)