delta.microseconds * 1E-6, 6)
_set_counter(element, spec, identifier, sec)
+def _concat(*args, sep='/'):
+ """Concatenates words in args with a separator('/')
+ """
+ return sep.join(args)
+
class _Statistics():
"""Statistics data set"""
# default statistics data
caller. isc.cc.data.DataNotFoundError is raised when
incrementing the counter of the item undefined in the spec
file."""
- identifier = '/'.join(args)
+ identifier = _concat(*args)
step = 1
with self._rlock:
if self._disabled: return
caller. isc.cc.data.DataNotFoundError is raised when
decrementing the counter of the item undefined in the spec
file."""
- identifier = '/'.join(args)
+ identifier = _concat(*args)
step = -1
with self._rlock:
if self._disabled: return
"""A getter method for counters. It returns the current number
of the specified counter. isc.cc.data.DataNotFoundError is
raised when the counter doesn't have a number yet."""
- identifier = '/'.join(args)
+ identifier = _concat(*args)
return _get_counter(self._statistics._data, identifier)
def start(self, *args):
"""Sets the value returned from _start_timer() as a value of
the identifier in the self._start_time which is dict-type"""
- identifier = '/'.join(args)
+ identifier = _concat(*args)
with self._rlock:
if self._disabled: return
isc.cc.data.set(self._start_time, identifier, _start_timer())
timer which has never been started, it raises and does
nothing. But in case of stopping the time which isn't defined
in the spec file, it raises DataNotFoundError"""
- identifier = '/'.join(args)
+ identifier = _concat(*args)
with self._rlock:
if self._disabled: return
try:
# delete the started timer
del isc.cc.data.find(
self._start_time,
- '/'.join(identifier.split('/')[0:-1]))\
+ _concat(*identifier.split('/')[0:-1]))\
[identifier.split('/')[-1]]
def dump_statistics(self):
counter._get_counter(self.counters._statistics._data,
timer_name), 0)
+ def test_concat(self):
+ # only strings
+ a = ( 'a','b','c','d' )
+ self.assertEqual('a/b/c/d', counter._concat(*a))
+ self.assertEqual('aTbTcTd', counter._concat(*a, sep='T'))
+ self.assertEqual('a\\b\\c\\d', counter._concat(*a, sep='\\'))
+ # mixed with other types
+ b = a + (1,)
+ self.assertRaises(TypeError, counter._concat, *b)
+ b = a + (1.1,)
+ self.assertRaises(TypeError, counter._concat, *b)
+ b = a + ([],)
+ self.assertRaises(TypeError, counter._concat, *b)
+ b = a + ({},)
+ self.assertRaises(TypeError, counter._concat, *b)
+
class BaseTestCounters():
def setUp(self):