This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-10-13 12:53:46 +00:00
|
|
|
from ereuse_devicehub.resources.device.models import Device
|
2019-04-11 16:29:51 +00:00
|
|
|
from ereuse_devicehub.resources.event.models import RateComputer
|
2018-10-13 12:53:46 +00:00
|
|
|
from ereuse_devicehub.resources.event.rate.workbench import v1_0
|
|
|
|
|
|
|
|
RATE_TYPES = {
|
2019-04-11 16:29:51 +00:00
|
|
|
RateComputer: {
|
|
|
|
'1.0': v1_0.Rate()
|
2018-10-13 12:53:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-11 16:29:51 +00:00
|
|
|
def rate(device: Device, version):
|
2018-10-13 12:53:46 +00:00
|
|
|
"""
|
|
|
|
Rates the passed-in ``rate`` using values from the rate itself
|
|
|
|
and the ``device``.
|
|
|
|
|
|
|
|
This method mutates ``rate``.
|
|
|
|
|
|
|
|
:param device: The device to use as a model.
|
|
|
|
:param rate: A half-filled rate.
|
|
|
|
"""
|
|
|
|
assert cls in RATE_TYPES, 'Rate type {} not supported.'.format(cls)
|
2019-04-11 16:29:51 +00:00
|
|
|
assert str(rate.version) in RATE_TYPES[cls], \
|
2018-10-13 12:53:46 +00:00
|
|
|
'Rate version {} not supported.'.format(rate.version)
|
2019-04-11 16:29:51 +00:00
|
|
|
RATE_TYPES[cls][str(rate.version)].compute(device)
|