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:
parent
1f29891b5d
commit
d8c6c0f470
14
gpx2svg
14
gpx2svg
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue