-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.py
More file actions
executable file
·37 lines (30 loc) · 1.3 KB
/
employee.py
File metadata and controls
executable file
·37 lines (30 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import collections
EmployeeTuple = collections.namedtuple('EmployeeTuple', ['name', 'ccnl_contract', 'shifts_per_week', 'unavailable', 'on_vacation', 'id'])
# name: string
# ccnl_contract: bool
# shifts_per_week: dict(): int (week) -> number of shifts to do in that week
# unavailable: dict() shift object -> bool
# on_vacation: list(): [day] += bool
# id: identifier. Equals position in data.employees
class Employee(EmployeeTuple):
def __hash__(self):
return self.id
def __str__(self):
string = self.name
if self.ccnl_contract:
string += " [ccnl]"
# if all([item == self.shifts_per_week[0] for item in self.shifts_per_week.values()]):
# string += " - shifts per week = {0}".format(self.shifts_per_week[0])
# else:
string += " - shifts per week "
for w, s in self.shifts_per_week.items():
string += "{0}: {1}, ".format(w, s)
# -- print unavailibilities
unavailibilities = list()
for k, v in self.unavailable.items():
if v:
unavailibilities.append("{0} - {1}".format(k.name, k.day))
# -- paste strings
if unavailibilities:
string += "\nUnavailable on: " + ", ".join(unavailibilities)
return string