Commit e837ab8cd2e6ba2da499ea2cd79dcae3e1aabf60

Authored by Philippe Lagadec
1 parent 2d2d5c2c

Added comments for pylint

oletools/ezhexviewer.py
@@ -132,6 +132,7 @@ def hexdump3(src, length=8, startindex=0): @@ -132,6 +132,7 @@ def hexdump3(src, length=8, startindex=0):
132 startindex: index of 1st byte. 132 startindex: index of 1st byte.
133 """ 133 """
134 result=[] 134 result=[]
  135 + # pylint: disable-next=possibly-used-before-assignment
135 for i in xrange(0, len(src), length): 136 for i in xrange(0, len(src), length):
136 s = src[i:i+length] 137 s = src[i:i+length]
137 hexa = ' '.join(["%02X" % xord(x) for x in s]) 138 hexa = ' '.join(["%02X" % xord(x) for x in s])
oletools/msodde.py
@@ -388,6 +388,7 @@ def process_doc_stream(stream): @@ -388,6 +388,7 @@ def process_doc_stream(stream):
388 # appending a raw byte to a unicode string here. Not clean but 388 # appending a raw byte to a unicode string here. Not clean but
389 # all we do later is check for the ascii-sequence 'DDE' later... 389 # all we do later is check for the ascii-sequence 'DDE' later...
390 elif char == 0: # may be a high-byte of a 2-byte codec 390 elif char == 0: # may be a high-byte of a 2-byte codec
  391 + # pylint: disable-next=possibly-used-before-assignment
391 field_contents += unichr(char) 392 field_contents += unichr(char)
392 elif char in (10, 13): 393 elif char in (10, 13):
393 field_contents += u'\n' 394 field_contents += u'\n'
oletools/oleobj.py
@@ -332,6 +332,7 @@ def read_zero_terminated_string(data, index): @@ -332,6 +332,7 @@ def read_zero_terminated_string(data, index):
332 """ 332 """
333 if index is None: 333 if index is None:
334 result = bytearray() 334 result = bytearray()
  335 + # pylint: disable-next=possibly-used-before-assignment
335 for _ in xrange(STR_MAX_LEN): 336 for _ in xrange(STR_MAX_LEN):
336 char = ord(data.read(1)) # need ord() for py3 337 char = ord(data.read(1)) # need ord() for py3
337 if char == 0: 338 if char == 0:
oletools/olevba.py
@@ -1050,6 +1050,7 @@ def vba_chr_tostr(t): @@ -1050,6 +1050,7 @@ def vba_chr_tostr(t):
1050 else: 1050 else:
1051 # unicode character 1051 # unicode character
1052 # Note: this distinction is only needed for Python 2 1052 # Note: this distinction is only needed for Python 2
  1053 + # pylint: disable-next=possibly-used-before-assignment
1053 return VbaExpressionString(unichr(i).encode('utf-8', 'backslashreplace')) 1054 return VbaExpressionString(unichr(i).encode('utf-8', 'backslashreplace'))
1054 except ValueError: 1055 except ValueError:
1055 log.exception('ERROR: incorrect parameter value for chr(): %r' % i) 1056 log.exception('ERROR: incorrect parameter value for chr(): %r' % i)
@@ -1165,6 +1166,7 @@ def subtract_ints_list(tokens): @@ -1165,6 +1166,7 @@ def subtract_ints_list(tokens):
1165 # extract argument from the tokens: 1166 # extract argument from the tokens:
1166 # expected to be a tuple containing a list of integers such as [a,'&',b,'&',c,...] 1167 # expected to be a tuple containing a list of integers such as [a,'&',b,'&',c,...]
1167 integers = tokens[0][::2] 1168 integers = tokens[0][::2]
  1169 + # pylint: disable-next=possibly-used-before-assignment
1168 return reduce(lambda x,y:x-y, integers) 1170 return reduce(lambda x,y:x-y, integers)
1169 1171
1170 1172
@@ -1407,6 +1409,7 @@ def decompress_stream(compressed_container): @@ -1407,6 +1409,7 @@ def decompress_stream(compressed_container):
1407 # copy tokens (reference to a previous literal token) 1409 # copy tokens (reference to a previous literal token)
1408 flag_byte = compressed_container[compressed_current] 1410 flag_byte = compressed_container[compressed_current]
1409 compressed_current += 1 1411 compressed_current += 1
  1412 + # pylint: disable-next=possibly-used-before-assignment
1410 for bit_index in xrange(0, 8): 1413 for bit_index in xrange(0, 8):
1411 # log.debug('bit_index=%d / compressed_current=%d / compressed_end=%d' % (bit_index, compressed_current, compressed_end)) 1414 # log.debug('bit_index=%d / compressed_current=%d / compressed_end=%d' % (bit_index, compressed_current, compressed_end))
1412 if compressed_current >= compressed_end: 1415 if compressed_current >= compressed_end:
@@ -2434,6 +2437,7 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'): @@ -2434,6 +2437,7 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'):
2434 else: 2437 else:
2435 # on Python 3, just keep Unicode strings as-is: 2438 # on Python 3, just keep Unicode strings as-is:
2436 return json_obj 2439 return json_obj
  2440 + # pylint: disable-next=possibly-used-before-assignment
2437 elif isinstance(json_obj, unicode) and PYTHON2: 2441 elif isinstance(json_obj, unicode) and PYTHON2:
2438 # On Python 2, encode unicode to bytes: 2442 # On Python 2, encode unicode to bytes:
2439 json_obj_bytes = json_obj.encode(encoding, errors) 2443 json_obj_bytes = json_obj.encode(encoding, errors)