From 37c85a0f5f425c010e02bcde71adee11cebae061 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Mon, 9 Feb 2015 15:44:50 -0800 Subject: [PATCH] proposed workaround to retain both Name and Notes fields in TCX files http://github.com/cpfair/tapiriik/issues/99 --- tapiriik/services/tcx.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tapiriik/services/tcx.py b/tapiriik/services/tcx.py index 859efc148..7eb73afa2 100644 --- a/tapiriik/services/tcx.py +++ b/tapiriik/services/tcx.py @@ -55,7 +55,10 @@ def Parse(tcxData, act=None): xnotes = xact.find("tcx:Notes", namespaces=ns) if xnotes is not None: - act.Notes = xnotes.text + xnotes_lines = xnotes.splitlines() + act.Name = xnotes_lines[0] + if len(xnotes_lines)>1: + act.Notes = '\n'.join(xnotes.text[1:]) xcreator = xact.find("tcx:Creator", namespaces=ns) if xcreator is not None and xcreator.attrib["{" + TCXIO.Namespaces["xsi"] + "}type"] == "Device_t": @@ -257,8 +260,12 @@ def Dump(activity): dateFormat = "%Y-%m-%dT%H:%M:%S.000Z" - if activity.Name is not None: + if activity.Name is not None and activity.Notes is not None: + etree.SubElement(act, "Notes").text = '\n'.join(activity.Name, activity.Notes) + elif activity.Name is not None: etree.SubElement(act, "Notes").text = activity.Name + elif activity.Notes is not None: + etree.SubElement(act, "Notes").text = '\n' + activity.Notes if activity.Type == ActivityType.Cycling: act.attrib["Sport"] = "Biking"