def parse_one_rule_from_dict(rule):
 rule.pop('description', None)
 trigger = rule.pop('trigger', None)
 case_sensitive = rule.pop('caseSensitive', True)
 if (case_sensitive == 'false'):
  case_sensitive = False
 elif (case_sensitive == 'true'):
  case_sensitive = True
 try:
  search = rule.pop('search')
 except KeyError:
  raise ValueError('Redaction rule is missing `search` field')
 try:
  replace = rule.pop('replace')
 except KeyError:
  raise ValueError('Redaction rule is missing `replace` field')
 if rule:
  raise ValueError(('Redaction rule contains unknown field(s): %s' % rule.keys()))
 return RedactionRule(trigger, search, replace, case_sensitive)

def parse_one_rule_from_dict ( rule ) : rule . pop ( 'description' , None ) trigger = rule . pop ( 'trigger' , None ) case_sensitive = rule . pop ( 'caseSensitive' , True ) if ( case_sensitive == 'false' ) : case_sensitive = False elif ( case_sensitive == 'true' ) : case_sensitive = True try : search = rule . pop ( 'search' ) except KeyError : raise ValueError ( 'Redaction rule is missing `search` field' ) try : replace = rule . pop ( 'replace' ) except KeyError : raise ValueError ( 'Redaction rule is missing `replace` field' ) if rule : raise ValueError ( ( 'Redaction rule contains unknown field(s): %s' % rule . keys ( ) ) ) return RedactionRule ( trigger , search , replace , case_sensitive )
parse_one_rule_from_dict parses a redactionrule from a dictionary like: "description": "this is the first rule" .