import pickle,json,collections,re A=pickle.load(open("active.pkl","rb"));act=A["active"];tc=A["tagcache"] prod=collections.defaultdict(list); cons=collections.defaultdict(set) tagsof=collections.defaultdict(set) for t,s in tc.items(): for i in s: tagsof[i].add(t) for rid,(jar,j) in act.items(): r=json.dumps(j.get("result",""))+json.dumps(j.get("results",""))+json.dumps(j.get("output","")) for m in set(re.findall(r'"(?:id|item)": "([^"]+)"',r)): prod[m].append(rid) body=json.dumps({k:v for k,v in j.items() if k not in("result","results","output")}) for m in re.findall(r'"item": "([^"]+)"|"id": "([^"]+)"',body): cons[m[0] or m[1]].add(rid) for m in re.findall(r'"tag": "([^"]+)"',body): cons["#"+m].add(rid) def info(i): c=set(cons[i]) for t in tagsof[i]: c|=cons["#"+t] return len(prod[i]),len(c),sorted(prod[i])[:6] for i in """extradelight:bread_slice moredelight:bread_slice extradelight:sliced_potato moredelight:diced_potatoes rusticdelight:potato_slices dungeonsdelight:fiery_knife twilightdelight:fiery_knife dungeonsdelight:ironwood_knife twilightdelight:ironwood_knife dungeonsdelight:knightmetal_knife twilightdelight:knightmetal_knife dungeonsdelight:steeleaf_knife twilightdelight:steeleaf_knife frightsdelight:poisonous_potato_crate dungeonsdelight:poisonous_potato_crate frightsdelight:rotten_tomato_crate dungeonsdelight:rotten_tomato_crate handcrafted:wood_plate twilightforest:oak_drying_rack comforts:sleeping_bag_red handcrafted:red_sheet adorablehamsterpets:cucumber_crate extradelight:cucumber_crate_item fruitsdelight:apple_crate extradelight:apple_crate rusticdelight:coffee_beans_bag extradelight:coffee_bean_sack extradelight:coffee_cherry_crate fishermans_haven:worm aquaculture:worm create:copper_nugget twilightforest:copper_nugget twilightdelight:rainbow_ice_cream twilightdelight:refreshing_ice_cream twilightdelight:twilight_ice_cream""".split(): print(i, *info(i))