-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (18 loc) · 750 Bytes
/
Copy pathmain.py
File metadata and controls
25 lines (18 loc) · 750 Bytes
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
"""Demo: headcount and cost rollups over a nested org chart."""
from __future__ import annotations
from patterns.structural.composite.examples.org_chart.org import Department, Employee
def main() -> None:
platform = Department(
"platform",
[Employee("Ada", 190_000), Employee("Grace", 185_000)],
)
payments = Department(
"payments",
[Employee("Alan", 175_000), platform], # a department inside a department
)
company = Department("engineering", [payments, Employee("Barbara", 210_000)])
for unit in (platform, payments, company):
metrics = unit.total()
print(f"{unit.name}: {metrics.headcount} people, ${metrics.annual_cost:,}/yr")
if __name__ == "__main__":
main()