Write the JSON sessions to the given filename. Args: sessions The parsed JSON sessions to dump into filename. filename (string) The path to the file to write the parsed JSON file to. indent (int) The number of spaces per line to write to the file. A value of N
(sessions, filename, indent)
| 176 | |
| 177 | |
| 178 | def write_sessions(sessions, filename, indent): |
| 179 | """ Write the JSON sessions to the given filename. |
| 180 | |
| 181 | Args: |
| 182 | sessions The parsed JSON sessions to dump into filename. |
| 183 | filename (string) The path to the file to write the parsed JSON file to. |
| 184 | indent (int) The number of spaces per line to write to the file. A |
| 185 | value of None causes the whole JSON file to be written as a single line. |
| 186 | """ |
| 187 | new_json = deepcopy(TEMPLATE) |
| 188 | new_json["sessions"] = deepcopy(sessions) |
| 189 | with open(filename, "w") as f: |
| 190 | json.dump(new_json, f, ensure_ascii=False, indent=indent) |
| 191 | logging.debug(f"{filename} has {len(sessions)} sessions") |
| 192 | |
| 193 | |
| 194 | class ParseJSONError(PostProcessError): |
no test coverage detected