kiwi.iso_tools

 1# Copyright (c) 2015 SUSE Linux GmbH.  All rights reserved.
 2#
 3# This file is part of kiwi.
 4#
 5# kiwi is free software: you can redistribute it and/or modify
 6# it under the terms of the GNU General Public License as published by
 7# the Free Software Foundation, either version 3 of the License, or
 8# (at your option) any later version.
 9#
10# kiwi is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with kiwi.  If not, see <http://www.gnu.org/licenses/>
17#
18import importlib
19from typing import Any
20from abc import (
21    ABCMeta,
22    abstractmethod
23)
24
25# project
26from kiwi.exceptions import KiwiIsoToolError
27from kiwi.runtime_config import RuntimeConfig
28
29
30class IsoTools(metaclass=ABCMeta):
31    """
32    **IsoTools factory**
33    """
34    @abstractmethod
35    def __init__(self) -> None:
36        return None  # pragma: no cover
37
38    @staticmethod
39    def new(source_dir: str) -> Any:
40        name_map = {
41            'xorriso': 'XorrIso'
42        }
43        runtime_config = RuntimeConfig()
44        tool = runtime_config.get_iso_tool_category()
45        try:
46            iso_tool = importlib.import_module(
47                'kiwi.iso_tools.{}'.format(tool)
48            )
49            module_name = 'IsoTools{}'.format(name_map[tool])
50            return iso_tool.__dict__[module_name](source_dir)
51        except Exception:
52            raise KiwiIsoToolError(
53                'No support for {} tool available'.format(tool)
54            )
class IsoTools:
31class IsoTools(metaclass=ABCMeta):
32    """
33    **IsoTools factory**
34    """
35    @abstractmethod
36    def __init__(self) -> None:
37        return None  # pragma: no cover
38
39    @staticmethod
40    def new(source_dir: str) -> Any:
41        name_map = {
42            'xorriso': 'XorrIso'
43        }
44        runtime_config = RuntimeConfig()
45        tool = runtime_config.get_iso_tool_category()
46        try:
47            iso_tool = importlib.import_module(
48                'kiwi.iso_tools.{}'.format(tool)
49            )
50            module_name = 'IsoTools{}'.format(name_map[tool])
51            return iso_tool.__dict__[module_name](source_dir)
52        except Exception:
53            raise KiwiIsoToolError(
54                'No support for {} tool available'.format(tool)
55            )

IsoTools factory

@staticmethod
def new(source_dir: str) -> Any:
39    @staticmethod
40    def new(source_dir: str) -> Any:
41        name_map = {
42            'xorriso': 'XorrIso'
43        }
44        runtime_config = RuntimeConfig()
45        tool = runtime_config.get_iso_tool_category()
46        try:
47            iso_tool = importlib.import_module(
48                'kiwi.iso_tools.{}'.format(tool)
49            )
50            module_name = 'IsoTools{}'.format(name_map[tool])
51            return iso_tool.__dict__[module_name](source_dir)
52        except Exception:
53            raise KiwiIsoToolError(
54                'No support for {} tool available'.format(tool)
55            )