@@ -71,7 +71,8 @@ def remove_config_prefix(string):
7171
7272 for rep_path in repl_paths :
7373 print ('=======================> {}' .format (rep_path ))
74- with open (rep_path ) as f_rep :
74+ # TuyaOpen: encoding='utf-8'
75+ with open (rep_path , encoding = 'utf-8' ) as f_rep :
7576 for line_number , line in enumerate (f_rep , start = 1 ):
7677 sp_line = line .split ()
7778 if len (sp_line ) == 0 or sp_line [0 ].startswith ('#' ):
@@ -98,7 +99,8 @@ def get_new_option(self, deprecated_option):
9899
99100 def replace (self , sdkconfig_in , sdkconfig_out ):
100101 replace_enabled = True
101- with open (sdkconfig_in , 'r' ) as f_in , open (sdkconfig_out , 'w' ) as f_out :
102+ # TuyaOpen: encoding='utf-8'
103+ with open (sdkconfig_in , 'r' , encoding = 'utf-8' ) as f_in , open (sdkconfig_out , 'w' , encoding = 'utf-8' ) as f_out :
102104 for line_num , line in enumerate (f_in , start = 1 ):
103105 if self ._RE_DEP_OP_BEGIN .search (line ):
104106 replace_enabled = False
@@ -128,7 +130,8 @@ def option_was_written(opt):
128130 return any (visibility .visible (node ) for node in config .syms [opt ].nodes )
129131
130132 if len (self .r_dic ) > 0 :
131- with open (path_output , 'a' ) as f_o :
133+ # TuyaOpen: encoding='utf-8'
134+ with open (path_output , 'a' , encoding = 'utf-8' ) as f_o :
132135 header = 'Deprecated options and their replacements'
133136 f_o .write ('.. _configuration-deprecated-options:\n \n {}\n {}\n \n ' .format (header , '-' * len (header )))
134137 for dep_opt in sorted (self .r_dic ):
@@ -165,7 +168,8 @@ def append_config_node_process(node):
165168 append_config_node_process (n )
166169
167170 if len (tmp_list ) > 0 :
168- with open (path_output , 'a' ) as f_o :
171+ # TuyaOpen: encoding='utf-8'
172+ with open (path_output , 'a' , encoding = 'utf-8' ) as f_o :
169173 f_o .write ('\n {}\n ' .format (self ._DEP_OP_BEGIN ))
170174 f_o .writelines (tmp_list )
171175 f_o .write ('{}\n ' .format (self ._DEP_OP_END ))
@@ -177,7 +181,8 @@ def _opt_defined(opt):
177181 return not (opt .orig_type in (kconfiglib .BOOL , kconfiglib .TRISTATE ) and opt .str_value == "n" )
178182
179183 if len (self .r_dic ) > 0 :
180- with open (path_output , 'a' ) as f_o :
184+ # TuyaOpen: encoding='utf-8'
185+ with open (path_output , 'a' , encoding = 'utf-8' ) as f_o :
181186 f_o .write ('\n /* List of deprecated options */\n ' )
182187 for dep_opt in sorted (self .r_dic ):
183188 new_opt = self .r_dic [dep_opt ]
@@ -235,7 +240,8 @@ def main():
235240 parser .add_argument ('--env' , action = 'append' , default = [],
236241 help = 'Environment to set when evaluating the config file' , metavar = 'NAME=VAL' )
237242
238- parser .add_argument ('--env-file' , type = argparse .FileType ('r' ),
243+ # TuyaOpen: encoding='utf-8'
244+ parser .add_argument ('--env-file' , type = argparse .FileType ('r' , encoding = 'utf-8' ),
239245 help = 'Optional file to load environment variables from. Contents '
240246 'should be a JSON object where each key/value pair is a variable.' )
241247
@@ -269,7 +275,8 @@ def main():
269275
270276 if len (args .defaults ) > 0 :
271277 def _replace_empty_assignments (path_in , path_out ):
272- with open (path_in , 'r' ) as f_in , open (path_out , 'w' ) as f_out :
278+ # TuyaOpen: encoding='utf-8'
279+ with open (path_in , 'r' , encoding = 'utf-8' ) as f_in , open (path_out , 'w' , encoding = 'utf-8' ) as f_out :
273280 for line_num , line in enumerate (f_in , start = 1 ):
274281 line = line .strip ()
275282 if line .endswith ('=' ):
@@ -350,7 +357,8 @@ def write_makefile(deprecated_options, config, filename):
350357# Beken IoT Development Framework (BEKEN-ARMINO) Project Makefile Configuration
351358#
352359"""
353- with open (filename , "w" ) as f :
360+ # TuyaOpen: encoding='utf-8'
361+ with open (filename , "w" , encoding = 'utf-8' ) as f :
354362 tmp_dep_lines = []
355363 f .write (CONFIG_HEADING )
356364
@@ -406,7 +414,8 @@ def write_header(deprecated_options, config, filename):
406414
407415
408416def write_cmake (deprecated_options , config , filename ):
409- with open (filename , "w" ) as f :
417+ # TuyaOpen: encoding='utf-8'
418+ with open (filename , "w" , encoding = 'utf-8' ) as f :
410419 tmp_dep_list = []
411420 write = f .write
412421 prefix = config .config_prefix
@@ -473,7 +482,8 @@ def write_node(node):
473482
474483def write_json (deprecated_options , config , filename ):
475484 config_dict = get_json_values (config )
476- with open (filename , "w" ) as f :
485+ # TuyaOpen: encoding='utf-8'
486+ with open (filename , "w" , encoding = 'utf-8' ) as f :
477487 json .dump (config_dict , f , indent = 4 , sort_keys = True )
478488
479489
@@ -590,7 +600,8 @@ def write_node(node):
590600
591601 for n in config .node_iter ():
592602 write_node (n )
593- with open (filename , "w" ) as f :
603+ # TuyaOpen: encoding='utf-8'
604+ with open (filename , "w" , encoding = 'utf-8' ) as f :
594605 f .write (json .dumps (result , sort_keys = True , indent = 4 ))
595606
596607
@@ -607,16 +618,19 @@ def write_docs(deprecated_options, config, filename):
607618
608619
609620def update_if_changed (source , destination ):
610- with open (source , "r" ) as f :
621+ # TuyaOpen: encoding='utf-8'
622+ with open (source , "r" , encoding = 'utf-8' ) as f :
611623 source_contents = f .read ()
612624
613625 if os .path .exists (destination ):
614- with open (destination , "r" ) as f :
626+ # TuyaOpen: encoding='utf-8'
627+ with open (destination , "r" , encoding = 'utf-8' ) as f :
615628 dest_contents = f .read ()
616629 if source_contents == dest_contents :
617630 return # nothing to update
618631
619- with open (destination , "w" ) as f :
632+ # TuyaOpen: encoding='utf-8'
633+ with open (destination , "w" , encoding = 'utf-8' ) as f :
620634 f .write (source_contents )
621635
622636
0 commit comments