rougail-output-ansible/src/rougail/output_ansible/__init__.py
2026-06-21 16:53:52 +02:00

65 lines
1.9 KiB
Python

"""
Silique (https://www.silique.fr)
Copyright (C) 2022-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from .ansible import Inventory
from .__version__ import __version__
class RougailOutputAnsible:
output_name = "ansible"
def __init__(
self,
config: "Config",
*,
rougailconfig: "RougailConfig" = None,
**kwargs,
) -> None:
self.config = config
self.rougailconfig = rougailconfig
self.kwargs = kwargs
def run(self):
output = self.rougailconfig["ansible.output"]
if output == "doc":
from .doc import Doc
data = Doc(self.config, rougailconfig=self.rougailconfig, **self.kwargs)
else:
data = Inventory(
self.config, rougailconfig=self.rougailconfig, **self.kwargs
)
return data.run()
def print(self):
output = self.rougailconfig["ansible.output"]
if output == "doc":
from .doc import Doc
data = Doc(self.config, rougailconfig=self.rougailconfig, **self.kwargs)
else:
data = Inventory(
self.config, rougailconfig=self.rougailconfig, **self.kwargs
)
return data.print()
RougailOutput = RougailOutputAnsible
__all__ = ("RougailOutputAnsible", "__version__")