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