Skip to content

Commit

Permalink
Merge pull request #5 from hugovk/handle-error
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Feb 5, 2022
2 parents 9eb8450 + ff7d32c commit ade49a6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import gpxpy # pip3 install gpxpy
import gpxpy.gpx
from gpxpy.geo import ONE_DEGREE
from termcolor import colored # pip3 install termcolor
from termcolor import cprint # pip3 install termcolor
from tqdm import tqdm # pip3 install tqdm

# from pprint import pprint
Expand Down Expand Up @@ -85,12 +85,17 @@ def save_gpx(gpx, filename, dry_run):
with open(new_filename, "w") as f:
f.write(gpx.to_xml())

print(colored(new_filename, "green"))
cprint(new_filename, "green")


def split_gpx(filename, max_distance, max2, dry_run):
gpx_file = open(filename)
gpx = gpxpy.parse(gpx_file)
try:
gpx = gpxpy.parse(gpx_file)
except gpxpy.gpx.GPXException as e:
print(gpx_file)
cprint(f"Cannot parse {filename}: {e}", "red")
return

new_gpx = copy.deepcopy(gpx)
new_gpx.tracks = []
Expand Down

0 comments on commit ade49a6

Please sign in to comment.