1 Star 0 Fork 1.3K

zhangxiujian/communication_dsoftbus_waring

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
config.py 2.42 KB
一键复制 编辑 原始数据 按行查看 历史
liubb_0516 提交于 2021-08-23 19:14 . add config file for dsoftbus
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
import sys
import subprocess
from PyInquirer import prompt
def enable_option(file_name):
option_list = []
try:
with open('.config', 'r') as config_file:
for line in config_file:
if line.startswith('CONFIG_'):
str1 = line.split('=')
option_list.append(str1[0][7:])
except IOError:
print('No config file')
return
if os.path.exists('.config'):
os.remove('.config')
file_data = ''
with open(file_name, 'r') as gni_file:
for line in gni_file:
if '=' in line:
str1 = line.split('=')
if str1[0].strip() in option_list:
line = str1[0] + '= true\n'
else:
line = str1[0] + '= false\n'
file_data += line
with open(file_name, 'w') as gni_file:
gni_file.write(file_data)
def ask_option():
options_prompt = {
'type': 'list',
'name': 'option',
'message': 'Which platform do you want to config?',
'default': 'standard',
'choices': ['standard', 'small', 'mini']
}
answers = prompt(options_prompt)
return answers['option']
def main():
print('##### Welcome to Dsoftbus #####')
option = ask_option()
subprocess.call(['menuconfig'])
file_gni = './adapter/default_config/feature_config/platform/config.gni'
if (option == 'standard'):
file_gni = file_gni.replace('platform', 'standard')
elif (option == 'small'):
file_gni = file_gni.replace('platform', 'small')
else:
file_gni = file_gni.replace('platform', 'mini')
enable_option(file_gni)
if __name__ == '__main__':
sys.exit(main())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/neacedaer/communication_dsoftbus_waring.git
git@gitee.com:neacedaer/communication_dsoftbus_waring.git
neacedaer
communication_dsoftbus_waring
communication_dsoftbus_waring
master

搜索帮助