Skip to content

Commit

Permalink
Issue #45: check for new sport and subsport not None for all cases
Browse files Browse the repository at this point in the history
(cherry picked from commit 2fcb36f)
  • Loading branch information
tcgoetz committed Jan 14, 2020
1 parent 1b33891 commit e5cf943
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fit_file_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ def _write_generic_entry(self, fit_file, activity_id, sub_sport, message_dict):
def __choose_sport(self, current_sport, current_sub_sport, new_sport, new_sub_sport):
sport = Fit.field_enums.Sport.strict_from_string(current_sport)
sub_sport = Fit.field_enums.SubSport.strict_from_string(current_sub_sport)
if (sport is None and new_sport is not None) or (not sport.preferred() and new_sport.preferred()):
if new_sport is not None and (sport is None or (not sport.preferred() and new_sport.preferred())):
sport = new_sport
if (sub_sport is None and new_sub_sport is not None) or (not sub_sport.preferred() and new_sub_sport.preferred()):
if new_sub_sport is not None and (sub_sport is None or (not sub_sport.preferred() and new_sub_sport.preferred())):
sub_sport = new_sub_sport
return {'sport' : sport.name, 'sub_sport' : sub_sport.name}

Expand Down

0 comments on commit e5cf943

Please sign in to comment.