From 0dacf703a59875d418605bda2ec6277cccc382df Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 5 Mar 2021 09:01:14 +0800 Subject: [PATCH] update --- tools/{tools => }/as.sh | 0 tools/{tools => }/clang-analyze.py | 0 tools/{tools => }/formatting.py | 12 +++++++----- 3 files changed, 7 insertions(+), 5 deletions(-) rename tools/{tools => }/as.sh (100%) rename tools/{tools => }/clang-analyze.py (100%) rename tools/{tools => }/formatting.py (89%) diff --git a/tools/tools/as.sh b/tools/as.sh similarity index 100% rename from tools/tools/as.sh rename to tools/as.sh diff --git a/tools/tools/clang-analyze.py b/tools/clang-analyze.py similarity index 100% rename from tools/tools/clang-analyze.py rename to tools/clang-analyze.py diff --git a/tools/tools/formatting.py b/tools/formatting.py similarity index 89% rename from tools/tools/formatting.py rename to tools/formatting.py index 25d7a593d5..0b63e031fa 100644 --- a/tools/tools/formatting.py +++ b/tools/formatting.py @@ -39,7 +39,7 @@ import chardet #这里并不是简单的将TAB替换成4个空格 #空格个数到底是多少需要计算,因为TAB制表本身有自动对齐的功能 def tab2spaces(line): - list_str = list(line) #字符串变成列表 + list_str = list(line) #字符串打散成列表,放边操作 i = list_str.count('\t') while i > 0: @@ -78,13 +78,15 @@ def format_codes(filename): def get_encode_info(file): with open(file, 'rb') as f: - code = chardet.detect(f.read())['encoding'] - if code == 'EUC-JP': #chardet库容易将含着少量中文的英文字符文档识别为日语编码格式 - code = 'GB2312' + code = chardet.detect(f.read())['encoding'] + #charde库有一定几率对当前文件的编码识别不准确 + if code == 'EUC-JP': #容易将含着少量中文的英文字符文档识别为日语编码格式 + code = 'GB2312' elif code == 'ISO-8859-1': #部分文件GB2312码会被识别成ISO-8859-1 code = 'GB2312' - if not (code == 'ascii' or code == 'utf-8' or code == 'GB2312' or code == 'Windows-1252'): # Windows-1252 是由于意法半导体是法国企业's的'是法语的'导致的 + if not (code == 'ascii' or code == 'utf-8' or code == 'GB2312' #编码识别正确 + or code == 'Windows-1252'): # Windows-1252 是由于意法半导体是法国企业's的'是法语的'导致的 if code != None: print('未处理,需人工确认:'+code+':'+file) #需要人工确认 code = None