Skip to content

Commit a5737fe

Browse files
Minor code refactoring.
1 parent 7ec098a commit a5737fe

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

resources/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ def utils_write_JSON_file(json_filename, json_data, verbose = True, pprint = Fal
366366
l_start = time.time()
367367
if verbose: log_debug('utils_write_JSON_file() "{}"'.format(json_filename))
368368

369+
# Parameter pprint == True overrides option OPTION_COMPACT_JSON.
369370
# Choose JSON iterative encoder or normal encoder.
370371
if OPTION_LOWMEM_WRITE_JSON:
371372
if verbose: log_debug('utils_write_JSON_file() Using OPTION_LOWMEM_WRITE_JSON option')
@@ -379,26 +380,24 @@ def utils_write_JSON_file(json_filename, json_data, verbose = True, pprint = Fal
379380
jobj = json.JSONEncoder(ensure_ascii = False, sort_keys = True,
380381
indent = JSON_INDENT, separators = JSON_SEP)
381382
else:
382-
# Parameter pprint == True overrides option OPTION_COMPACT_JSON.
383383
if pprint:
384-
f_data = json.dumps(json_data, ensure_ascii = False, sort_keys = True,
384+
jdata = json.dumps(json_data, ensure_ascii = False, sort_keys = True,
385385
indent = JSON_INDENT, separators = JSON_SEP)
386386
else:
387387
if OPTION_COMPACT_JSON:
388-
f_data = json.dumps(json_data, ensure_ascii = False, sort_keys = True)
388+
jdata = json.dumps(json_data, ensure_ascii = False, sort_keys = True)
389389
else:
390-
f_data = json.dumps(json_data, ensure_ascii = False, sort_keys = True,
390+
jdata = json.dumps(json_data, ensure_ascii = False, sort_keys = True,
391391
indent = JSON_INDENT, separators = JSON_SEP)
392392

393393
# Write JSON to disk
394394
try:
395395
with io.open(json_filename, 'wt', encoding = 'utf-8') as file:
396396
if OPTION_LOWMEM_WRITE_JSON:
397-
# Chunk by chunk JSON writer, uses less memory but takes longer.
398397
for chunk in jobj.iterencode(json_data):
399398
file.write(chunk)
400399
else:
401-
file.write(f_data)
400+
file.write(jdata)
402401
except OSError:
403402
kodi_notify(ADDON_LONG_NAME, 'Cannot write {} file (OSError)'.format(json_filename))
404403
except IOError:

0 commit comments

Comments
 (0)