Skip to content

Commit

Permalink
added simpler filter syntax
Browse files Browse the repository at this point in the history
for instance instead of
"filter": ["ISO", "=", "FRA"]
you can now use
"filter": { "ISO": "FRA" }
  • Loading branch information
gka committed Jul 28, 2012
1 parent c04ef85 commit a75c97f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kartograph/filter.py
Expand Up @@ -16,6 +16,10 @@ def filter_record(filt, record):
res = False res = False
for sfilt in filt['or']: for sfilt in filt['or']:
res = res or filter_record(sfilt, record) res = res or filter_record(sfilt, record)
else:
res = True
for key in filt:
res = res and filter_record([key, '=', filt[key]], record)
elif isinstance(filt, list): elif isinstance(filt, list):
res = filter_single(filt, record) res = filter_single(filt, record)
return res return res
Expand Down

0 comments on commit a75c97f

Please sign in to comment.