<commit_before>from PyQt4 import QtGui, QtCore


class BuildIcons:
    success_sleeping = 'icon-success.svg'
    success_building = 'icon-success-building.svg'
    failure_sleeping = 'icon-failure.svg'
    failure_building = 'icon-failure-building.svg'
    unavailable = 'icon-inactive.svg'
    resource_path = ":/status/icons/%s"

    def __init__(self):
        self.all_status = {'Success.Sleeping': self.success_sleeping, 'Success.CheckingModifications': self.success_sleeping, 'Success.Building': self.success_building,
                           'Failure.Sleeping': self.failure_sleeping, 'Failure.CheckingModifications': self.failure_sleeping, 'Failure.Building': self.failure_building,
                           'unavailable': self.unavailable}

    def for_status(self, status):
        return QtGui.QIcon(self.get_path(status))

    def for_aggregate_status(self, status, count):
        if count is "0":
            return self.for_status(status)
        icon = self.for_status(status)
        pixmap = icon.pixmap(22, 22)
        painter = QtGui.QPainter(pixmap)
        painter.setOpacity(1)
        painter.drawText(pixmap.rect(), QtCore.Qt.AlignCenter, count)
        painter.end()
        return QtGui.QIcon(pixmap)

    def get_path(self, status):
        if status in self.all_status:
            return self.resource_path % self.all_status[status]
        return self.resource_path % self.all_status['unavailable']<commit_msg>Fixing #17: Providing the capability to load the icons from theme files and if not found, fallback to ones packaged with the artifact.<commit_after>from PyQt4 import QtGui, QtCore


class BuildIcons:
    success_sleeping = 'icon-success'
    success_building = 'icon-success-building'
    failure_sleeping = 'icon-failure'
    failure_building = 'icon-failure-building'
    unavailable = 'icon-inactive'
    resource_path = ":/status/icons/%s.svg"
    theme_resource_path = "%s"

    def __init__(self):
        self.all_status = {'Success.Sleeping': self.success_sleeping, 'Success.CheckingModifications': self.success_sleeping, 'Success.Building': self.success_building,
                           'Failure.Sleeping': self.failure_sleeping, 'Failure.CheckingModifications': self.failure_sleeping, 'Failure.Building': self.failure_building,
                           'unavailable': self.unavailable}

    def for_status(self, status):
        return QtGui.QIcon.fromTheme(self.get_path(self.theme_resource_path, status), QtGui.QIcon(self.get_path(self.resource_path, status)))

    def for_aggregate_status(self, status, count):
        if count is "0":
            return self.for_status(status)
        icon = self.for_status(status)
        pixmap = icon.pixmap(22, 22)
        painter = QtGui.QPainter(pixmap)
        painter.setOpacity(1)
        painter.drawText(pixmap.rect(), QtCore.Qt.AlignCenter, count)
        painter.end()
        return QtGui.QIcon(pixmap)

    def get_path(self, resource_path, status):
        if status in self.all_status:
            return resource_path % self.all_status[status]
        return resource_path % self.all_status['unavailable']
{'fraction_non_alphanumeric': 0.10592, 'fraction_numerical': 0.00512, 'mean_word_length': 3.190348525469169, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4201215', 'n_tokens_mistral': 955, 'n_tokens_neox': 928, 'n_words': 183}