Code Duplication    Length = 10-10 lines in 2 locations

glances/stats.py 2 locations

@@ 59-68 (lines=10) @@
56
                return getattr(plugin, 'get_json_views')
57
            # The method get_views is not found for the plugin
58
            raise AttributeError(item)
59
        if item.startswith('get'):
60
            # Get the plugin name
61
            plugname = item[len('get') :].lower()
62
            # Get the plugin instance
63
            plugin = self._plugins[plugname]
64
            if hasattr(plugin, 'get_json'):
65
                # The method get_json exist, return it
66
                return getattr(plugin, 'get_json')
67
            # The method get_stats is not found for the plugin
68
            raise AttributeError(item)
69
        # Default behavior
70
        raise AttributeError(item)
71
@@ 49-58 (lines=10) @@
46
        - getViewsPlugname(): return views of the Plugname stat in JSON format
47
        """
48
        # Check if the attribute starts with 'get'
49
        if item.startswith('getViews'):
50
            # Get the plugin name
51
            plugname = item[len('getViews') :].lower()
52
            # Get the plugin instance
53
            plugin = self._plugins[plugname]
54
            if hasattr(plugin, 'get_json_views'):
55
                # The method get_json_views exist, return it
56
                return getattr(plugin, 'get_json_views')
57
            # The method get_views is not found for the plugin
58
            raise AttributeError(item)
59
        if item.startswith('get'):
60
            # Get the plugin name
61
            plugname = item[len('get') :].lower()