comparison donations/management/commands/donations_report.py @ 684:161b56849114

For Django 1.5: management commands should use self.stdout, etc. for output. Note that I did not update the legacy commands since it is likely I will never run or test these commands again.
author Brian Neal <bgneal@gmail.com>
date Fri, 23 Aug 2013 19:17:40 -0500
parents 08d83015e15d
children
comparison
equal deleted inserted replaced
683:c83d330cb65f 684:161b56849114
30 if year < 2011 or year > today.year: 30 if year < 2011 or year > today.year:
31 raise CommandError("invalid year") 31 raise CommandError("invalid year")
32 32
33 max_month = 12 if year != today.year else today.month 33 max_month = 12 if year != today.year else today.month
34 34
35 print ROW_FMT % ('Month', 'Gross', 'Net') 35 self.stdout.write(ROW_FMT % ('Month', 'Gross', 'Net'))
36 sep = ROW_FMT % ('-' * 10, '-' * 7, '-' * 7) 36 sep = ROW_FMT % ('-' * 10, '-' * 7, '-' * 7)
37 print sep 37 self.stdout.write(sep)
38 38
39 total_gross = decimal.Decimal() 39 total_gross = decimal.Decimal()
40 total_net = decimal.Decimal() 40 total_net = decimal.Decimal()
41 41
42 for month in range(1, max_month + 1): 42 for month in range(1, max_month + 1):
52 52
53 net = gross - fee 53 net = gross - fee
54 54
55 d = datetime.date(year=year, month=month, day=1) 55 d = datetime.date(year=year, month=month, day=1)
56 56
57 print ROW_FMT % (d.strftime('%b %Y'), gross, net) 57 self.stdout.write(ROW_FMT % (d.strftime('%b %Y'), gross, net))
58 58
59 total_gross += gross 59 total_gross += gross
60 total_net += net 60 total_net += net
61 61
62 print sep 62 self.stdout.write(sep)
63 print ROW_FMT % ('Total:', total_gross, total_net) 63 self.stdout.write(ROW_FMT % ('Total:', total_gross, total_net))