1#!/usr/bin/env python 2# coding=utf-8 3############################################## 4# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16############################################## 17 18import argparse 19import shutil 20import os 21from bin import config 22from utils import constants 23 24 25def main_function(): 26 parser = argparse.ArgumentParser( 27 prog=config.Config.name, description=config.Config.description) 28 for command in config.Config.commands: 29 arg_abbr = command.get("abbr") 30 arg_name = command.get("name") 31 arg_choices = command.get("choices") 32 arg_required = (True if command.get("required") else False) 33 arg_type = command.get("type") 34 default = command.get("default") 35 arg_help = command.get("help") 36 parser.add_argument(arg_abbr, arg_name, choices=arg_choices, 37 required=arg_required, type=arg_type, default=default, help=arg_help) 38 39 config.run_tools(parser.parse_args()) 40 41 42if __name__ == '__main__': 43 main_function() 44 if os.path.exists(constants.StringConstant.SYSROOT.value): 45 shutil.rmtree(constants.StringConstant.SYSROOT.value) 46