Skip to content

Commit

Permalink
Added comments for pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Lagadec committed May 30, 2024
1 parent 2d2d5c2 commit e837ab8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions oletools/ezhexviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def hexdump3(src, length=8, startindex=0):
startindex: index of 1st byte.
"""
result=[]
# pylint: disable-next=possibly-used-before-assignment
for i in xrange(0, len(src), length):
s = src[i:i+length]
hexa = ' '.join(["%02X" % xord(x) for x in s])
Expand Down
1 change: 1 addition & 0 deletions oletools/msodde.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def process_doc_stream(stream):
# appending a raw byte to a unicode string here. Not clean but
# all we do later is check for the ascii-sequence 'DDE' later...
elif char == 0: # may be a high-byte of a 2-byte codec
# pylint: disable-next=possibly-used-before-assignment
field_contents += unichr(char)
elif char in (10, 13):
field_contents += u'\n'
Expand Down
1 change: 1 addition & 0 deletions oletools/oleobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def read_zero_terminated_string(data, index):
"""
if index is None:
result = bytearray()
# pylint: disable-next=possibly-used-before-assignment
for _ in xrange(STR_MAX_LEN):
char = ord(data.read(1)) # need ord() for py3
if char == 0:
Expand Down
4 changes: 4 additions & 0 deletions oletools/olevba.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ def vba_chr_tostr(t):
else:
# unicode character
# Note: this distinction is only needed for Python 2
# pylint: disable-next=possibly-used-before-assignment
return VbaExpressionString(unichr(i).encode('utf-8', 'backslashreplace'))
except ValueError:
log.exception('ERROR: incorrect parameter value for chr(): %r' % i)
Expand Down Expand Up @@ -1165,6 +1166,7 @@ def subtract_ints_list(tokens):
# extract argument from the tokens:
# expected to be a tuple containing a list of integers such as [a,'&',b,'&',c,...]
integers = tokens[0][::2]
# pylint: disable-next=possibly-used-before-assignment
return reduce(lambda x,y:x-y, integers)


Expand Down Expand Up @@ -1407,6 +1409,7 @@ def decompress_stream(compressed_container):
# copy tokens (reference to a previous literal token)
flag_byte = compressed_container[compressed_current]
compressed_current += 1
# pylint: disable-next=possibly-used-before-assignment
for bit_index in xrange(0, 8):
# log.debug('bit_index=%d / compressed_current=%d / compressed_end=%d' % (bit_index, compressed_current, compressed_end))
if compressed_current >= compressed_end:
Expand Down Expand Up @@ -2434,6 +2437,7 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'):
else:
# on Python 3, just keep Unicode strings as-is:
return json_obj
# pylint: disable-next=possibly-used-before-assignment
elif isinstance(json_obj, unicode) and PYTHON2:
# On Python 2, encode unicode to bytes:
json_obj_bytes = json_obj.encode(encoding, errors)
Expand Down

0 comments on commit e837ab8

Please sign in to comment.