• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.set_module_interface import SetModuleInterface
20from resolver.interface.args_resolver_interface import ArgsResolverInterface
21from services.interface.menu_interface import MenuInterface
22from exceptions.ohos_exception import OHOSException
23
24
25class OHOSSetModule(SetModuleInterface):
26
27    _instance = None
28
29    def __init__(self, args_dict: dict, args_resolver: ArgsResolverInterface, menu: MenuInterface):
30        super().__init__(args_dict, args_resolver)
31        self._menu = menu
32        OHOSSetModule._instance = self
33
34    @staticmethod
35    def get_instance():
36        if OHOSSetModule._instance is not None:
37            return OHOSSetModule._instance
38        else:
39            raise OHOSException(
40                'OHOSSetModule has not been instantiated', '0000')
41
42    @property
43    def menu(self):
44        return self._menu
45
46    def set_product(self):
47        self.args_resolver.resolve_arg(self.args_dict['product_name'], self)
48
49    def set_parameter(self):
50        self.args_resolver.resolve_arg(self.args_dict['all'], self)
51