parent
4c160d1723
commit
5a9725ee17
|
@ -649,8 +649,7 @@ class Battery:
|
|||
elif isinstance(self.level, int):
|
||||
status = self.status.name.lower().replace("_", " ") if self.status is not None else "Unknown"
|
||||
return _("Battery: %(percent)d%% (%(status)s)") % {"percent": self.level, "status": _(status)}
|
||||
else:
|
||||
return ""
|
||||
return ""
|
||||
|
||||
|
||||
class Alert(IntEnum):
|
||||
|
|
|
@ -20,6 +20,7 @@ import struct
|
|||
import time
|
||||
|
||||
from enum import IntEnum
|
||||
from typing import Any
|
||||
|
||||
from solaar.i18n import _
|
||||
|
||||
|
@ -276,7 +277,7 @@ class Settings(Setting):
|
|||
self._value[int(key)] = value
|
||||
self._pre_write(save)
|
||||
|
||||
def write_key_value(self, key, value, save=True):
|
||||
def write_key_value(self, key, value, save=True) -> Any | None:
|
||||
assert hasattr(self, "_value")
|
||||
assert hasattr(self, "_device")
|
||||
assert key is not None
|
||||
|
|
|
@ -33,7 +33,6 @@ from . import common
|
|||
from . import descriptors
|
||||
from . import desktop_notifications
|
||||
from . import diversion
|
||||
from . import hidpp10_constants
|
||||
from . import hidpp20
|
||||
from . import hidpp20_constants
|
||||
from . import settings
|
||||
|
@ -46,7 +45,6 @@ from .hidpp20_constants import ParamId
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
_hidpp20 = hidpp20.Hidpp20()
|
||||
_DK = hidpp10_constants.DEVICE_KIND
|
||||
_F = hidpp20_constants.SupportedFeature
|
||||
|
||||
|
||||
|
@ -1612,8 +1610,6 @@ class LEDZoneSetting(settings.Setting):
|
|||
period_field = {"name": _LEDP.period, "kind": settings.Kind.RANGE, "label": _("Period"), "min": 100, "max": 5000}
|
||||
intensity_field = {"name": _LEDP.intensity, "kind": settings.Kind.RANGE, "label": _("Intensity"), "min": 0, "max": 100}
|
||||
ramp_field = {"name": _LEDP.ramp, "kind": settings.Kind.CHOICE, "label": _("Ramp"), "choices": hidpp20.LEDRampChoices}
|
||||
# form_field = {"name": _LEDP.form, "kind": settings.Kind.CHOICE, "label": _("Form"), "choices":
|
||||
# _hidpp20.LEDFormChoices}
|
||||
possible_fields = [color_field, speed_field, period_field, intensity_field, ramp_field]
|
||||
|
||||
@classmethod
|
||||
|
@ -1948,7 +1944,7 @@ def check_feature_settings(device, already_known) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def check_feature_setting(device, setting_name) -> settings.Setting | None:
|
||||
def check_feature_setting(device, setting_name: str) -> settings.Setting | None:
|
||||
for sclass in SETTINGS:
|
||||
if sclass.feature and sclass.name == setting_name and device.features:
|
||||
setting = check_feature(device, sclass)
|
||||
|
|
|
@ -43,11 +43,11 @@ class Kind(IntEnum):
|
|||
|
||||
class Validator:
|
||||
@classmethod
|
||||
def build(cls, setting_class, device, **kwargs):
|
||||
def build(cls, setting_class, device, **kwargs) -> Validator:
|
||||
return cls(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def to_string(cls, value):
|
||||
def to_string(cls, value) -> str:
|
||||
return str(value)
|
||||
|
||||
def compare(self, args, current):
|
||||
|
@ -200,7 +200,7 @@ class BitFieldValidator(Validator):
|
|||
assert isinstance(byte_count, int) and byte_count >= self.byte_count
|
||||
self.byte_count = byte_count
|
||||
|
||||
def to_string(self, value):
|
||||
def to_string(self, value) -> str:
|
||||
def element_to_string(key, val):
|
||||
k = next((k for k in self.options if int(key) == k), None)
|
||||
return str(k) + ":" + str(val) if k is not None else "?"
|
||||
|
@ -381,7 +381,7 @@ class ChoicesValidator(Validator):
|
|||
assert self._byte_count + self._read_skip_byte_count <= 14
|
||||
assert self._byte_count + len(self._write_prefix_bytes) <= 14
|
||||
|
||||
def to_string(self, value):
|
||||
def to_string(self, value) -> str:
|
||||
return str(self.choices[value]) if isinstance(value, int) else str(value)
|
||||
|
||||
def validate_read(self, reply_bytes):
|
||||
|
@ -465,7 +465,7 @@ class ChoicesMapValidator(ChoicesValidator):
|
|||
assert self._byte_count + self._read_skip_byte_count + self._key_byte_count <= 14
|
||||
assert self._byte_count + len(self._write_prefix_bytes) + self._key_byte_count <= 14
|
||||
|
||||
def to_string(self, value):
|
||||
def to_string(self, value) -> str:
|
||||
def element_to_string(key, val):
|
||||
k, c = next(((k, c) for k, c in self.choices.items() if int(key) == k), (None, None))
|
||||
return str(k) + ":" + str(c[val]) if k is not None else "?"
|
||||
|
|
Loading…
Reference in New Issue