def failure_ignore(ignore: bool): """ Ignores failures based on parameter passed. """ try: yield except Exception as err: if ignore: log.warning(f'ignoring error {err}') else: raise
def validate_package_cli_can_be_skipped(package: Package, skip: bool): """ Checks whether package CLI installation can be skipped. Args: package: Package to validate skip: Whether to skip installing CLI Raises: PackageManagerError """ if package.manifest['cli']['mandatory'] and skip: raise PackageManagerError(f'CLI is mandatory for package {package.name} ' f'but it was requested to be not installed') elif skip: log.warning(f'Package {package.name} CLI plugin will not be installed')