@@ -89,9 +89,6 @@ def print_report(report, total_cost, total_gain_lost, formatter):
8989 'Price' ,
9090 'Change' ,
9191 'Gain/Lost' ]
92- # headers_len = len(headers)
93- # print('%10s '*headers_len % headers)
94- # print(('-'*10 + ' ')*headers_len)
9592
9693 formatter .headings (headers )
9794
@@ -118,8 +115,6 @@ def print_report(report, total_cost, total_gain_lost, formatter):
118115 ' ' * 10 ,
119116 'Gain/lost' ,
120117 f'{ total_gain_lost :>10.2f} ' ]
121- # print(('-'*10 + ' ')*len(footer))
122- # print('%10s '*len(footer) % footer)
123118 formatter .footings (footers )
124119
125120def portfolio_report (portfoliofile , pricefile , fmt = 'txt' ):
@@ -134,14 +129,7 @@ def portfolio_report(portfoliofile, pricefile, fmt='txt'):
134129 report , total_cost , total_gain_lost = make_report_data (portfolio , prices )
135130
136131 # Print it out
137- if fmt == 'txt' :
138- formatter = tableformat .TextTableFormatter ()
139- elif fmt == 'csv' :
140- formatter = tableformat .CSVTableFormatter ()
141- elif fmt == 'html' :
142- formatter = tableformat .HTMLTableFormatter ()
143- else :
144- raise RuntimeError (f'Unknow format { fmt } ' )
132+ formatter = tableformat .createformatter (fmt )
145133
146134 print_report (report , total_cost , total_gain_lost , formatter )
147135
0 commit comments