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 modules.interface.tool_module_interface import ToolModuleInterface 20from resolver.interface.args_resolver_interface import ArgsResolverInterface 21from services.interface.build_file_generator_interface import BuildFileGeneratorInterface 22from exceptions.ohos_exception import OHOSException 23 24 25class OHOSToolModule(ToolModuleInterface): 26 27 _instance = None 28 29 def __init__(self, args_dict: dict, args_resolver: ArgsResolverInterface, gn: BuildFileGeneratorInterface): 30 super().__init__(args_dict, args_resolver) 31 self._gn = gn 32 OHOSToolModule._instance = self 33 34 @staticmethod 35 def get_instance(): 36 if OHOSToolModule._instance is not None: 37 return OHOSToolModule._instance 38 else: 39 raise OHOSException( 40 'OHOSToolModule has not been instantiated', '0000') 41 42 @property 43 def gn(self): 44 return self._gn 45 46 def list_targets(self): 47 self.args_resolver.resolve_arg(self.args_dict['ls'], self) 48 49 def desc_targets(self): 50 self.args_resolver.resolve_arg(self.args_dict['desc'], self) 51 52 def path_targets(self): 53 self.args_resolver.resolve_arg(self.args_dict['path'], self) 54 55 def refs_targets(self): 56 self.args_resolver.resolve_arg(self.args_dict['refs'], self) 57 58 def format_targets(self): 59 self.args_resolver.resolve_arg(self.args_dict['format'], self) 60 61 def clean_targets(self): 62 self.args_resolver.resolve_arg(self.args_dict['clean'], self) 63