Skip to content

fixes around csv and ID input #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fstimer/gui/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''
Expand Down Expand Up @@ -632,7 +634,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)
Expand Down
7 changes: 7 additions & 0 deletions fstimer/printer/printcsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 6 additions & 2 deletions fstimer/printer/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down