Example #1
0
File: drop.py Project: Roger/y
    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)
Example #2
0
File: keep.py Project: Roger/y
    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)
Example #3
0
 def fun(self, data):
     key = self.options.get("value", "value")
     return get_key(data, key, None)
Example #4
0
File: sort-by.py Project: Roger/y
    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)
Example #5
0
    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)
Example #6
0
File: get.py Project: Roger/y
 def fun(self, data):
     key = self.options.get("value", "value")
     return get_key(data, key, None)