Пример #1
0
     file_index = 0
     result_count = 0
     while file_index < file_count:
         sys.stdout.write(str(int((file_index / file_count) * 100)) + "%\r")
         sys.stdout.flush()
         file = file_list[file_index]
         try:
             before_size += os.path.getsize(file)
             with open(file, encoding=get_encoding(file, None)) as f:
                 d = json.dumps(json.load(f))
             with open(file, 'w', encoding="utf-8") as f:
                 f.write(d)
             after_size += os.path.getsize(file)
             result_count += 1
         except IOError as e:
             Console.warning("处理:" + file + "发生IO错误", e)
         finally:
             file_index += 1
 elif _type == '.mcfunction':
     get_file_as_type(input_path, file_list, _type)
     file_count = len(file_list)
     file_index = 0
     _index = 0
     result_count = 0
     while file_index < file_count:
         sys.stdout.write(str(int((file_index / file_count) * 100)) + "%\r")
         sys.stdout.flush()
         b_size = 0
         file = file_list[file_index]
         try:
             b_size = os.path.getsize(file)