# Copyright (c) 2025 Kim Jarvis TPF Software Services S.A. kim.jarvis@tpfsystems.com # This software is licensed under the MIT License. See the LICENSE file for details.#fromtypingimportListfromreemote.commandimportCommand
[docs]classInfo:""" A class to manage package operations on a remote system using `apt`. Attributes: package (str): A package name to be queried. sudo (bool): If `True`, the commands will be executed with `sudo` privileges. su (bool): If `True`, the commands will be executed with `su` privileges. **Examples:** .. code:: python yield Info(package='vim') Usage: This class is designed to be used in a generator-based workflow where commands are yielded for execution. Notes: - Commands are constructed based on the `present`, `sudo`, and `su` flags. """def__init__(self,package:str,sudo:bool=False,su:bool=False):self.package:str=packageself.sudo:bool=sudoself.su:bool=sudef__repr__(self)->str:return(f"Info(package={self.package!r}, "f"sudo={self.sudo!r}, su={self.su!r})")defexecute(self):r0=yieldCommand(f"{self}",composite=True)r0.executed=True# Retrieve the package informationr1=yieldCommand(f"apt info {self.package}",sudo=self.sudo,su=self.su)