@@ -369,6 +369,7 @@ def utils_write_JSON_file(json_filename, json_data, verbose = True, pprint = Fal
369369 l_start = time .time ()
370370 if verbose : log_debug ('utils_write_JSON_file() "{}"' .format (json_filename ))
371371
372+ # Parameter pprint == True overrides option OPTION_COMPACT_JSON.
372373 # Choose JSON iterative encoder or normal encoder.
373374 if OPTION_LOWMEM_WRITE_JSON :
374375 if verbose : log_debug ('utils_write_JSON_file() Using OPTION_LOWMEM_WRITE_JSON option' )
@@ -382,26 +383,26 @@ def utils_write_JSON_file(json_filename, json_data, verbose = True, pprint = Fal
382383 jobj = json .JSONEncoder (ensure_ascii = False , sort_keys = True ,
383384 indent = JSON_INDENT , separators = JSON_SEP )
384385 else :
385- # Parameter pprint == True overrides option OPTION_COMPACT_JSON.
386386 if pprint :
387- f_data = text_type ( json .dumps (json_data , ensure_ascii = False , sort_keys = True ,
388- indent = JSON_INDENT , separators = JSON_SEP ))
387+ jdata = json .dumps (json_data , ensure_ascii = False , sort_keys = True ,
388+ indent = JSON_INDENT , separators = JSON_SEP )
389389 else :
390390 if OPTION_COMPACT_JSON :
391- f_data = text_type ( json .dumps (json_data , ensure_ascii = False , sort_keys = True ) )
391+ jdata = json .dumps (json_data , ensure_ascii = False , sort_keys = True )
392392 else :
393- f_data = text_type ( json .dumps (json_data , ensure_ascii = False , sort_keys = True ,
394- indent = JSON_INDENT , separators = JSON_SEP ))
393+ jdata = json .dumps (json_data , ensure_ascii = False , sort_keys = True ,
394+ indent = JSON_INDENT , separators = JSON_SEP )
395395
396396 # Write JSON to disk
397397 try :
398398 with io .open (json_filename , 'wt' , encoding = 'utf-8' ) as file :
399399 if OPTION_LOWMEM_WRITE_JSON :
400- # Chunk by chunk JSON writer, uses less memory but takes longer.
401400 for chunk in jobj .iterencode (json_data ):
402- file .write (text_type (chunk ))
401+ chunk = text_type (chunk ) # Required in Python 2.
402+ file .write (chunk )
403403 else :
404- file .write (f_data )
404+ jdata = text_type (jdata ) # Required in Python 2.
405+ file .write (jdata )
405406 except OSError :
406407 kodi_notify (ADDON_LONG_NAME , 'Cannot write {} file (OSError)' .format (json_filename ))
407408 except IOError :
@@ -696,8 +697,7 @@ def kodi_dialog_get_file_multiple(d_heading, mask = '', d_file = ''):
696697 ret = xbmcgui .Dialog ().browse (1 , d_heading , '' , enableMultiple = True )
697698
698699 # ret is a list
699- for i in range (len (ret )):
700- ret [i ] = ret [i ].decode ('utf-8' )
700+ for i in range (len (ret )): ret [i ] = ret [i ].decode ('utf-8' )
701701
702702 return ret
703703
0 commit comments