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,
}
@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=','):
"""Return data in CSV format"""
@ -1486,12 +1497,7 @@ def version():
def csv_header(delimiter=','):
"""Print the 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])
print_(out.getvalue())
print_(SpeedtestResults.csv_header(delimiter=delimiter))
sys.exit(0)