Skip to content

Commit 5b17fcf

Browse files
committed
ftespnow: Fix code formatting errors.
Signed-off-by: Guilherme Laurindo Schneck <guilhermeschneck@gmail.com>
1 parent a28e4c5 commit 5b17fcf

4 files changed

Lines changed: 49 additions & 49 deletions

File tree

micropython/ftespnow/examples/client_side_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# Write received data to .txt file
3939
txt_received = esp.receive_to_txt(
4040
"filepath/filename.txt", mode="w"
41-
) # Set mode to 'w' so file is truncated before writing
41+
) # Set mode to 'w' so file is truncated before writing
4242
if txt_received:
4343
print("File received successfully")
4444
else:
@@ -47,7 +47,7 @@
4747
# Write received data to .json file
4848
json_received = esp.receive_to_json(
4949
"filepath/filename.json", mode="w"
50-
) # Set mode to 'w' so file is truncated before writing
50+
) # Set mode to 'w' so file is truncated before writing
5151
if json_received:
5252
print("File received successfully")
5353
else:

micropython/ftespnow/examples/server_side_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
message = "Hello"
88
peer = "a4f00f772d15" # Mac address of the client that you want to send data to
99
sent = esp.send_message(peer, message)
10-
if sent: # Check if client received the data
10+
if sent: # Check if client received the data
1111
print("Message received by clientclient")
1212
else:
1313
print("Message not received by client")
@@ -36,7 +36,7 @@
3636
# Write received data to .txt file
3737
txt_received = esp.receive_to_txt(
3838
"filepath/filename.txt", mode="w"
39-
) # Set mode to 'w' so file is truncated before writing
39+
) # Set mode to 'w' so file is truncated before writing
4040
if txt_received:
4141
print("File received successfully")
4242
else:
@@ -45,7 +45,7 @@
4545
# Write received data to .json file
4646
json_received = esp.receive_to_json(
4747
"filepath/filename.json", mode="w"
48-
) # Set mode to 'w' so file is truncated before writing
48+
) # Set mode to 'w' so file is truncated before writing
4949
if json_received: # Check if any data was received
5050
print("File received successfully")
5151
else:

micropython/ftespnow/ftespnow-client/ftespnow/client.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44

55
class CLIENT:
6-
def __init__(self, *, timeout: int = 5) -> None:
6+
def __init__(self, *, timeout :int = 5) -> None:
77
self.esp = espnow.ESPNow()
88
self.timeout = timeout
99

10-
def configure(self, *, timeout: int = 5) -> None:
10+
def configure(self, *, timeout :int = 5) -> None:
1111
self.timeout: int = timeout
1212

13-
def connect(self, peer: str) -> None:
13+
def connect(self, peer :str) -> None:
1414
self.peer: str = peer
1515
self.esp.active(True)
1616
self.esp.add_peer(self.peer)
1717

18-
def send_message(self, data: str) -> bool:
18+
def send_message(self, data :str) -> bool:
1919
"""
2020
Send a string
2121
@@ -28,7 +28,7 @@ def send_message(self, data: str) -> bool:
2828
bool: Confirmation flag (`True` if data was received, `False` otherwise)
2929
"""
3030

31-
ack: bool = self.esp.send(self.peer, data)
31+
ack :bool = self.esp.send(self.peer, data)
3232
return ack
3333

3434
def receive_message(self, recv_timeout :int = 5) -> list | None:
@@ -49,7 +49,7 @@ def receive_message(self, recv_timeout :int = 5) -> list | None:
4949
return
5050
return received
5151

52-
def send_txt(self, filename: str) -> bool:
52+
def send_txt(self, filename :str) -> bool:
5353
"""
5454
Parse and send a `.txt` file as a `string`
5555
@@ -63,11 +63,11 @@ def send_txt(self, filename: str) -> bool:
6363
"""
6464

6565
with open(filename, "r") as f:
66-
data: str = str(f.readlines())
67-
sent: bool = self.send_message(data)
66+
data :str = str(f.readlines())
67+
sent :bool = self.send_message(data)
6868
return sent
6969

70-
def send_json(self, filename: str, *, indent: int = 4) -> bool:
70+
def send_json(self, filename :str, *, indent :int = 4) -> bool:
7171
"""
7272
Parse and send a `.json` file as a `string`
7373
@@ -84,11 +84,11 @@ def send_json(self, filename: str, *, indent: int = 4) -> bool:
8484

8585
with open(filename, "r") as f:
8686
unparsed = json.load(f)
87-
parsed: str = json.dumps(unparsed, indent=indent)
88-
sent: bool = self.send_message(parsed)
87+
parsed :str = json.dumps(unparsed, indent=indent)
88+
sent :bool = self.send_message(parsed)
8989
return sent
9090

91-
def receive_to_txt(self, target_file: str, mode: str = "a") -> bool:
91+
def receive_to_txt(self, target_file :str, mode :str = "a") -> bool:
9292
"""
9393
Write received `string` into a `.txt` file.
9494
@@ -126,11 +126,11 @@ def receive_to_txt(self, target_file: str, mode: str = "a") -> bool:
126126
if ".txt" not in target_file:
127127
raise SyntaxError("File format must be .txt")
128128
try:
129-
received: bool = False
130-
data: list | None = self.receive_message()
129+
received :bool = False
130+
data :list | None = self.receive_message()
131131
if data is None:
132132
return received
133-
data_list: list[str] = str(data[-1]).split("\n")
133+
data_list :list[str] = str(data[-1]).split("\n")
134134
if data_list[-1] == "":
135135
data_list = data_list[:-1]
136136
with open(target_file, mode) as f:
@@ -139,7 +139,7 @@ def receive_to_txt(self, target_file: str, mode: str = "a") -> bool:
139139
except SyntaxError:
140140
raise
141141

142-
def receive_to_json(self, target_file: str, mode: str = "a") -> bool:
142+
def receive_to_json(self, target_file :str, mode :str = "a") -> bool:
143143
"""
144144
Write received `string` into a `.json` file.
145145
@@ -177,13 +177,13 @@ def receive_to_json(self, target_file: str, mode: str = "a") -> bool:
177177
if ".json" not in target_file:
178178
raise SyntaxError("File format must be .json")
179179
try:
180-
received: bool = False
181-
data: list | None = self.receive_message()
180+
received :bool = False
181+
data :list | None = self.receive_message()
182182
if data is None:
183183
return received
184-
mac: str = str(data[0])
184+
mac :str = str(data[0])
185185
message = json.loads(str(data[-1]))
186-
unparsed: dict = {"mac": mac, "message": message}
186+
unparsed :dict = {"mac": mac, "message": message}
187187
with open(target_file, mode) as f:
188188
json.dump(unparsed, f)
189189
return not received
@@ -203,10 +203,10 @@ def receive_to_dict(self) -> dict:
203203
unparsed (dict): `dictionary` object containing unparsed equivalent of the received `.json`
204204
"""
205205

206-
data: list | None = self.receive_message()
206+
data :list | None = self.receive_message()
207207
if data is None:
208208
return {}
209-
mac: str = str(data[0])
209+
mac :str = str(data[0])
210210
message = json.loads(str(data[-1]))
211-
unparsed: dict = {"mac": mac, "message": message}
211+
unparsed :dict = {"mac": mac, "message": message}
212212
return unparsed

micropython/ftespnow/ftespnow-server/ftespnow/server.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import json
33

44
class SERVER:
5-
def __init__(self, *, timeout: int = 5) -> None:
5+
def __init__(self, *, timeout :int = 5) -> None:
66
self.esp = espnow.ESPNow()
77
self.timeout = timeout
88

9-
def configure(self, *, timeout: int = 5) -> None:
9+
def configure(self, *, timeout :int = 5) -> None:
1010
self.timeout = timeout
1111

12-
def send_message(self, peer: str, data: str) -> bool:
12+
def send_message(self, peer :str, data :str) -> bool:
1313
"""
1414
Send a string
1515
@@ -24,7 +24,7 @@ def send_message(self, peer: str, data: str) -> bool:
2424
bool: Confirmation flag (`True` if data was received, `False` otherwise)
2525
"""
2626

27-
ack: bool = self.esp.send(peer, data)
27+
ack :bool = self.esp.send(peer, data)
2828
return ack
2929

3030
def receive_message(self, recv_timeout :int = 5) -> list | None:
@@ -45,7 +45,7 @@ def receive_message(self, recv_timeout :int = 5) -> list | None:
4545
return
4646
return received
4747

48-
def send_txt(self, peer: str, filename: str) -> bool:
48+
def send_txt(self, peer :str, filename :str) -> bool:
4949
"""
5050
Parse and send a `.txt` file as a `string`
5151
@@ -61,11 +61,11 @@ def send_txt(self, peer: str, filename: str) -> bool:
6161
"""
6262

6363
with open(filename, "r") as f:
64-
data: str = str(f.readlines())
65-
sent: bool = self.send_message(peer, data)
64+
data :str = str(f.readlines())
65+
sent :bool = self.send_message(peer, data)
6666
return sent
6767

68-
def send_json(self, peer: str, filename: str, *, indent: int = 4) -> bool:
68+
def send_json(self, peer :str, filename :str, *, indent :int = 4) -> bool:
6969
"""
7070
Parse and send a `.json` file as a `string`
7171
@@ -84,11 +84,11 @@ def send_json(self, peer: str, filename: str, *, indent: int = 4) -> bool:
8484

8585
with open(filename, "r") as f:
8686
unparsed = json.load(f)
87-
parsed: str = json.dumps(unparsed, indent=indent)
88-
sent: bool = self.send_message(peer, parsed)
87+
parsed :str = json.dumps(unparsed, indent=indent)
88+
sent :bool = self.send_message(peer, parsed)
8989
return sent
9090

91-
def receive_to_txt(self, target_file: str, mode: str = "a") -> bool:
91+
def receive_to_txt(self, target_file :str, mode :str = "a") -> bool:
9292
"""
9393
Write received `string` into a `.txt` file.
9494
@@ -126,10 +126,10 @@ def receive_to_txt(self, target_file: str, mode: str = "a") -> bool:
126126
if ".txt" not in target_file:
127127
raise SyntaxError("File format must be .txt")
128128
try:
129-
data: list | None = self.receive_message()
129+
data :list | None = self.receive_message()
130130
if data is None:
131131
return False
132-
data_list: list[str] = str(data[-1]).split("\n")
132+
data_list :list[str] = str(data[-1]).split("\n")
133133
if data_list[-1] == "":
134134
data_list = data_list[:-1]
135135
with open(target_file, mode) as f:
@@ -138,7 +138,7 @@ def receive_to_txt(self, target_file: str, mode: str = "a") -> bool:
138138
except SyntaxError:
139139
raise
140140

141-
def receive_to_json(self, target_file: str, mode: str = "a") -> bool:
141+
def receive_to_json(self, target_file :str, mode :str = "a") -> bool:
142142
"""
143143
Write received `string` into a `.json` file.
144144
@@ -176,13 +176,13 @@ def receive_to_json(self, target_file: str, mode: str = "a") -> bool:
176176
if ".json" not in target_file:
177177
raise SyntaxError("File format must be .json")
178178
try:
179-
received: bool = False
180-
data: list | None = self.receive_message()
179+
received :bool = False
180+
data :list | None = self.receive_message()
181181
if data is None:
182182
return received
183-
mac: str = str(data[0])
183+
mac :str = str(data[0])
184184
message = json.loads(str(data[-1]))
185-
unparsed: dict = {"mac": mac, "message": message}
185+
unparsed :dict = {"mac": mac, "message": message}
186186
with open(target_file, mode) as f:
187187
json.dump(unparsed, f)
188188
return not received
@@ -202,10 +202,10 @@ def receive_to_dict(self) -> dict:
202202
unparsed (dict): `dictionary` object containing unparsed equivalent of the received `.json`
203203
"""
204204

205-
data: list | None = self.receive_message()
205+
data :list | None = self.receive_message()
206206
if data is None:
207207
return {}
208-
mac: str = str(data[0])
208+
mac :str = str(data[0])
209209
message = json.loads(str(data[-1]))
210-
unparsed: dict = {"mac": mac, "message": message}
210+
unparsed :dict = {"mac": mac, "message": message}
211211
return unparsed

0 commit comments

Comments
 (0)