mirror of
https://gitee.com/openharmony/third_party_icu
synced 2024-11-23 08:10:07 +00:00
编译脚本代码规范
Signed-off-by: 王剑 <wangjian546@huawei.com>
This commit is contained in:
parent
9e630e5eb9
commit
aa1a98db0c
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -13,16 +15,17 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import stat
|
||||||
|
|
||||||
|
|
||||||
def add_content(data, src_content, prefix=''):
|
def add_content(data, src_content, prefix=''):
|
||||||
if len(prefix) == 0:
|
if len(prefix) == 0:
|
||||||
for content in src_content:
|
for content in src_content:
|
||||||
data = data + ' ' + content + '\n'
|
data = data + ' ' + content + '\n'
|
||||||
else:
|
else:
|
||||||
data = data + ' ' + prefix + '{' + '\n'
|
data = data + ' ' + prefix + '{' + '\n'
|
||||||
for content in src_content:
|
for content in src_content:
|
||||||
data = data + ' ' + content + '\n'
|
data = data + ' ' + content + '\n'
|
||||||
data = data + ' }' + '\n'
|
data = data + ' }' + '\n'
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -39,9 +42,7 @@ def copy_content(src_file, dest_file, out_file):
|
|||||||
|
|
||||||
data = ''
|
data = ''
|
||||||
signal = 0
|
signal = 0
|
||||||
for index in range(len(dest_content)):
|
for index, line in enumerate(dest_content):
|
||||||
line = dest_content[index]
|
|
||||||
|
|
||||||
if (index == len(dest_content) - 1) and (signal != 3):
|
if (index == len(dest_content) - 1) and (signal != 3):
|
||||||
if signal == 0:
|
if signal == 0:
|
||||||
data = add_content(data, src_content, 'units')
|
data = add_content(data, src_content, 'units')
|
||||||
@ -77,7 +78,9 @@ def copy_content(src_file, dest_file, out_file):
|
|||||||
else:
|
else:
|
||||||
data += line
|
data += line
|
||||||
|
|
||||||
with open(out_file, 'w', encoding='utf-8') as f:
|
flags = os.O_WRONLY | os.O_CREAT
|
||||||
|
mode = stat.S_IWUSR | stat.S_IRUSR
|
||||||
|
with os.fdopen(os.open(out_file, flags, mode), 'w') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
@ -85,24 +88,28 @@ def copy_file(src_file, dest_file):
|
|||||||
with open(src_file, 'r', encoding='utf-8') as f:
|
with open(src_file, 'r', encoding='utf-8') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|
||||||
with open(dest_file, 'w', encoding='utf-8') as f:
|
flags = os.O_WRONLY | os.O_CREAT
|
||||||
|
mode = stat.S_IWUSR | stat.S_IRUSR
|
||||||
|
with os.fdopen(os.open(dest_file, flags, mode), 'w') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--icu_src_dir', type=str)
|
parser.add_argument('--icu_src_dir', type=str)
|
||||||
parser.add_argument('--ohos_src_dir', type=str)
|
parser.add_argument('--ohos_src_dir', type=str)
|
||||||
parser.add_argument('--out_dir', type=str)
|
parser.add_argument('--out_dir', type=str)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
out_dir = args.out_dir + '/out/temp/'
|
unit_path = 'unit'
|
||||||
unit_path = '/unit/'
|
filter_file = 'data_filter.json'
|
||||||
filter_file = '/data_filter.json'
|
out_dir = os.path.join(args.out_dir, 'out', 'temp')
|
||||||
os.makedirs(out_dir + unit_path, exist_ok=True)
|
os.makedirs(os.path.join(out_dir, unit_path), exist_ok=True)
|
||||||
|
|
||||||
for file in os.listdir(args.ohos_src_dir + unit_path):
|
if os.path.exists(os.path.join(args.ohos_src_dir, unit_path)):
|
||||||
copy_content(args.ohos_src_dir + unit_path + file,
|
for file in os.listdir(os.path.join(args.ohos_src_dir, unit_path)):
|
||||||
args.icu_src_dir + unit_path + file, out_dir + unit_path + file)
|
copy_content(os.path.join(args.ohos_src_dir, unit_path, file),
|
||||||
|
os.path.join(args.icu_src_dir, unit_path, file),
|
||||||
|
os.path.join(out_dir, unit_path, file))
|
||||||
|
|
||||||
copy_file(args.ohos_src_dir + filter_file, out_dir + filter_file)
|
copy_file(os.path.join(args.ohos_src_dir, filter_file), os.path.join(out_dir, filter_file))
|
||||||
|
Loading…
Reference in New Issue
Block a user