From 628b7b79604aab5e9a18921c48c4275321c4be3c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 4 Sep 2022 12:16:37 +0300 Subject: [PATCH 1/3] Add emoji to test Unicode --- tests/gpx/activity_7448910422.gpx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gpx/activity_7448910422.gpx b/tests/gpx/activity_7448910422.gpx index 0e7a36d..794c15c 100644 --- a/tests/gpx/activity_7448910422.gpx +++ b/tests/gpx/activity_7448910422.gpx @@ -11,7 +11,7 @@ - West Berkshire Cycling + West Berkshire Cycling 🍻 cycling From c152b3454b64d533faefff3a26b7a2eadd704573 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 4 Sep 2022 13:22:31 +0300 Subject: [PATCH 2/3] Fix encoding on Windows --- src/stravavis/process_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stravavis/process_data.py b/src/stravavis/process_data.py index c05297e..ea053d5 100644 --- a/src/stravavis/process_data.py +++ b/src/stravavis/process_data.py @@ -18,7 +18,7 @@ def process_file(fpath): # Function for processing an individual GPX file # Ref: https://pypi.org/project/gpxpy/ def process_gpx(gpxfile): - activity = gpxpy.parse(open(gpxfile)) + activity = gpxpy.parse(open(gpxfile, encoding="utf-8")) lon = [] lat = [] From b482ba6604f9e598222f0484118695e3a1d1ea4c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 4 Sep 2022 13:26:35 +0300 Subject: [PATCH 3/3] Open file with context manager --- src/stravavis/process_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stravavis/process_data.py b/src/stravavis/process_data.py index ea053d5..700488a 100644 --- a/src/stravavis/process_data.py +++ b/src/stravavis/process_data.py @@ -18,7 +18,8 @@ def process_file(fpath): # Function for processing an individual GPX file # Ref: https://pypi.org/project/gpxpy/ def process_gpx(gpxfile): - activity = gpxpy.parse(open(gpxfile, encoding="utf-8")) + with open(gpxfile, encoding="utf-8") as f: + activity = gpxpy.parse(f) lon = [] lat = []