Files
PythonRMV/src/pyrmv/utility/weekdays_bitmask.py
profitroll f31fa65d78
Some checks reported warnings
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.8) (push) Has been cancelled
Tests / test (3.9) (push) Has been cancelled
Tests / test (3.10) (push) Has been cancelled
Small refactor and isort+black formatting
2023-11-24 11:21:02 +01:00

19 lines
693 B
Python

from typing import OrderedDict
def weekdays_bitmask(data: OrderedDict[str, bool]) -> str:
"""Convert ordered dict with weekdays to a bitmask.
### Args:
* data (OrderedDict[str, bool]): OrderedDict formatted as follows: OrderedDict(Monday=bool, Tuesday=bool, Wednesday=bool, Thursday=bool, Friday=bool, Saturday=bool, Sunday=bool)
### Returns:
* str: _description_
"""
if len(data) != 7:
raise ValueError(
"OrderedDict must be formatted as follows: OrderedDict(Monday=bool, Tuesday=bool, Wednesday=bool, Thursday=bool, Friday=bool, Saturday=bool, Sunday=bool)"
)
return "".join("1" if data[day] else "0" for day in data)