From 7fde5671dc0ef07d0ab41f69a9e78ae5c6fdd018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Sat, 7 Jun 2014 11:32:43 +0200 Subject: [PATCH] use yield from instead of explicit version --- pysstv/color.py | 9 +++------ pysstv/grayscale.py | 6 ++---- pysstv/sstv.py | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pysstv/color.py b/pysstv/color.py index 5bcb600..dd852ff 100644 --- a/pysstv/color.py +++ b/pysstv/color.py @@ -16,14 +16,12 @@ class ColorSSTV(GrayscaleSSTV): msec_pixel = self.SCAN / self.WIDTH image = self.pixels for index in self.COLOR_SEQ: - for item in self.before_channel(index): - yield item + yield from self.before_channel(index) for col in range(self.WIDTH): pixel = image[col, line] freq_pixel = byte_to_freq(pixel[index]) yield freq_pixel, msec_pixel - for item in self.after_channel(index): - yield item + yield from self.after_channel(index) def before_channel(self, index): return [] @@ -65,8 +63,7 @@ class ScottieS1(MartinM1): def before_channel(self, index): if index == RED: - for item in MartinM1.horizontal_sync(self): - yield item + yield from MartinM1.horizontal_sync(self) yield FREQ_BLACK, self.INTER_CH_GAP diff --git a/pysstv/grayscale.py b/pysstv/grayscale.py index 75472aa..cc225cd 100644 --- a/pysstv/grayscale.py +++ b/pysstv/grayscale.py @@ -10,10 +10,8 @@ class GrayscaleSSTV(SSTV): def gen_image_tuples(self): for line in range(self.HEIGHT): - for item in self.horizontal_sync(): - yield item - for item in self.encode_line(line): - yield item + yield from self.horizontal_sync() + yield from self.encode_line(line) def encode_line(self, line): msec_pixel = self.SCAN / self.WIDTH diff --git a/pysstv/sstv.py b/pysstv/sstv.py index 3ac4d68..e742851 100644 --- a/pysstv/sstv.py +++ b/pysstv/sstv.py @@ -113,8 +113,7 @@ class SSTV(object): parity_freq = FREQ_VIS_BIT1 if num_ones % 2 == 1 else FREQ_VIS_BIT0 yield parity_freq, MSEC_VIS_BIT yield FREQ_SYNC, MSEC_VIS_BIT # stop bit - for freq_tuple in self.gen_image_tuples(): - yield freq_tuple + yield from self.gen_image_tuples() for fskid_byte in map(ord, self.fskid_payload): for _ in range(6): bit = fskid_byte & 1