<commit_before># :coding: utf-8
# :copyright: Copyright (c) 2013 <NAME>
# :license: See LICENSE.txt.

from PySide import QtGui, QtCore


class Widget(QtGui.QFrame):
    '''Base widget.

    Subclass to create widgets that reflect specific schema fragments.

    '''

    # Emit when value changes.
    value_changed = QtCore.Signal()

    def __init__(self, title=None, description=None, required=False,
                 parent=None):
        '''Initialise widget with *parent*.'''
        super(Widget, self).__init__(parent=parent)

        self.construct()
        self.post_construction()

        self.title = title
        self.description = description
        self.required = required

    def construct(self):
        '''Construct widget.'''
        self.title_label = QtGui.QLabel()
        self.required_indicator = QtGui.QLabel()
        self.error_indicator = QtGui.QLabel()

    def post_construction(self):
        '''Perform post-construction operations.'''

    @property
    def title(self):
        '''Return title value as stored in widget.'''
        return self.title_label.text()

    @title.setter
    def title(self, value):
        '''Set title to *value*.'''
        self.title_label.setText(value)

    @property
    def description(self):
        '''Return description value as stored in widget.'''
        return self.title_label.toolTip()

    @description.setter
    def description(self, value):
        '''Set description to *value*.'''
        self.title_label.setToolTip(value)

    @property
    def required(self):
        '''Return current required status.'''
        return self.required_indicator.pixmap() != None

    @required.setter
    def required(self, value):
        '''Set required status to boolean *value*.'''
        if value:
            self.required_indicator.setPixmap(QtGui.QPixmap())
            self.required_indicator.setToolTip('Required')
        else:
            self.required_indicator.setPixmap(QtGui.QPixmap())
            self.required_indicator.setToolTip('')

    @property
    def error(self):
        '''Return current error value.'''
        return self.error_indicator.toolTip()

    @error.setter
    def error(self, value):
        '''Set error to *value*.'''
        if value:
            self.error_indicator.setPixmap(QtGui.QPixmap())
            self.error_indicator.setToolTip(value)
        else:
            self.error_indicator.setPixmap(QtGui.QPixmap())
            self.error_indicator.setToolTip('')

    @property
    def value(self):
        '''Return current value.'''
        raise NotImplementedError()

    @value.setter
    def value(self, value):
        '''Set current *value*.'''
        raise NotImplementedError()
<commit_msg>Cleanup API.<commit_after># :coding: utf-8
# :copyright: Copyright (c) 2013 <NAME>
# :license: See LICENSE.txt.

from PySide import QtGui, QtCore


class Widget(QtGui.QFrame):
    '''Base widget.

    Subclass to create widgets that reflect specific schema fragments.

    '''

    # Emit when value changes.
    value_changed = QtCore.Signal()

    def __init__(self, title=None, description=None, required=False,
                 parent=None):
        '''Initialise widget with *parent*.'''
        super(Widget, self).__init__(parent=parent)

        self._construct()
        self._post_construction()

        self.title = title
        self.description = description
        self.required = required

    def _construct(self):
        '''Construct widget.'''
        self._title_label = QtGui.QLabel()
        self._required_indicator = QtGui.QLabel()
        self._error_indicator = QtGui.QLabel()

    def _post_construction(self):
        '''Perform post-construction operations.'''

    @property
    def title(self):
        '''Return title value as stored in widget.'''
        return self._title_label.text()

    @title.setter
    def title(self, value):
        '''Set title to *value*.'''
        self._title_label.setText(value)

    @property
    def description(self):
        '''Return description value as stored in widget.'''
        return self._title_label.toolTip()

    @description.setter
    def description(self, value):
        '''Set description to *value*.'''
        self._title_label.setToolTip(value)

    @property
    def required(self):
        '''Return current required status.'''
        return self._required_indicator.pixmap() != None

    @required.setter
    def required(self, value):
        '''Set required status to boolean *value*.'''
        if value:
            self._required_indicator.setPixmap(QtGui.QPixmap())
            self._required_indicator.setToolTip('Required')
        else:
            self._required_indicator.setPixmap(QtGui.QPixmap())
            self._required_indicator.setToolTip('')

    @property
    def error(self):
        '''Return current error value.'''
        return self._error_indicator.toolTip()

    @error.setter
    def error(self, value):
        '''Set error to *value*.'''
        if value:
            self._error_indicator.setPixmap(QtGui.QPixmap())
            self._error_indicator.setToolTip(value)
        else:
            self._error_indicator.setPixmap(QtGui.QPixmap())
            self._error_indicator.setToolTip('')

    @property
    def value(self):
        '''Return current value.'''
        raise NotImplementedError()

    @value.setter
    def value(self, value):
        '''Set current *value*.'''
        raise NotImplementedError()

{'fraction_non_alphanumeric': 0.11970029239766082, 'fraction_numerical': 0.001827485380116959, 'mean_word_length': 2.4971246006389776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1342794', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1526, 'n_words': 361}