GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#29)
by Hugo
06:14
created

add_hidden_attributes()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 6
rs 9.4286
1
import os
0 ignored issues
show
Unused Code introduced by
The import os seems to be unused.
Loading history...
2
3
from PyQt4.QtGui import QListWidget, QIcon, QSizePolicy
0 ignored issues
show
Configuration introduced by
The import PyQt4.QtGui could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
Unused Code introduced by
Unused QSizePolicy imported from PyQt4.QtGui
Loading history...
Unused Code introduced by
Unused QIcon imported from PyQt4.QtGui
Loading history...
4
5
from Orange.widgets import gui
6
from Orange.widgets.settings import ContextSetting
7
from Orange.widgets.widget import OWWidget
8
from Orange.widgets.utils import vartype
9
10
ICON_UP = gui.resource_filename("icons/Dlg_up3.png")
11
ICON_DOWN = gui.resource_filename("icons/Dlg_down3.png")
12
13
14
class OWVisWidget(OWWidget):
15
    _shown_attributes = ContextSetting(default=[], required=ContextSetting.REQUIRED,
16
                                       selected='selected_shown', reservoir="_hidden_attributes")
17
    # Setting above will override these fields
18
    _hidden_attributes = ()
19
    selected_shown = ()
20
    selected_hidden = ()
21
22
    @property
23
    def shown_attributes(self):
24
        return [a[0] for a in self._shown_attributes]
25
26
    @shown_attributes.setter
27
    def shown_attributes(self, value):
28
        shown = []
29
        hidden = []
30
31
        domain = self.get_data_domain()
32
        attr_info = lambda a: (a.name, vartype(a))
33
        if domain:
34
            if value:
35
                shown = value if isinstance(value[0], tuple) else [attr_info(domain[a]) for a in value]
36
                hidden = [x for x in [attr_info(domain[a]) for a in domain.attributes] if x not in shown]
37
            else:
38
                shown = [attr_info(a) for a in domain.attributes]
39
                if not self.show_all_attributes:
40
                    hidden = shown[10:]
41
                    shown = shown[:10]
42
43
            if domain.class_var and attr_info(domain.class_var) not in shown:
44
                hidden += [attr_info(domain.class_var)]
45
46
        self._shown_attributes = shown
47
        self._hidden_attributes = hidden
48
        self.selected_hidden = []
49
        self.selected_shown = []
50
51
        self.trigger_attributes_changed()
52
53
    @property
54
    def hidden_attributes(self):
55
        return [a[0] for a in self._hidden_attributes]
56
57
    __attribute_selection_area_initialized = False
58
59
    #noinspection PyAttributeOutsideInit
60
    def add_attribute_selection_area(self, parent):
61
        self.add_shown_attributes(parent)
62
        self.add_hidden_attributes(parent)
63
        self.__attribute_selection_area_initialized = True
64
65
        self.trigger_attributes_changed()
66
67
    #noinspection PyAttributeOutsideInit
68
    def add_shown_attributes(self, parent):
69
        self.shown_attributes_area = gui.widgetBox(parent, " Shown attributes ")
0 ignored issues
show
Coding Style introduced by
The attribute shown_attributes_area was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
70
        self.shown_attributes_listbox = gui.listBox(
0 ignored issues
show
Coding Style introduced by
The attribute shown_attributes_listbox was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
71
            self.shown_attributes_area, self, "selected_shown", "_shown_attributes",
72
            dragDropCallback=self.trigger_attributes_changed,
73
            enableDragDrop=True, selectionMode=QListWidget.ExtendedSelection)
74
75
    #noinspection PyAttributeOutsideInit
76
    def add_hidden_attributes(self, parent):
77
        self.hidden_attributes_area = gui.widgetBox(parent, " Hidden attributes ")
0 ignored issues
show
Coding Style introduced by
The attribute hidden_attributes_area was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
78
        self.hidden_attributes_listbox = gui.listBox(self.hidden_attributes_area, self, "selected_hidden",
0 ignored issues
show
Coding Style introduced by
The attribute hidden_attributes_listbox was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
79
                                                     "_hidden_attributes",
80
                                                     dragDropCallback=self.trigger_attributes_changed,
81
                                                     enableDragDrop=True, selectionMode=QListWidget.ExtendedSelection)
82
83
    def get_data_domain(self):
84
        if hasattr(self, "data") and self.data:
85
            return self.data.domain
86
        else:
87
            return None
88
89
    def trigger_attributes_changed(self):
90
        if not self.__attribute_selection_area_initialized:
91
            # Some components trigger this event during the initialization.
92
            # We ignore those requests, a separate event will be triggered
93
            # manually when everything is initialized.
94
            return
95
96
        self.attributes_changed()
97
98
    def closeContext(self):
99
        super().closeContext()
100
101
        self.data = None
0 ignored issues
show
Coding Style introduced by
The attribute data was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
102
        self.shown_attributes = None
103
104
    # "Events"
105
    def attributes_changed(self):
106
        pass
107