Skip to content

Instantly share code, notes, and snippets.

@bjoernhaeuser
Created September 28, 2014 07:59
Show Gist options
  • Save bjoernhaeuser/5b38a72d03a5db2e40ba to your computer and use it in GitHub Desktop.
Save bjoernhaeuser/5b38a72d03a5db2e40ba to your computer and use it in GitHub Desktop.
"""
Filters event based on schema and table
"""
from ConfigParser import NoOptionError, NoSectionError
class EventFilter(object):
"""
Filters event based on schema and table
"""
def __init__(self, config):
self.config = config
def filter(self, obj):
"""
:param obj: object to filter, should contain values for schema and table
:return: True if the object is on whitelist
"""
if not hasattr(obj, 'schema'):
return True
try:
self.config.get(obj.schema, obj.table)
return True
except (NoOptionError, NoSectionError):
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment