Beispiel #1
0
def prettify_data(mf_dict, stats):
    for mf in mf_dict:
        for val in ['total_units', 'total_amount_invested',
                    'total_amount_now', 'percentage_gains',
                    'annualized_gains']:
            mf_dict[mf][val] = utils.prettify_number(mf_dict[mf][val])

    for val in ['total_amount_invested', 'percentage_gains',
                'total_amount_now', 'total_gains']:
        stats[val] = utils.prettify_number(stats[val])

    return mf_dict, stats
Beispiel #2
0
 def test_prettify_number(self):
     inp_outp_dict = {
         1:              '1.00',
         1.00:           '1.00',
         123.4567:       '123.46',
         123.45:         '123.45',
         1234.56:        '1,234.56',
         12345.67:       '12,345.67',
         123456.7:       '1,23,456.70',
         1234567.89:     '12,34,567.89',
         12345678.9:     '1,23,45,678.90',
         9123456789.87:  '912,34,56,789.87',
         -1.0:           '-1.00',
         -123.45:        '-123.45',
         -1234.56:       '-1,234.56',
         -12345.67:      '-12,345.67',
         -123456.7:      '-1,23,456.70',
         -1234567.89:    '-12,34,567.89',
         -12345678.9:    '-1,23,45,678.90',
         -9123456789.87: '-912,34,56,789.87',
      }
     for inp, outp in inp_outp_dict.iteritems():
         self.assertEqual(outp, utils.prettify_number(inp))