161847f8eSopenharmony_ci#!/usr/bin/env python
261847f8eSopenharmony_ci# -*- coding: utf-8 -*-
361847f8eSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
461847f8eSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
561847f8eSopenharmony_ci# you may not use this file except in compliance with the License.
661847f8eSopenharmony_ci# You may obtain a copy of the License at
761847f8eSopenharmony_ci#
861847f8eSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
961847f8eSopenharmony_ci#
1061847f8eSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1161847f8eSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1261847f8eSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1361847f8eSopenharmony_ci# See the License for the specific language governing permissions and
1461847f8eSopenharmony_ci# limitations under the License.
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ciimport enum
1761847f8eSopenharmony_cifrom coreImpl import detection_label
1861847f8eSopenharmony_ci
1961847f8eSopenharmony_ci
2061847f8eSopenharmony_ciclass ToolNameType(enum.Enum):
2161847f8eSopenharmony_ci    DETECTION = 'detection'
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci
2461847f8eSopenharmony_citool_name_type_set = [
2561847f8eSopenharmony_ci    member.value for name_tool,
2661847f8eSopenharmony_ci    member in ToolNameType.__members__.items()
2761847f8eSopenharmony_ci]
2861847f8eSopenharmony_ci
2961847f8eSopenharmony_ci
3061847f8eSopenharmony_ciclass FormatType(enum.Enum):
3161847f8eSopenharmony_ci    JSON = 'json'
3261847f8eSopenharmony_ci    EXCEL = 'excel'
3361847f8eSopenharmony_ci
3461847f8eSopenharmony_ci
3561847f8eSopenharmony_ciformat_set = [
3661847f8eSopenharmony_ci    member.value for name_format,
3761847f8eSopenharmony_ci    member in FormatType.__members__.items()
3861847f8eSopenharmony_ci]
3961847f8eSopenharmony_ci
4061847f8eSopenharmony_ci
4161847f8eSopenharmony_cidef run_tools(options):
4261847f8eSopenharmony_ci    tool_name = options.tool_name
4361847f8eSopenharmony_ci    if tool_name == ToolNameType["DETECTION"].value:
4461847f8eSopenharmony_ci        detection_label.detection_label(options.check_labels, options.result_json_path, options.output_path)
4561847f8eSopenharmony_ci
4661847f8eSopenharmony_ci
4761847f8eSopenharmony_ciclass Config(object):
4861847f8eSopenharmony_ci    name = 'parser'
4961847f8eSopenharmony_ci    version = '0.1.0'
5061847f8eSopenharmony_ci    description = 'Compare the parser the NDKS'
5161847f8eSopenharmony_ci    commands = [
5261847f8eSopenharmony_ci        {
5361847f8eSopenharmony_ci            "name": "--tool-name",
5461847f8eSopenharmony_ci            "abbr": "-N",
5561847f8eSopenharmony_ci            "required": True,
5661847f8eSopenharmony_ci            "choices": tool_name_type_set,
5761847f8eSopenharmony_ci            "type": str,
5861847f8eSopenharmony_ci            "default": ToolNameType["DETECTION"],
5961847f8eSopenharmony_ci            "help": "工具名称"
6061847f8eSopenharmony_ci        },
6161847f8eSopenharmony_ci        {
6261847f8eSopenharmony_ci            "name": "--check-labels",
6361847f8eSopenharmony_ci            "abbr": "-L",
6461847f8eSopenharmony_ci            "required": True,
6561847f8eSopenharmony_ci            "type": str,
6661847f8eSopenharmony_ci            "help": "需要校验的标签"
6761847f8eSopenharmony_ci        },
6861847f8eSopenharmony_ci        {
6961847f8eSopenharmony_ci            "name": "--result-json-path",
7061847f8eSopenharmony_ci            "abbr": "-P",
7161847f8eSopenharmony_ci            "required": True,
7261847f8eSopenharmony_ci            "type": str,
7361847f8eSopenharmony_ci            "help": "解析结果json文件路径"
7461847f8eSopenharmony_ci        },
7561847f8eSopenharmony_ci        {
7661847f8eSopenharmony_ci            "name": "--output-path",
7761847f8eSopenharmony_ci            "abbr": "-O",
7861847f8eSopenharmony_ci            "required": False,
7961847f8eSopenharmony_ci            "type": str,
8061847f8eSopenharmony_ci            "help": "输出路径"
8161847f8eSopenharmony_ci        }
8261847f8eSopenharmony_ci    ]
8361847f8eSopenharmony_ci
84