Change the filespec for ignored changes and the mode of retire.py
[retire.git] / utils.py
1
2 # Global helper functions
3 def truncate(n, decimals=2):
4     multiplier = 10 ** decimals
5     return int(n * multiplier) / multiplier
6
7 def format_money(number):
8     return ("${:,}".format(truncate(number)))
9
10 def format_rate(rate):
11     if rate >= 1.0:
12         return format_rate(rate - 1.0)
13     else:
14         return "{:<}%".format(round(rate * 100, 3))