Skip to content

Commit

Permalink
Clean up with collections.defaultdict
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Jun 26, 2018
1 parent ad865bb commit 09c685c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import colorama
import tldextract

from collections import defaultdict

# Use: ./validate.py old.json new.json
KEYS = ['action_map', 'snitch_map', 'version']
old_path = sys.argv[1]
Expand Down Expand Up @@ -53,26 +55,20 @@

BLOCKED = ("block", "cookieblock")

blocked_old = {}
blocked_old = defaultdict(list)
for domain in old_js['action_map'].keys():
if old_js['action_map'][domain]['heuristicAction'] not in BLOCKED:
continue

base = extract(domain).registered_domain

if base not in blocked_old:
blocked_old[base] = []
blocked_old[base].append(domain)

blocked_new = {}
blocked_new = defaultdict(list)
for domain in new_js['action_map'].keys():
if new_js['action_map'][domain]['heuristicAction'] not in BLOCKED:
continue

base = extract(domain).registered_domain

if base not in blocked_new:
blocked_new[base] = []
blocked_new[base].append(domain)

blocked_bases_old = set(blocked_old.keys())
Expand Down

0 comments on commit 09c685c

Please sign in to comment.