@@ -188,33 +188,31 @@ def reset_stats_history(self):
188
188
def update_stats_history (self ):
189
189
"""Update stats history."""
190
190
# Build the history
191
- if self .get_export () and self .history_enable ():
192
- # If the plugin data is a dict, the dict's key should be used
193
- if self .get_key () is None :
194
- item_name = ''
191
+ if not (self .get_export () and self .history_enable ()):
192
+ return
193
+ # Itern through items history
194
+ item_name = '' if self .get_key () is None else self .get_key ()
195
+ for i in self .get_items_history_list ():
196
+ if isinstance (self .get_export (), list ):
197
+ # Stats is a list of data
198
+ # Iter through stats (for example, iter through network interface)
199
+ for l_export in self .get_export ():
200
+ if i ['name' ] in l_export :
201
+ self .stats_history .add (
202
+ nativestr (l_export [item_name ]) + '_' + nativestr (i ['name' ]),
203
+ l_export [i ['name' ]],
204
+ description = i ['description' ],
205
+ history_max_size = self ._limits ['history_size' ],
206
+ )
195
207
else :
196
- item_name = self .get_key ()
197
- for i in self .get_items_history_list ():
198
- if isinstance (self .get_export (), list ):
199
- # Stats is a list of data
200
- # Iter through it (for example, iter through network interface)
201
- for l_export in self .get_export ():
202
- if i ['name' ] in l_export :
203
- self .stats_history .add (
204
- nativestr (l_export [item_name ]) + '_' + nativestr (i ['name' ]),
205
- l_export [i ['name' ]],
206
- description = i ['description' ],
207
- history_max_size = self ._limits ['history_size' ],
208
- )
209
- else :
210
- # Stats is not a list
211
- # Add the item to the history directly
212
- self .stats_history .add (
213
- nativestr (i ['name' ]),
214
- self .get_export ()[i ['name' ]],
215
- description = i ['description' ],
216
- history_max_size = self ._limits ['history_size' ],
217
- )
208
+ # Stats is not a list
209
+ # Add the item to the history directly
210
+ self .stats_history .add (
211
+ nativestr (i ['name' ]),
212
+ self .get_export ()[i ['name' ]],
213
+ description = i ['description' ],
214
+ history_max_size = self ._limits ['history_size' ],
215
+ )
218
216
219
217
def get_items_history_list (self ):
220
218
"""Return the items history list."""
0 commit comments