Browse Source

[2222] used find() instead of `in` operator

 - used find() instead of `in` operator for exact pattern matching of string
 - a style fix in the list
Naoki Kambe 12 years ago
parent
commit
a258bfbbb5
2 changed files with 8 additions and 6 deletions
  1. 2 1
      src/bin/xfrout/tests/xfrout_test.py.in
  2. 6 5
      src/bin/xfrout/xfrout.py.in

+ 2 - 1
src/bin/xfrout/tests/xfrout_test.py.in

@@ -321,7 +321,8 @@ class TestXfroutSessionBase(unittest.TestCase):
             'dec_axfr_running': _dec_axfr_running
             }
         self.get_counter = lambda n: \
-            self._statistics_data[n] if 'ixfr_' in n or 'axfr_' in n \
+            self._statistics_data[n] \
+            if n.find('ixfr_') == 0 or n.find('axfr_') == 0 \
             else self._statistics_data['zones'][TEST_ZONE_NAME_STR][n]
 
     def tearDown(self):

+ 6 - 5
src/bin/xfrout/xfrout.py.in

@@ -173,7 +173,8 @@ class XfroutSession():
         # incrementing or decrementing Xfr running. An argument
         # is required for zone name in counting Xfr requests.
         for (k, v) in counters.items():
-            if 'counter_' in k or 'inc_' in k or 'dec_' in k:
+            if k.find('counter_') == 0 or k.find('inc_') == 0 \
+                    or k.find('dec_') == 0:
                 setattr(self, "_%s" % k, v)
         self._handle()
 
@@ -975,10 +976,10 @@ class XfroutCounter:
         self._statistics_data = {}
         self._counters_for_xfroutsession = {}
         self._counters_for_notifyout = {}
-        self._xfrrunning_names = [ \
-            n for n in \
-                isc.config.spec_name_list(self._statistics_spec) \
-                if 'xfr_running' in n ]
+        self._xfrrunning_names = [
+            n for n in isc.config.spec_name_list\
+                (self._statistics_spec) \
+                if n.find('xfr_running') == 1 ]
         self._lock = threading.RLock()
         self._create_perzone_incrementers()
         self._create_xfrrunning_xxcrementers()