Parcourir la source

[2225_statistics] add helpful comments to the complicated expression

Also rsplit() is used instead of split() to be simplified.

It's due to the review comment.
Naoki Kambe il y a 12 ans
Parent
commit
f098bc21fd
1 fichiers modifiés avec 13 ajouts et 5 suppressions
  1. 13 5
      src/lib/python/isc/statistics/counter.py

+ 13 - 5
src/lib/python/isc/statistics/counter.py

@@ -344,11 +344,19 @@ class Counters():
                 self._statistics._data,
                 self._statistics._spec,
                 identifier)
-            # delete the started timer
-            del isc.cc.data.find(
-                self._start_time,
-                _concat(*identifier.split('/')[0:-1]))\
-                [identifier.split('/')[-1]]
+            # A datetime value of once used timer should be deleted
+            # for a future use.
+            # Here, names of branch and leaf are obtained from a
+            # string of identifier. The branch name is equivalent to
+            # the position of datetime to be deleted and the leaf name
+            # is equivalent to the value of datetime to be deleted.
+            (branch, leaf) = identifier.rsplit('/', 1)
+            # Then map of branch is obtained from self._start_time by
+            # using isc.cc.data.find().
+            branch_map = isc.cc.data.find(self._start_time, branch)
+            # Finally a value of the leaf name is deleted from the
+            # map.
+            del branch_map[leaf]
 
     def dump_statistics(self):
         """Calculates an entire server counts, and returns statistics