def on_data(self, data): for field, value in self.options.items(): if isinstance(value, list) and len(value) == 2 and value[0] in PREDICATES: pred_name = value[0] predicate = PREDICATES[pred_name] comparison = value[1] else: pred_name = "eq" predicate = is_eq comparison = value val = get_key(data, field, None) if predicate(unwrap(val), comparison): return self.printer(data)
def on_data(self, data): for field, value in self.options.items(): if isinstance(value, list) and len(value) == 2 and value[0] in PREDICATES: pred_name = value[0] predicate = PREDICATES[pred_name] comparison = value[1] else: pred_name = "eq" predicate = is_eq comparison = value val = get_key(data, field, None) if not predicate(unwrap(val), comparison): return self.printer(data)
def fun(self, data): key = self.options.get("value", "value") return get_key(data, key, None)
def cmp(self, a, b): val_a = get_key(a, self.key, None) val_b = get_key(b, self.key, None) return cmp(val_a, val_b)