summaryrefslogtreecommitdiff
path: root/tools/file_check.py
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2021-04-09 10:53:17 +0800
committerguozhanxin <[email protected]>2021-04-09 11:08:25 +0800
commitdbebcd72648aee9259022158bbc4356cc54a8321 (patch)
tree08da7f0918ca96af8368feae2a671ebbd0786a49 /tools/file_check.py
parent31cb379daeaeda2b1d4dba7670a90ea59e115ac8 (diff)
[update] file_check.py, Improve compatibility.
Diffstat (limited to 'tools/file_check.py')
-rw-r--r--tools/file_check.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/file_check.py b/tools/file_check.py
index d4095f55e4..3e7ac6fc1c 100644
--- a/tools/file_check.py
+++ b/tools/file_check.py
@@ -80,9 +80,9 @@ class CheckOut:
def get_new_file(self):
file_list = list()
try:
- os.system('git remote add rtt_repo {} 1>/dev/null'.format(self.rtt_repo))
- os.system('git fetch rtt_repo 1>/dev/null')
- os.system('git reset rtt_repo/{} --soft 1>/dev/null'.format(self.rtt_branch))
+ os.system('git remote add rtt_repo {}'.format(self.rtt_repo))
+ os.system('git fetch rtt_repo')
+ os.system('git reset rtt_repo/{} --soft'.format(self.rtt_branch))
os.system('git status > git.txt')
except Exception as e:
logging.error(e)
@@ -119,7 +119,7 @@ class FormatCheck:
def __check_file(self, file_lines, file_path):
line_num = 1
- check_result = False
+ check_result = True
for line in file_lines:
# check line start
line_start = line.replace(' ', '')
@@ -140,7 +140,7 @@ class FormatCheck:
logging.info("Start to check files format.")
if len(self.file_list) == 0:
logging.warning("There are no files to check license.")
- return 0
+ return True
encoding_check_result = True
format_check_result = True
for file_path in self.file_list:
@@ -156,13 +156,13 @@ class FormatCheck:
else:
continue
- if code != 'utf-8':
+ if code != 'utf-8' and code != 'ascii':
logging.error("[{0}]: encoding not utf-8, please format it.".format(file_path))
encoding_check_result = False
else:
logging.info('[{0}]: encoding check success.'.format(file_path))
- with open(file_path, 'r') as f:
+ with open(file_path, 'r', encoding = "utf-8") as f:
file_lines = f.readlines()
format_check_result = self.__check_file(file_lines, file_path)