From 15dbbef449f42081f00b3e3c8466a045168e55ce Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 25 Mar 2018 17:52:02 +0200 Subject: [PATCH] added boattype and workouttype to YAML workout commands --- rowers/uploads.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/rowers/uploads.py b/rowers/uploads.py index 02ac1837..2a760442 100644 --- a/rowers/uploads.py +++ b/rowers/uploads.py @@ -181,6 +181,33 @@ def getplotoptions(uploadoptions,value): return uploadoptions +from types import workouttypes,boattypes + +def gettype(uploadoptions,value,key): + workouttype = 'rower' + for type,verb in workouttypes: + if value == type: + workouttype = type + if value == verb: + workouttype = type + + uploadoptions[key] = workouttype + + return uploadoptions + +def getboattype(uploadoptions,value,key): + boattype = '1x' + for type,verb in boattypes: + if value == type: + boattype = type + if value == verb: + boattype = type + + uploadoptions[key] = boattype + + return uploadoptions + + def getboolean(uploadoptions,value,key): b = True if not value: @@ -208,6 +235,10 @@ def upload_options(body): uploadoptions = getplotoptions(uploadoptions,value) if 'priva' in lowkey: uploadoptions = getboolean(uploadoptions,value,'makeprivate') + if 'type' in lowkey: + uploadoptions = gettype(uploadoptions,value,'workouttype') + if 'boat' in lowkey: + uploadoptions = getboattype(uploadoptions,value,'workouttype') except AttributeError: #pass raise yaml.YAMLError