Move the majority of the csv_header functionality to SpeedtestResults

This commit is contained in:
Matt Martz 2017-11-23 09:46:55 -06:00
parent 4457fe9fb8
commit 5c061da8e0
1 changed files with 12 additions and 6 deletions

View File

@ -929,6 +929,17 @@ class SpeedtestResults(object):
'client': self.client, 'client': self.client,
} }
@staticmethod
def csv_header(delimiter=','):
"""Return CSV Headers"""
row = ['Server ID', 'Sponsor', 'Server Name', 'Timestamp', 'Distance',
'Ping', 'Download', 'Upload', 'Share', 'IP Address']
out = StringIO()
writer = csv.writer(out, delimiter=delimiter, lineterminator='')
writer.writerow([to_utf8(v) for v in row])
return out.getvalue()
def csv(self, delimiter=','): def csv(self, delimiter=','):
"""Return data in CSV format""" """Return data in CSV format"""
@ -1486,12 +1497,7 @@ def version():
def csv_header(delimiter=','): def csv_header(delimiter=','):
"""Print the CSV Headers""" """Print the CSV Headers"""
row = ['Server ID', 'Sponsor', 'Server Name', 'Timestamp', 'Distance', print_(SpeedtestResults.csv_header(delimiter=delimiter))
'Ping', 'Download', 'Upload', 'Share', 'IP Address']
out = StringIO()
writer = csv.writer(out, delimiter=delimiter, lineterminator='')
writer.writerow([to_utf8(v) for v in row])
print_(out.getvalue())
sys.exit(0) sys.exit(0)