Commit 3463905db47c40dbbfdfe4f8d928bdfeda2ba7a8

Authored by Christian Herdtweck
1 parent 4c1151ea

add n_processed=count to last json meta entry, try to set the is_last apart from json fields

Showing 1 changed file with 5 additions and 5 deletions
oletools/olevba.py
... ... @@ -1785,15 +1785,15 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'):
1785 1785  
1786 1786 _have_printed_json_start = False
1787 1787  
1788   -def print_json(json_dict=None, is_last=False, **json_parts):
  1788 +def print_json(json_dict=None, _json_is_last=False, **json_parts):
1789 1789 """ line-wise print of json.dumps(json2ascii(..)) with options and indent+1
1790 1790  
1791 1791 can use in two ways:
1792 1792 (1) print_json(some_dict)
1793 1793 (2) print_json(key1=value1, key2=value2, ...)
1794 1794  
1795   - :param bool is_last: set to True only for very last entry to complete
1796   - the top-level json-list
  1795 + :param bool _json_is_last: set to True only for very last entry to complete
  1796 + the top-level json-list
1797 1797 """
1798 1798 global _have_printed_json_start
1799 1799  
... ... @@ -1815,7 +1815,7 @@ def print_json(json_dict=None, is_last=False, **json_parts):
1815 1815 indent=4, ensure_ascii=False).splitlines()
1816 1816 for line in lines[:-1]:
1817 1817 print ' {}'.format(line)
1818   - if is_last:
  1818 + if _json_is_last:
1819 1819 print ' {}'.format(lines[-1]) # print last line without comma
1820 1820 print ']'
1821 1821 else:
... ... @@ -3050,7 +3050,7 @@ def main():
3050 3050 if options.output_mode == 'json':
3051 3051 # print last json entry (a last one without a comma) and closing ]
3052 3052 print_json(type='MetaInformation', return_code=return_code,
3053   - is_last=True)
  3053 + n_processed=count, _json_is_last=True)
3054 3054  
3055 3055 except Exception as exc:
3056 3056 # some unexpected error, maybe some of the types caught in except clauses
... ...