diff options
author | Ben Sima <ben@bsima.me> | 2019-11-03 10:33:14 -0800 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-11-03 10:33:14 -0800 |
commit | 04a7ffb8b18511001d42a45849485ffff733bef8 (patch) | |
tree | b43954f852c96bd4eb6a743301d5d6d10f755a21 | |
parent | 999d3b3b8a6654476fb90daf5d1331349681b650 (diff) |
formatting
-rwxr-xr-x | progress.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/progress.py b/progress.py index 47ee5d9..6eb48c8 100755 --- a/progress.py +++ b/progress.py @@ -3,9 +3,10 @@ from datetime import datetime, timedelta from calendar import * + class Progress(object): - """Displays the time left in the day/week/month/year as a percentage. Inspired - by https://twitter.com/year_progress + """Displays the time left in the day/workweek/month/year as a + percentage. Inspired by https://twitter.com/year_progress """ @@ -16,16 +17,17 @@ class Progress(object): month_max = max(list(cal.itermonthdays(self.now.year, self.now.month))) year_max = 366 if isleap(self.now.year) else 365 self.dura = { - 'day': timedelta(hours=8), - 'week': timedelta(days=7), - 'month': timedelta(days=month_max), - 'year': timedelta(days=year_max), + "day": timedelta(hours=8), + "week": timedelta(days=7), + "month": timedelta(days=month_max), + "year": timedelta(days=year_max), } self.end = { - 'year': datetime(self.now.year+1, 1, 1), - 'day': datetime(self.now.year, self.now.month, self.now.day, hour=16), - 'week': datetime(self.now.year, self.now.month, self.now.day) + weekdays_left, - 'month': datetime(self.now.year, self.now.month, month_max), + "year": datetime(self.now.year + 1, 1, 1), + "day": datetime(self.now.year, self.now.month, self.now.day, hour=16), + "week": datetime(self.now.year, self.now.month, self.now.day) + + weekdays_left, + "month": datetime(self.now.year, self.now.month, month_max), } def calc(self, key): @@ -33,11 +35,12 @@ class Progress(object): def __str__(self): return "d: {d:.1%} | w: {w:.1%} | m: {m:.1%} | y: {y:.1%}".format( - d=self.calc('day'), - w=self.calc('week'), - m=self.calc('month'), - y=self.calc('year'), + d=self.calc("day"), + w=self.calc("week"), + m=self.calc("month"), + y=self.calc("year"), ) -if __name__ == '__main__': + +if __name__ == "__main__": print(str(Progress())) |