mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 07:04:17 +00:00 
			
		
		
		
	utils/counters: Remove duplicated counter
The implementation of the `counter` was duplicated in both `wa.utils.counters` and `wa.utils.types.counter` the latter of which is currently unsed, therefore port missing functionality to the former and remove.
This commit is contained in:
		| @@ -1,46 +0,0 @@ | |||||||
| """ |  | ||||||
| An auto incremeting value (kind of like an AUTO INCREMENT field in SQL). |  | ||||||
| Optionally, the name of the counter to be used is specified (each counter |  | ||||||
| increments separately). |  | ||||||
|  |  | ||||||
| Counts start at 1, not 0. |  | ||||||
|  |  | ||||||
| """ |  | ||||||
| from collections import defaultdict |  | ||||||
|  |  | ||||||
| __all__ = [ |  | ||||||
|     'next', |  | ||||||
|     'reset', |  | ||||||
|     'reset_all', |  | ||||||
|     'counter', |  | ||||||
| ] |  | ||||||
|  |  | ||||||
| __counters = defaultdict(int) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def next(name=None): |  | ||||||
|     __counters[name] += 1 |  | ||||||
|     value = __counters[name] |  | ||||||
|     return value |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def reset_all(value=0): |  | ||||||
|     for k in __counters: |  | ||||||
|         reset(k, value) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def reset(name=None, value=0): |  | ||||||
|     __counters[name] = value |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class counter(object): |  | ||||||
|  |  | ||||||
|     def __init__(self, name): |  | ||||||
|         self.name = name |  | ||||||
|  |  | ||||||
|     def next(self): |  | ||||||
|         return next(self.name) |  | ||||||
|  |  | ||||||
|     def reset(self, value=0): |  | ||||||
|         return reset(self.name, value) |  | ||||||
|  |  | ||||||
| @@ -200,9 +200,12 @@ def regex(value): | |||||||
| __counters = defaultdict(int) | __counters = defaultdict(int) | ||||||
|  |  | ||||||
|  |  | ||||||
| def reset_counter(name=None): | def reset_counter(name=None, value=0): | ||||||
|     __counters[name] = 0 |     __counters[name] = value | ||||||
|  |  | ||||||
|  | def reset_all_counters(value=0): | ||||||
|  |     for k in __counters: | ||||||
|  |         reset_counter(k, value) | ||||||
|  |  | ||||||
| def counter(name=None): | def counter(name=None): | ||||||
|     """ |     """ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user