Initial commit
This commit is contained in:
2
Solutions/9_4/structly/tableformat/formats/__init__.py
Normal file
2
Solutions/9_4/structly/tableformat/formats/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# formats/__init__.py
|
||||
|
||||
10
Solutions/9_4/structly/tableformat/formats/csv.py
Normal file
10
Solutions/9_4/structly/tableformat/formats/csv.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# csv.py
|
||||
|
||||
from ..formatter import TableFormatter
|
||||
|
||||
class CSVTableFormatter(TableFormatter):
|
||||
def headings(self, headers):
|
||||
print(','.join(headers))
|
||||
|
||||
def row(self, rowdata):
|
||||
print(','.join(str(d) for d in rowdata))
|
||||
16
Solutions/9_4/structly/tableformat/formats/html.py
Normal file
16
Solutions/9_4/structly/tableformat/formats/html.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# html.py
|
||||
|
||||
from ..formatter import TableFormatter
|
||||
|
||||
class HTMLTableFormatter(TableFormatter):
|
||||
def headings(self, headers):
|
||||
print('<tr>', end=' ')
|
||||
for h in headers:
|
||||
print('<th>%s</th>' % h, end=' ')
|
||||
print('</tr>')
|
||||
|
||||
def row(self, rowdata):
|
||||
print('<tr>', end=' ')
|
||||
for d in rowdata:
|
||||
print('<td>%s</td>' % d, end=' ')
|
||||
print('</tr>')
|
||||
11
Solutions/9_4/structly/tableformat/formats/text.py
Normal file
11
Solutions/9_4/structly/tableformat/formats/text.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# text.py
|
||||
|
||||
from ..formatter import TableFormatter
|
||||
|
||||
class TextTableFormatter(TableFormatter):
|
||||
def headings(self, headers):
|
||||
print(' '.join('%10s' % h for h in headers))
|
||||
print(('-'*10 + ' ')*len(headers))
|
||||
|
||||
def row(self, rowdata):
|
||||
print(' '.join('%10s' % d for d in rowdata))
|
||||
9
Solutions/9_4/structly/tableformat/formats/tsv.py
Normal file
9
Solutions/9_4/structly/tableformat/formats/tsv.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# tsv.py
|
||||
|
||||
from ..formatter import TableFormatter
|
||||
|
||||
class TSVTableFormatter(TableFormatter):
|
||||
def headings(self, headers):
|
||||
print('\t'.join(headers))
|
||||
def row(self, rowdata):
|
||||
print('\t'.join(str(d) for d in rowdata))
|
||||
Reference in New Issue
Block a user