1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright (c) 2023 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16import enum 17from coreImpl.parser import parser 18from coreImpl.check import check 19from coreImpl.diff import diff 20 21 22class ToolNameType(enum.Enum): 23 COLLECT = 'collect' 24 DIFF = 'diff' 25 CHECK = 'check' 26 27 28tool_name_type_set = [ 29 member.value for name_tool, 30 member in ToolNameType.__members__.items() 31] 32 33 34class FormatType(enum.Enum): 35 JSON = 'json' 36 EXCEL = 'excel' 37 38 39format_set = [ 40 member.value for name_format, 41 member in FormatType.__members__.items() 42] 43 44 45def run_tools(options): 46 tool_name = options.tool_name 47 if tool_name == ToolNameType["COLLECT"].value: 48 parser.parser(options.parser_path) 49 elif tool_name == ToolNameType["DIFF"].value: 50 diff.process_dir(options.diff_path_old, options.diff_path_new) 51 elif tool_name == ToolNameType['CHECK'].value: 52 check.curr_entry(options.parser_path) 53 else: 54 print("工具名称错误") 55 56 57class Config(object): 58 name = 'parser' 59 version = '0.1.0' 60 description = 'Compare the parser the NDKS' 61 commands = [ 62 { 63 "name": "--tool-name", 64 "abbr": "-N", 65 "required": True, 66 "choices": tool_name_type_set, 67 "type": str, 68 "default": ToolNameType["COLLECT"], 69 "help": "工具名称" 70 }, 71 { 72 "name": "--parser-path", 73 "abbr": "-P", 74 "required": True, 75 "type": str, 76 "help": "解析路径" 77 }, 78 { 79 "name": "--diff-path-old", 80 "abbr": "-old", 81 "required": False, 82 "type": str, 83 "help": "旧文件路径" 84 }, 85 { 86 "name": "--diff-path-new", 87 "abbr": "-new", 88 "required": False, 89 "type": str, 90 "help": "新文件路径" 91 } 92 93 ] 94