mirror of https://github.com/Nonannet/pyhoff.git
Escaping for f-strings fixed
This commit is contained in:
parent
d748553711
commit
5aab2d6d74
1
.flake8
1
.flake8
|
@ -14,6 +14,7 @@ exclude =
|
||||||
dist,
|
dist,
|
||||||
.conda
|
.conda
|
||||||
.venv
|
.venv
|
||||||
|
venv
|
||||||
|
|
||||||
# Enable specific plugins or options
|
# Enable specific plugins or options
|
||||||
# Example: Enabling flake8-docstrings
|
# Example: Enabling flake8-docstrings
|
||||||
|
|
|
@ -45,8 +45,8 @@ class BusTerminal():
|
||||||
@classmethod
|
@classmethod
|
||||||
def select(cls, bus_coupler: 'BusCoupler', terminal_number: int = 0) -> 'BusTerminal':
|
def select(cls, bus_coupler: 'BusCoupler', terminal_number: int = 0) -> 'BusTerminal':
|
||||||
terminal_list = [bt for bt in bus_coupler.bus_terminals if isinstance(bt, cls)]
|
terminal_list = [bt for bt in bus_coupler.bus_terminals if isinstance(bt, cls)]
|
||||||
assert terminal_list, f'No instance of {cls.__name__} configured at this BusCoupler'
|
assert terminal_list, f"No instance of {cls.__name__} configured at this BusCoupler"
|
||||||
assert 0 <= terminal_number < len(terminal_list), f'Out of range, select in range: 0..{len(terminal_list) - 1}'
|
assert 0 <= terminal_number < len(terminal_list), f"Out of range, select in range: 0..{len(terminal_list) - 1}"
|
||||||
return terminal_list[terminal_number]
|
return terminal_list[terminal_number]
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ class BusCoupler():
|
||||||
terminal_classes.append(element)
|
terminal_classes.append(element)
|
||||||
|
|
||||||
for terminal_class in terminal_classes:
|
for terminal_class in terminal_classes:
|
||||||
assert _is_bus_terminal(terminal_class), f'{terminal_class} is not a bus terminal'
|
assert _is_bus_terminal(terminal_class), f"{terminal_class} is not a bus terminal"
|
||||||
|
|
||||||
def get_para(key: str) -> int:
|
def get_para(key: str) -> int:
|
||||||
return terminal_class.parameters.get(key, 0)
|
return terminal_class.parameters.get(key, 0)
|
||||||
|
|
|
@ -451,7 +451,7 @@ class SimpleModbusClient:
|
||||||
return bytes()
|
return bytes()
|
||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(f'<- Received: {' '.join(hex(b) for b in buffer)}')
|
print(f"<- Received: {' '.join(hex(b) for b in buffer)}")
|
||||||
|
|
||||||
return buffer
|
return buffer
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ class SimpleModbusClient:
|
||||||
try:
|
try:
|
||||||
self._socket.sendall(data)
|
self._socket.sendall(data)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(f'-> Send: {' '.join(hex(b) for b in data)}')
|
print(f"-> Send: {' '.join(hex(b) for b in data)}")
|
||||||
return len(data)
|
return len(data)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
self.last_error = 'sending data failed'
|
self.last_error = 'sending data failed'
|
||||||
|
@ -532,7 +532,7 @@ class SimpleModbusClient:
|
||||||
return self.close()
|
return self.close()
|
||||||
|
|
||||||
if data[0] > 0x80:
|
if data[0] > 0x80:
|
||||||
self.last_error = f'return error: {_modbus_exceptions.get(data[1], '')} ({data[1]})'
|
self.last_error = f"return error: {_modbus_exceptions.get(data[1], '')} ({data[1]})"
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(self.last_error)
|
print(self.last_error)
|
||||||
return bytes()
|
return bytes()
|
||||||
|
|
|
@ -14,7 +14,7 @@ def test_against_old_traces():
|
||||||
|
|
||||||
# dummy modbus send function
|
# dummy modbus send function
|
||||||
def debug_send_dummy(data: bytes) -> int:
|
def debug_send_dummy(data: bytes) -> int:
|
||||||
print(f'-> Send: {' '.join(hex(b) for b in data)}')
|
print(f"-> Send: {' '.join(hex(b) for b in data)}")
|
||||||
for b in data:
|
for b in data:
|
||||||
debug_data.append(f"{b:02X}")
|
debug_data.append(f"{b:02X}")
|
||||||
return len(data)
|
return len(data)
|
||||||
|
|
Loading…
Reference in New Issue