1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4# 5# Copyright (c) 2023 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19from abc import abstractmethod 20from modules.interface.module_interface import ModuleInterface 21from resolver.interface.args_resolver_interface import ArgsResolverInterface 22from containers.arg import ModuleType 23from containers.arg import Arg 24 25 26class ToolModuleInterface(ModuleInterface): 27 28 def __init__(self, args_dict: dict, args_resolver: ArgsResolverInterface): 29 super().__init__(args_dict, args_resolver) 30 31 @abstractmethod 32 def list_targets(self): 33 pass 34 35 @abstractmethod 36 def desc_targets(self): 37 pass 38 39 @abstractmethod 40 def path_targets(self): 41 pass 42 43 @abstractmethod 44 def refs_targets(self): 45 pass 46 47 @abstractmethod 48 def format_targets(self): 49 pass 50 51 @abstractmethod 52 def clean_targets(self): 53 pass 54 55 def run(self): 56 if self.args_dict['ls'].arg_value: 57 self.list_targets() 58 elif self.args_dict['desc'].arg_value: 59 self.desc_targets() 60 elif self.args_dict['path'].arg_value: 61 self.path_targets() 62 elif self.args_dict['refs'].arg_value: 63 self.refs_targets() 64 elif self.args_dict['format'].arg_value: 65 self.format_targets() 66 elif self.args_dict['clean'].arg_value: 67 self.clean_targets() 68 else: 69 Arg.get_help(ModuleType.TOOL) 70