From 03acf6e2e5d066cd817055df7cc85396a7dff468 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Wed, 11 May 2016 20:09:41 +0200 Subject: [PATCH 1/3] Make sure entered ID numbers have no leading 0s As Ids are used as string further, 01 and 1 would not match. This is problematic for example when scanning bar codes and the scan gives 01 --- fstimer/gui/timing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fstimer/gui/timing.py b/fstimer/gui/timing.py index 07bc755..bdb3c74 100644 --- a/fstimer/gui/timing.py +++ b/fstimer/gui/timing.py @@ -632,7 +632,7 @@ def record_time(self, jnk_unused): and then mark the time.''' txt = self.entrybox.get_text() timemarks = txt.count(self.timebtn) - txt = txt.replace(self.timebtn, '') + txt = txt.replace(self.timebtn, '').lstrip('0') # it is actually a result. (or a pass, which we treat as a result) # prepend to raw self.rawtimes['ids'].insert(0, txt) From 1b19a34bc8a14c1b6f91511f6816e06108d96a76 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Tue, 30 May 2017 15:00:39 +0200 Subject: [PATCH 2/3] Added nb of registered times on the status line Very useful when you have duplicate setup to double check that you took the smae number of times The number of runners per lap was there, but in case you are taking only timings on that instance, it does not help --- fstimer/gui/timing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fstimer/gui/timing.py b/fstimer/gui/timing.py index bdb3c74..897930a 100644 --- a/fstimer/gui/timing.py +++ b/fstimer/gui/timing.py @@ -235,12 +235,14 @@ def update_racers_label(self): if self.numlaps > 1: s += ' (per lap)' s += ': ' + ' | '.join(str(n) for n in self.racers_in) + s += ', Times taken : %d ' % len(self.rawtimes['times']) self.racerslabel.set_markup(s) def check_for_newtime(self, jnk_unused): '''Handles entering of a new time''' if self.entrybox.get_text() == self.timebtn: self.new_blank_time() + self.update_racers_label() def scroll_times(self, jnk1_unused, jnk2_unused): '''handles scrolling of the time window''' From 0c658a806dff0e661ec6bf533dbde584fa7863e9 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Mon, 5 Jun 2017 23:47:34 +0200 Subject: [PATCH 3/3] Make sure to escape properly items in csv files --- fstimer/printer/printcsv.py | 7 +++++++ fstimer/printer/printer.py | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fstimer/printer/printcsv.py b/fstimer/printer/printcsv.py index f5b14df..60991f1 100644 --- a/fstimer/printer/printcsv.py +++ b/fstimer/printer/printcsv.py @@ -42,6 +42,13 @@ def file_extension(self): containing data from this printer''' return 'csv' + def escape(self, word): + '''returns an escaped version of the value''' + if type(word) == str and word.find(',') >= 0: + return '"' + word.replace('"', '\\"') + '"' + else: + return word + def scratch_table_header(self): '''Returns the header of the printout for scratch results''' return 'Place,' + ','.join(self.fields) + '\n' diff --git a/fstimer/printer/printer.py b/fstimer/printer/printer.py index 27337a8..ae0ce25 100644 --- a/fstimer/printer/printer.py +++ b/fstimer/printer/printer.py @@ -73,9 +73,13 @@ def cat_table_footer(self, category): @type category: string @param category: name of the category handled by the table''' return '' - + + def escape(self, word): + '''returns an escaped version of the value, if needed''' + return word + def common_entry(self, row): - return self.row_delim.join(row) + return self.row_delim.join(map(self.escape, row)) def scratch_entry(self, row, category=None): '''Returns the printout of the entry of a given runner