|
@@ -7,12 +7,13 @@ inside the Verenigde Nederlanden.
|
|
|
import sys
|
|
|
import math
|
|
|
import re
|
|
|
-from datetime import timedelta
|
|
|
+from datetime import timedelta, datetime
|
|
|
import dateutil.parser
|
|
|
|
|
|
# Config
|
|
|
-PLAYER = True
|
|
|
+PLAYER = False
|
|
|
DATE = True
|
|
|
+TOTAL = False
|
|
|
|
|
|
|
|
|
def calculate_buildings(filename='department.txt'):
|
|
@@ -45,7 +46,7 @@ def calculate_buildings(filename='department.txt'):
|
|
|
else:
|
|
|
players[player] = count
|
|
|
|
|
|
- if DATE:
|
|
|
+ if DATE or TOTAL:
|
|
|
date_format = date.strftime("%Y-%m-%d")
|
|
|
if date_format in days:
|
|
|
days[date_format] += count
|
|
@@ -54,12 +55,23 @@ def calculate_buildings(filename='department.txt'):
|
|
|
except Exception as exception:
|
|
|
print('%s %s' % (line, exception))
|
|
|
|
|
|
+ last_date = datetime.now()
|
|
|
+ for date in sorted(days, reverse=True):
|
|
|
+ date = dateutil.parser.parse(date)
|
|
|
+ difference = last_date - date
|
|
|
+ if difference.days > 1:
|
|
|
+ for i in range(1, difference.days):
|
|
|
+ new_date = date + timedelta(days=i)
|
|
|
+ new_date_formatted = new_date.strftime("%Y-%m-%d")
|
|
|
+ days[new_date_formatted] = 0
|
|
|
+ last_date = date
|
|
|
+
|
|
|
if PLAYER:
|
|
|
print_players(players)
|
|
|
if DATE:
|
|
|
print_days(days)
|
|
|
-
|
|
|
- print(total)
|
|
|
+ if TOTAL:
|
|
|
+ print_total(days)
|
|
|
|
|
|
|
|
|
def print_players(players):
|
|
@@ -83,6 +95,18 @@ def print_days(days):
|
|
|
print('%s,%3s' % (date, days[date]))
|
|
|
|
|
|
|
|
|
+def print_total(days):
|
|
|
+ """Print total points in department"""
|
|
|
+ total = 0
|
|
|
+ for date in sorted(days):
|
|
|
+ total += days[date]
|
|
|
+ last_day = dateutil.parser.parse(date) - timedelta(weeks=2)
|
|
|
+ last_day_format = last_day.strftime("%Y-%m-%d")
|
|
|
+ if last_day_format in days:
|
|
|
+ total -= days[last_day_format]
|
|
|
+ print('%s,%3s' % (date, total))
|
|
|
+
|
|
|
+
|
|
|
def bucks(money):
|
|
|
"""Format money"""
|
|
|
str_format = '{:,}'.format(money)
|