Skip to content

Commit

Permalink
Merge pull request #100 from dlenski/master
Browse files Browse the repository at this point in the history
workaround for bidirectional TCX import/export of Name and Notes fields
  • Loading branch information
cpfair committed Feb 13, 2015
2 parents b055a42 + 37c85a0 commit 8890bcd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tapiriik/services/tcx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8890bcd

Please sign in to comment.