Browse Source

Fix the easier code smells

Alois Mahdal 7 years ago
parent
commit
619a6824e0
1 changed files with 8 additions and 9 deletions
  1. 8
    9
      sznqalibs/hoover.py

+ 8
- 9
sznqalibs/hoover.py View File

77
                 aclass.check_values(argset)
77
                 aclass.check_values(argset)
78
             except NotImplementedError:         # let them bail out
78
             except NotImplementedError:         # let them bail out
79
                 counter.count_for(aclass, 'bailouts')
79
                 counter.count_for(aclass, 'bailouts')
80
-                pass
81
             else:
80
             else:
82
                 data[aclass], duration, overhead = get_data_and_stats(
81
                 data[aclass], duration, overhead = get_data_and_stats(
83
                     aclass, argset, driver_settings)
82
                     aclass, argset, driver_settings)
156
 # ## The Pattern                                                           ## #
155
 # ## The Pattern                                                           ## #
157
 # ########################################################################### #
156
 # ########################################################################### #
158
 
157
 
159
-class _BaseRuleOp():
158
+class _BaseRuleOp(object):
160
 
159
 
161
     def __init__(self, items, item_ok):
160
     def __init__(self, items, item_ok):
162
         self._items = items
161
         self._items = items
175
             raise ValueError("items must be an iterable: %r" % self._items)
174
             raise ValueError("items must be an iterable: %r" % self._items)
176
 
175
 
177
 
176
 
178
-class RuleOp():
177
+class RuleOp(object):
179
 
178
 
180
     class ALL(_BaseRuleOp):
179
     class ALL(_BaseRuleOp):
181
 
180
 
218
 # ## The Path                                                              ## #
217
 # ## The Path                                                              ## #
219
 # ########################################################################### #
218
 # ########################################################################### #
220
 
219
 
221
-class DictPath():
220
+class DictPath(object):
222
     """Mixin that adds "path-like" behavior to the top dict of dicts.
221
     """Mixin that adds "path-like" behavior to the top dict of dicts.
223
 
222
 
224
     Use this class as a mixin for a deep dic-like structure and you can access
223
     Use this class as a mixin for a deep dic-like structure and you can access
245
 
244
 
246
     DIV = "/"
245
     DIV = "/"
247
 
246
 
248
-    class Path():
247
+    class Path(object):
249
 
248
 
250
         def __init__(self, path, div):
249
         def __init__(self, path, div):
251
             self.DIV = div
250
             self.DIV = div
476
     def hack(self, ruleset):
475
     def hack(self, ruleset):
477
         """Apply action from each rule, if patterns match."""
476
         """Apply action from each rule, if patterns match."""
478
 
477
 
479
-        def driver_matches():
478
+        def driver_matches(rule):
480
             if 'drivers' not in rule:
479
             if 'drivers' not in rule:
481
                 return True
480
                 return True
482
             else:
481
             else:
483
                 return any(dataMatch(p, self)
482
                 return any(dataMatch(p, self)
484
                            for p in rule['drivers'])
483
                            for p in rule['drivers'])
485
 
484
 
486
-        def argset_matches():
485
+        def argset_matches(rule):
487
             if 'argsets' not in rule:
486
             if 'argsets' not in rule:
488
                 return True
487
                 return True
489
             else:
488
             else:
493
         matched = False
492
         matched = False
494
         cls = self.__class__
493
         cls = self.__class__
495
         for rule in ruleset:
494
         for rule in ruleset:
496
-            if driver_matches() and argset_matches():
495
+            if driver_matches(rule) and argset_matches(rule):
497
                 matched = True
496
                 matched = True
498
                 for action_name in cls.known_actions:
497
                 for action_name in cls.known_actions:
499
                     if action_name in rule:
498
                     if action_name in rule:
999
 
998
 
1000
         def get_all_colnames():
999
         def get_all_colnames():
1001
             cn = {}
1000
             cn = {}
1002
-            for errstr, affected in self._db.iteritems():
1001
+            for affected in self._db.itervalues():
1003
                 for argset in affected:
1002
                 for argset in affected:
1004
                     cn.update(dict.fromkeys(argset.keys()))
1003
                     cn.update(dict.fromkeys(argset.keys()))
1005
                 return sorted(cn.keys())
1004
                 return sorted(cn.keys())