update format to fstring
This commit is contained in:
parent
6068b60cac
commit
ffcfc9835d
@ -90,7 +90,7 @@ class LED(Extension):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'LED({})'.format(self._to_dict())
|
return f'LED({self._to_dict()})'
|
||||||
|
|
||||||
def _to_dict(self):
|
def _to_dict(self):
|
||||||
return {
|
return {
|
||||||
|
@ -22,7 +22,7 @@ class LockStatus(Extension):
|
|||||||
self.hid = device
|
self.hid = device
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return ('LockStatus(report={})').format(self.report)
|
return f'LockStatus(report={self.report})'
|
||||||
|
|
||||||
def during_bootup(self, sandbox):
|
def during_bootup(self, sandbox):
|
||||||
return
|
return
|
||||||
|
@ -36,7 +36,7 @@ class Rgb_matrix_data:
|
|||||||
):
|
):
|
||||||
keys = [key_color] * number_of_keys
|
keys = [key_color] * number_of_keys
|
||||||
underglow = [underglow_color] * number_of_underglow
|
underglow = [underglow_color] * number_of_underglow
|
||||||
print('Rgb_matrix_data(keys={},\nunderglow={})'.format(keys, underglow))
|
print(f'Rgb_matrix_data(keys={keys},\nunderglow={underglow})')
|
||||||
|
|
||||||
|
|
||||||
class Rgb_matrix(Extension):
|
class Rgb_matrix(Extension):
|
||||||
|
@ -57,7 +57,7 @@ class statusLED(Extension):
|
|||||||
self._layer_last = layer_active
|
self._layer_last = layer_active
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'SLED({})'.format(self._to_dict())
|
return f'SLED({self._to_dict()})'
|
||||||
|
|
||||||
def _to_dict(self):
|
def _to_dict(self):
|
||||||
return {
|
return {
|
||||||
|
@ -70,7 +70,7 @@ class AbstractHID:
|
|||||||
self.post_init()
|
self.post_init()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '{}(REPORT_BYTES={})'.format(self.__class__.__name__, self.REPORT_BYTES)
|
return f'{self.__class__.__name__}(REPORT_BYTES={self.REPORT_BYTES})'
|
||||||
|
|
||||||
def post_init(self):
|
def post_init(self):
|
||||||
pass
|
pass
|
||||||
|
@ -433,7 +433,7 @@ class Key:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Key(code={}, has_modifiers={})'.format(self.code, self.has_modifiers)
|
return f'Key(code={self.code}, has_modifiers={self.has_modifiers})'
|
||||||
|
|
||||||
def on_press(self, state, coord_int=None, coord_raw=None):
|
def on_press(self, state, coord_int=None, coord_raw=None):
|
||||||
if hasattr(self, '_pre_press_handlers'):
|
if hasattr(self, '_pre_press_handlers'):
|
||||||
@ -616,9 +616,7 @@ class ModifierKey(Key):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'ModifierKey(code={}, has_modifiers={})'.format(
|
return f'ModifierKey(code={self.code}, has_modifiers={self.has_modifiers})'
|
||||||
self.code, self.has_modifiers
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ConsumerKey(Key):
|
class ConsumerKey(Key):
|
||||||
|
@ -67,37 +67,27 @@ class KMKKeyboard:
|
|||||||
# real known fix yet other than turning off debug, but M4s have always been
|
# real known fix yet other than turning off debug, but M4s have always been
|
||||||
# tight on RAM so....
|
# tight on RAM so....
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (
|
return ''.join(
|
||||||
'KMKKeyboard(\n'
|
[
|
||||||
' debug_enabled={}, '
|
'KMKKeyboard(\n',
|
||||||
'diode_orientation={}, '
|
f' debug_enabled={self.debug_enabled}, ',
|
||||||
'matrix={},\n'
|
f'diode_orientation={self.diode_orientation}, ',
|
||||||
' unicode_mode={}, '
|
f'matrix={self.matrix},\n',
|
||||||
'_hid_helper={},\n'
|
f' unicode_mode={self.unicode_mode}, ',
|
||||||
' keys_pressed={},\n'
|
f'_hid_helper={self._hid_helper},\n',
|
||||||
' coordkeys_pressed={},\n'
|
f' keys_pressed={self.keys_pressed},\n',
|
||||||
' hid_pending={}, '
|
f' _coordkeys_pressed={self._coordkeys_pressed},\n',
|
||||||
'active_layers={}, '
|
f' hid_pending={self.hid_pending}, ',
|
||||||
'timeouts={}\n'
|
f'active_layers={self.active_layers}, ',
|
||||||
')'
|
f'_timeouts={self._timeouts}\n',
|
||||||
).format(
|
')',
|
||||||
self.debug_enabled,
|
]
|
||||||
self.diode_orientation,
|
|
||||||
self.matrix,
|
|
||||||
self.unicode_mode,
|
|
||||||
self._hid_helper,
|
|
||||||
# internal state
|
|
||||||
self.keys_pressed,
|
|
||||||
self._coordkeys_pressed,
|
|
||||||
self.hid_pending,
|
|
||||||
self.active_layers,
|
|
||||||
self._timeouts,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _print_debug_cycle(self, init=False):
|
def _print_debug_cycle(self, init=False):
|
||||||
if self.debug_enabled:
|
if self.debug_enabled:
|
||||||
if init:
|
if init:
|
||||||
print('KMKInit(release={})'.format(KMK_RELEASE))
|
print(f'KMKInit(release={KMK_RELEASE})')
|
||||||
print(self)
|
print(self)
|
||||||
|
|
||||||
def _send_hid(self):
|
def _send_hid(self):
|
||||||
@ -107,7 +97,7 @@ class KMKKeyboard:
|
|||||||
hid_report.send()
|
hid_report.send()
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
if self.debug_enabled:
|
if self.debug_enabled:
|
||||||
print('HidNotFound(HIDReportType={})'.format(e))
|
print(f'HidNotFound(HIDReportType={e})')
|
||||||
self.hid_pending = False
|
self.hid_pending = False
|
||||||
|
|
||||||
def _handle_matrix_report(self, update=None):
|
def _handle_matrix_report(self, update=None):
|
||||||
@ -120,7 +110,7 @@ class KMKKeyboard:
|
|||||||
idx = self.coord_mapping.index(int_coord)
|
idx = self.coord_mapping.index(int_coord)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if self.debug_enabled:
|
if self.debug_enabled:
|
||||||
print('CoordMappingNotFound(ic={})'.format(int_coord))
|
print(f'CoordMappingNotFound(ic={int_coord})')
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -141,7 +131,7 @@ class KMKKeyboard:
|
|||||||
int_coord = kevent.key_number
|
int_coord = kevent.key_number
|
||||||
is_pressed = kevent.pressed
|
is_pressed = kevent.pressed
|
||||||
if self.debug_enabled:
|
if self.debug_enabled:
|
||||||
print('\nMatrixChange(ic={}, pressed={})'.format(int_coord, is_pressed))
|
print(f'\nMatrixChange(ic={int_coord}, pressed={is_pressed})')
|
||||||
|
|
||||||
key = None
|
key = None
|
||||||
if not is_pressed:
|
if not is_pressed:
|
||||||
@ -156,11 +146,11 @@ class KMKKeyboard:
|
|||||||
|
|
||||||
if key is None:
|
if key is None:
|
||||||
if self.debug_enabled:
|
if self.debug_enabled:
|
||||||
print('MatrixUndefinedCoordinate(ic={})'.format(int_coord))
|
print(f'MatrixUndefinedCoordinate(ic={int_coord})')
|
||||||
return self
|
return self
|
||||||
|
|
||||||
if self.debug_enabled:
|
if self.debug_enabled:
|
||||||
print('KeyResolution(key={})'.format(key))
|
print(f'KeyResolution(key={key})')
|
||||||
|
|
||||||
self.pre_process_key(key, is_pressed, int_coord)
|
self.pre_process_key(key, is_pressed, int_coord)
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class Trackball(Module):
|
|||||||
chip_id = struct.unpack('<H', bytearray(self._i2c_rdwr([REG_CHIP_ID_L], 2)))[0]
|
chip_id = struct.unpack('<H', bytearray(self._i2c_rdwr([REG_CHIP_ID_L], 2)))[0]
|
||||||
if chip_id != CHIP_ID:
|
if chip_id != CHIP_ID:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
'Invalid chip ID: 0x{:04X}, expected 0x{:04X}'.format(chip_id, CHIP_ID)
|
f'Invalid chip ID: 0x{chip_id:04X}, expected 0x{CHIP_ID:04X}'
|
||||||
)
|
)
|
||||||
|
|
||||||
make_key(
|
make_key(
|
||||||
|
@ -63,9 +63,7 @@ class MatrixScanner(Scanner):
|
|||||||
]
|
]
|
||||||
self.translate_coords = False
|
self.translate_coords = False
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(f'Invalid DiodeOrientation: {self.diode_orienttaion}')
|
||||||
'Invalid DiodeOrientation: {}'.format(self.diode_orientation)
|
|
||||||
)
|
|
||||||
|
|
||||||
for pin in self.outputs:
|
for pin in self.outputs:
|
||||||
pin.switch_to_output()
|
pin.switch_to_output()
|
||||||
|
Loading…
Reference in New Issue
Block a user