Source code for libka.excuses.excuses_package_info
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space modified;
# vim: expandtab ts=4
# pylint: enable=line-too-long
############################################################################
# Copyright © 2017-2020 José Manuel Santamaría Lema <panfaust@gmail.com> #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
############################################################################
"""This module just provides the ExcusesPackageInfo class"""
from libka.ka_print import ka_print_plain
from libka.ka_print import ka_print_good_stuff
from libka.ka_print import ka_print_info
from libka.ka_print import ka_print_warning
from libka.ka_print import ka_print_error
[docs]
class ExcusesPackageInfo(): # pylint: disable=too-few-public-methods,too-many-instance-attributes
"""Class to represent the 'excuses' status for a specific source package"""
__slots__ = [
"package_name",
"old_version", "new_version",
"maintainer",
"age",
"autopkgtests",
"missing_builds",
"implicit_depends",
"depends",
"reasons",
"is_candidate"
]
def __init__(self):
self.package_name = ""
self.old_version = ""
self.new_version = ""
self.maintainer = ""
self.age = ""
self.autopkgtests = {}
self.missing_builds = []
self.implicit_depends = []
self.depends = []
self.reasons = []
self.is_candidate = False
def __str__(self):
slots_values_str_list = []
for slot in self.__slots__:
slot_str = "%s='%s'" % (slot, getattr(self, slot))
slots_values_str_list.append(slot_str)
slots_values_str = ",\n\t".join(slots_values_str_list)
result = "PackageInfo(%s)" % slots_values_str
return result
[docs]
def print(self): # pylint: disable=too-many-branches
"""Print package name and versions"""
ka_print_plain("Package: %s (from %s to %s)"
% (self.package_name, self.old_version, self.new_version))
#Print maintainer
ka_print_plain(" Maintainer: %s" % self.maintainer)
#Pint age
ka_print_plain(" %s days old" % self.age)
#Print autopkgtests
for autopkgtest_pkg in sorted(self.autopkgtests.keys()):
ka_print_plain(" autopkgtest for %s: " % autopkgtest_pkg, end='')
first_arch = True
for arch in sorted(self.autopkgtests[autopkgtest_pkg].keys()):
if not first_arch:
ka_print_plain(', ', end='')
ka_print_plain(arch + ": ", end='')
autopkgtest_result = self.autopkgtests[autopkgtest_pkg][arch]
if autopkgtest_result == "PASS":
ka_print_good_stuff("Pass", end='')
elif autopkgtest_result == "REGRESSION":
ka_print_error("Regression", end='')
elif autopkgtest_result == "ALWAYSFAIL":
ka_print_warning("Always failed", end='')
elif autopkgtest_result == "IGNORE-FAIL":
ka_print_warning("Ignored failure", end='')
elif autopkgtest_result == "RUNNING":
ka_print_info("Test in progress", end='')
elif autopkgtest_result == "NEUTRAL":
pass
else:
ka_print_plain(autopkgtest_result, end='')
first_arch = False
ka_print_plain('') #end with a newline
#Print missing builds
if self.missing_builds:
ka_print_plain(" Missing builds: ", end='')
ka_print_error(" ".join(self.missing_builds))
#Print depends
if self.implicit_depends:
implicit_depends_string = ", ".join(sorted(self.implicit_depends))
ka_print_plain(" Implicit dependency: %s" % implicit_depends_string)
#Print depends
if self.depends:
depends_string = ", ".join(sorted(self.depends))
ka_print_plain(" Depends: %s" % depends_string)
#Print reasons to not migrate
if self.reasons:
ka_print_plain(" Reasons to not migrate: ", end='')
ka_print_error(" ".join(self.reasons))
#Print if it's a valid candidate
if self.is_candidate:
ka_print_good_stuff(" %s" % "Valid candidate")