@@ -196,16 +196,13 @@ def _decode_bitonal(self):
196196 tokens = b"" .join (block .split ())
197197
198198 for token in tokens :
199- if token in (48 , 49 ):
200- tokens_read += 1
201- else :
199+ if token not in (48 , 49 ):
202200 raise ValueError (f"Invalid token for this mode: { bytes ([token ])} " )
203-
201+ tokens_read += 1
204202 decoded_data .append (token )
205203 if tokens_read == total_tokens : # finished!
206204 invert = bytes .maketrans (b"01" , b"\xFF \x00 " )
207- decoded_data = decoded_data .translate (invert )
208- return decoded_data
205+ return decoded_data .translate (invert )
209206
210207 def _decode_blocks (self , channels = 1 , depth = 8 ):
211208 decoded_data = bytearray ()
@@ -215,14 +212,13 @@ def _decode_blocks(self, channels=1, depth=8):
215212 bytes_per_sample = depth // 8
216213 total_tokens = self .size * channels
217214
218- token_spans = False
219215 comment_spans = False
220216 half_token = False
221217 tokens_read = 0
222218 while True :
223219 block = self ._read_block () # read next block
224220 if not block :
225- if token_spans :
221+ if half_token :
226222 block = bytearray (b" " ) # flush half_token
227223 else :
228224 raise ValueError ("Reached EOF while reading data" )
@@ -237,14 +233,12 @@ def _decode_blocks(self, channels=1, depth=8):
237233
238234 block , comment_spans = self ._ignore_comments (block )
239235
240- if token_spans :
236+ if half_token :
241237 block = half_token + block # stitch half_token to new block
242- token_spans = False
243238
244239 tokens = block .split ()
245240
246241 if block and not block [- 1 :].isspace (): # block might split token
247- token_spans = True
248242 half_token = tokens .pop () # save half token for later
249243 if len (half_token ) > max_len : # prevent buildup of half_token
250244 raise ValueError (
0 commit comments