Code Duplication    Length = 21-22 lines in 2 locations

glances/plugins/glances_diskio.py 1 location

@@ 33-53 (lines=21) @@
30
    stats is a list
31
    """
32
33
    def __init__(self, args=None, config=None):
34
        """Init the plugin."""
35
        super(Plugin, self).__init__(
36
            args=args, config=config, items_history_list=items_history_list, stats_init_value=[]
37
        )
38
39
        # We want to display the stat in the curse interface
40
        self.display_curse = True
41
42
        # Hide stats if it has never been != 0
43
        if config is not None:
44
            self.hide_zero = config.get_bool_value(self.plugin_name, 'hide_zero', default=False)
45
        else:
46
            self.hide_zero = False
47
        self.hide_zero_fields = ['read_bytes', 'write_bytes']
48
49
        # Force a first update because we need two update to have the first stat
50
        self.update()
51
        self.refresh_timer.set(0)
52
53
    def get_key(self):
54
        """Return the key of the list."""
55
        return 'disk_name'
56

glances/plugins/glances_network.py 1 location

@@ 78-99 (lines=22) @@
75
    stats is a list
76
    """
77
78
    def __init__(self, args=None, config=None):
79
        """Init the plugin."""
80
        super(Plugin, self).__init__(
81
            args=args,
82
            config=config,
83
            items_history_list=items_history_list,
84
            fields_description=fields_description,
85
            stats_init_value=[],
86
        )
87
88
        # We want to display the stat in the curse interface
89
        self.display_curse = True
90
91
        # Hide stats if it has never been != 0
92
        if config is not None:
93
            self.hide_zero = config.get_bool_value(self.plugin_name, 'hide_zero', default=False)
94
        else:
95
            self.hide_zero = False
96
        self.hide_zero_fields = ['rx', 'tx']
97
98
        # Force a first update because we need two update to have the first stat
99
        self.update()
100
        self.refresh_timer.set(0)
101
102
    def get_key(self):