Skip to content

Commit 5b3c4fd

Browse files
SourceryAIiphydf
authored andcommitted
Refactored by Sourcery
1 parent 0c54a96 commit 5b3c4fd

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

examples/echo.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def on_audio_receive_frame(self, fid, pcm, sample_count,
7575
sys.stdout.flush()
7676
bret = self.audio_send_frame(fid, pcm, sample_count,
7777
channels, sampling_rate)
78-
if bret is False:
79-
pass
8078

8179
def on_video_receive_frame(self, fid, width, height, frame):
8280
# print('video frame: %d, %d, %d, ' % (fid, width, height))
@@ -85,7 +83,6 @@ def on_video_receive_frame(self, fid, width, height, frame):
8583
bret = self.video_send_frame(fid, width, height, frame)
8684
if bret is False:
8785
print('video send frame error.')
88-
pass
8986

9087
def witerate(self):
9188
self.iterate()

examples/phone.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ def on_end(self, idx):
130130
self.stop = True
131131
if self.ae_thread:
132132
self.ae_thread.join()
133-
if self.call_type == self.TypeVideo:
134-
if self.ve_thread:
135-
self.ve_thread.join()
133+
if self.call_type == self.TypeVideo and self.ve_thread:
134+
self.ve_thread.join()
136135

137136
self.kill_transmission(idx)
138137
print("Call ended")
@@ -261,9 +260,6 @@ def loop(self):
261260

262261
if readable:
263262
args = sys.stdin.readline().strip().split()
264-
if not args:
265-
pass
266-
267263
if args[0] == "add":
268264
try:
269265
self.friend_add(args[1], "Hi")
@@ -272,8 +268,6 @@ def loop(self):
272268
print('Friend added')
273269
elif args[0] == "msg":
274270
try:
275-
if len(args) <= 2:
276-
pass
277271
friend_number = int(args[1])
278272
msg = ' '.join(args[2:])
279273
self.friend_send_message(friend_number,

tests/tests.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def loop(self, n):
115115
t:iteration_interval
116116
"""
117117
interval = self.bob.iteration_interval()
118-
for i in range(n):
118+
for _ in range(n):
119119
self.alice.iterate()
120120
self.bob.iterate()
121121
sleep(interval / 2000.0)
@@ -127,10 +127,7 @@ def loop_until_connected(self):
127127
"""
128128

129129
def on_self_connection_status(self, status):
130-
if status != Tox.CONNECTION_NONE:
131-
self.mycon_status = True
132-
else:
133-
self.mycon_status = False
130+
self.mycon_status = True if status != Tox.CONNECTION_NONE else False
134131
assert self.self_get_connection_status() == status
135132

136133
self.alice.mycon_status = False
@@ -160,7 +157,7 @@ def wait_callbacks(self, obj, attrs):
160157
count = 0
161158
THRESHOLD = 400
162159

163-
while not all([getattr(obj, attr) for attr in attrs]):
160+
while not all(getattr(obj, attr) for attr in attrs):
164161
self.loop(50)
165162
if count >= THRESHOLD:
166163
return False
@@ -731,7 +728,6 @@ def on_file_recv_control2(self, fid, file_number, control):
731728
CONTEXT['START'] = True
732729
elif control == Tox.FILE_CONTROL_CANCEL:
733730
self.completed = True
734-
pass
735731

736732
def on_file_chunk_request(self, fid, file_number, position, length):
737733
if length == 0:
@@ -759,8 +755,7 @@ def on_file_chunk_request(self, fid, file_number, position, length):
759755
BobTox.on_file_chunk_request = Tox.on_file_chunk_request
760756

761757
if __name__ == '__main__':
762-
methods = set([x for x in dir(Tox)
763-
if not x[0].isupper() and not x[0] == '_'])
758+
methods = {x for x in dir(Tox) if not x[0].isupper() and x[0] != '_'}
764759
docs = "".join([getattr(ToxTest, x).__doc__ for x in dir(ToxTest)
765760
if getattr(ToxTest, x).__doc__ is not None])
766761

0 commit comments

Comments
 (0)