20
20
# runtime is compatible with the generated code.
21
21
API_VERSION = (0 , 10 )
22
22
23
+ # pylint:disable=bad-indentation,too-many-public-methods,useless-object-inheritance,super-with-arguments
23
24
24
25
class KaitaiStruct (object ):
25
26
def __init__ (self , stream ):
@@ -79,9 +80,9 @@ def is_eof(self):
79
80
t = io .read (1 )
80
81
if t == b'' :
81
82
return True
82
- else :
83
- io .seek (- 1 , SEEK_CUR )
84
- return False
83
+
84
+ io .seek (- 1 , SEEK_CUR )
85
+ return False
85
86
86
87
def seek (self , n ):
87
88
self ._io .seek (n )
@@ -334,16 +335,17 @@ def read_bytes_term(self, term, include_term, consume_term, eos_error):
334
335
"end of stream reached, but no terminator %d found" %
335
336
(term ,)
336
337
)
337
- else :
338
- return r
339
- elif ord (c ) == term :
338
+
339
+ return r
340
+
341
+ if ord (c ) == term :
340
342
if include_term :
341
343
r += c
342
344
if not consume_term :
343
345
self ._io .seek (- 1 , SEEK_CUR )
344
346
return r
345
- else :
346
- r += c
347
+
348
+ r += c
347
349
348
350
def ensure_fixed_contents (self , expected ):
349
351
actual = self ._io .read (len (expected ))
@@ -373,15 +375,15 @@ def bytes_terminate(data, term, include_term):
373
375
def process_xor_one (data , key ):
374
376
if PY2 :
375
377
return bytes (bytearray (v ^ key for v in bytearray (data )))
376
- else :
377
- return bytes (v ^ key for v in data )
378
+
379
+ return bytes (v ^ key for v in data )
378
380
379
381
@staticmethod
380
382
def process_xor_many (data , key ):
381
383
if PY2 :
382
384
return bytes (bytearray (a ^ b for a , b in zip (bytearray (data ), itertools .cycle (bytearray (key )))))
383
- else :
384
- return bytes (a ^ b for a , b in zip (data , itertools .cycle (key )))
385
+
386
+ return bytes (a ^ b for a , b in zip (data , itertools .cycle (key )))
385
387
386
388
@staticmethod
387
389
def process_rotate_left (data , amount , group_size ):
@@ -395,7 +397,7 @@ def process_rotate_left(data, amount, group_size):
395
397
anti_amount = - amount & mask
396
398
397
399
r = bytearray (data )
398
- for i in range (len (r )):
400
+ for i in range (len (r )): # pylint:disable=consider-using-enumerate
399
401
r [i ] = (r [i ] << amount ) & 0xff | (r [i ] >> anti_amount )
400
402
return bytes (r )
401
403
@@ -477,19 +479,19 @@ class ValidationLessThanError(ValidationFailedError):
477
479
"""Signals validation failure: we required "actual" value to be
478
480
greater than or equal to "min", but it turned out that it's not.
479
481
"""
480
- def __init__ (self , min , actual , io , src_path ):
481
- super (ValidationLessThanError , self ).__init__ ("not in range, min %s, but got %s" % (repr (min ), repr (actual )), io , src_path )
482
- self .min = min
482
+ def __init__ (self , min_bound , actual , io , src_path ):
483
+ super (ValidationLessThanError , self ).__init__ ("not in range, min %s, but got %s" % (repr (min_bound ), repr (actual )), io , src_path )
484
+ self .min = min_bound
483
485
self .actual = actual
484
486
485
487
486
488
class ValidationGreaterThanError (ValidationFailedError ):
487
489
"""Signals validation failure: we required "actual" value to be
488
490
less than or equal to "max", but it turned out that it's not.
489
491
"""
490
- def __init__ (self , max , actual , io , src_path ):
491
- super (ValidationGreaterThanError , self ).__init__ ("not in range, max %s, but got %s" % (repr (max ), repr (actual )), io , src_path )
492
- self .max = max
492
+ def __init__ (self , max_bound , actual , io , src_path ):
493
+ super (ValidationGreaterThanError , self ).__init__ ("not in range, max %s, but got %s" % (repr (max_bound ), repr (actual )), io , src_path )
494
+ self .max = max_bound
493
495
self .actual = actual
494
496
495
497
0 commit comments