Coverage for birdplan/bird_config/sections/protocols/base_protocol_functions.py: 100%
23 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
1#
2# SPDX-License-Identifier: GPL-3.0-or-later
3#
4# Copyright (c) 2019-2024, AllWorldIT
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
19"""BIRD protocol specific functions base class."""
21import textwrap
22from collections import OrderedDict
23from typing import Dict
25from ....bird_config.globals import BirdConfigGlobals
26from ..base import SectionBase
27from ..functions import SectionFunctions
29__all__ = ["ProtocolFunctionsBase"]
32class ProtocolFunctionsBase(SectionBase): # pylint: disable=too-many-public-methods
33 """BIRD protocol specific functions base class."""
35 _functions: SectionFunctions
37 bird_functions: Dict[str, str]
39 def __init__(self, birdconfig_globals: BirdConfigGlobals, functions: SectionFunctions):
40 """Initialize the object."""
41 super().__init__(birdconfig_globals)
43 self._functions = functions
44 self.bird_functions = OrderedDict()
46 def configure(self) -> None:
47 """Configure global constants."""
48 super().configure()
50 # Check if we're adding functions
51 for _, content in self.bird_functions.items():
52 self.conf.add(textwrap.dedent(content))
53 self.conf.add("")
55 @property
56 def functions(self) -> SectionFunctions:
57 """Return the functions section."""
58 return self._functions