def make_key_filter(include):
 if (not include):
  return identity
 matchers = []
 for key in include:
  key = re.escape(key)
  key = key.replace('\\*', '.*')
  matchers.append(re.compile((key + '$')))
 def filter_(data):
  filtered = dict()
  for (key, value) in data.items():
   if any([m.match(key) for m in matchers]):
    filtered[key] = value
  return filtered
 return filter_

def make_key_filter ( include ) : if ( not include ) : return identity matchers = [ ] for key in include : key = re . escape ( key ) key = key . replace ( '\\*' , '.*' ) matchers . append ( re . compile ( ( key + '$' ) ) ) def filter_ ( data ) : filtered = dict ( ) for ( key , value ) in data . items ( ) : if any ( [ m . match ( key ) for m in matchers ] ) : filtered [ key ] = value return filtered return filter_
return a function that filters a dictionary .