| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | 
"""Calculate percentage level of index for regionsinside the Verenigde Nederlanden."""import mathimport refrom datetime import timedeltaimport dateutil.parser# ConfigPLAYER = TrueDATE = TruePLAYERS = {}DAYS = {}def calculate_buildings():    """Count working in departments"""    total = 0    total_reward = 0    with open('department.txt', 'r') as file:        for line in file:            try:                date_str = re.search(r'\s\d\d.*', line).group(0)                date_str = re.sub(r'\s\d\d\s', '', date_str)                date = dateutil.parser.parse(date_str)                if date.hour >= 20:                    date += timedelta(days=1)                line = re.sub(r'\s\d\d.*', '', line)                line = re.sub(r'\[.*\]', '', line)                line = line.strip()                count = re.search(r'\+\d+', line).group(0)                count = count.replace('+', '')                count = int(count)                total += count                if PLAYER:                    player = re.sub(r'\s\(.*', '', line)                    if player in PLAYERS:                        PLAYERS[player] += count                    else:                        PLAYERS[player] = count                if DATE:                    date_format = date.strftime("%Y-%m-%d")                    if date_format in DAYS:                        DAYS[date_format] += count                    else:                        DAYS[date_format] = count            except Exception as exception:                print('%s %s' % (line, exception))    if PLAYER:        print('punten,beloning,naam')        for player in sorted(PLAYERS, key=PLAYERS.get, reverse=True):            worked_times = math.floor(PLAYERS[player] / 10)            reward = worked_times * 2000000000            if worked_times >= 6:                reward += 10000000000            total_reward += reward            print('%3s,$ %5s,%s' % (PLAYERS[player], bucks(reward), player))    if DATE:        for date in sorted(DAYS, reverse=True):            print('%s,%3s' % (date, DAYS[date]))    print(total)    print(total_reward)def bucks(money):    """Format money"""    str_format = '{:,}'.format(money)    new_str = ''    for i in range(len(str_format), 0, -4):        if str_format[i-4:i] == ',000':            new_str = 'k' + new_str        else:            new_str = str_format[:i] + new_str            break    new_str = new_str.replace('kkkk', 't')    new_str = new_str.replace(',', '.')    return new_strif __name__ == '__main__':    calculate_buildings()
 |