You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
482 B
15 lines
482 B
# -*- coding: utf-8 -*-
|
|
import json
|
|
from collections import Counter
|
|
|
|
|
|
def items_iterator(objects_list, model):
|
|
for string_item, count in Counter(objects_list).items():
|
|
item = model._collector_class(*json.loads(string_item))
|
|
yield item._replace(value=item.value * count)
|
|
|
|
|
|
def unique_items_iterator(objects_list):
|
|
for string_item, count in Counter(objects_list).items():
|
|
item = json.loads(string_item)
|
|
yield tuple(item[:-1]), item[-1] * count
|
|
|