Ignore:
Timestamp:
2022-07-28T23:48:34+12:00 (21 months ago)
Author:
davidb
Message:

Code tidy up, and refactoring to have a saveJSON function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/bib-stinky/trunk/doi-stinky/util.py

    r36323 r36331  
    11from __future__ import print_function
    22
     3import json
    34import re
    45import sys
     
    2728
    2829    return key
     30
     31def writeJSON(json_output_filename,returned_json):
     32
     33    returned_json_prettyprint = json.dumps(returned_json, indent=2, ensure_ascii=False)
     34
     35    print("Saving returned JSON output to: " + json_output_filename)
     36
     37    # write output with auto-close file handle
     38    with open(json_output_filename, 'w', encoding="utf8") as fout:
     39        fout.write(returned_json_prettyprint)
Note: See TracChangeset for help on using the changeset viewer.