コード例 #1
0
    def expand(self):
        resolved = self.container.expand()

        filtered = []
        for r in resolved:
            ctx = Context(self.filter_expression.clone(), {"@": r})
            r.set_parent(ctx)
            ctx.set_parent(self.parent)
            if ctx.resolve():
                filtered.append(r)

        return Sequence(filtered)
コード例 #2
0
ファイル: filter.py プロジェクト: marchon/yay
    def expand(self):
        resolved = self.container.expand()

        filtered = []
        for r in resolved:
            ctx = Context(self.filter_expression.clone(), {"@": r})
            r.set_parent(ctx)
            ctx.set_parent(self.parent)
            if ctx.resolve():
                filtered.append(r)

        return Sequence(filtered)
コード例 #3
0
ファイル: foreach.py プロジェクト: marchon/yay
    def expand(self):
        lst = []

        for item in self.lookup.expand():
            c = Context(self.value.clone(), {self.alias: item})
            c.set_parent(self)

            if self.filter:
                f = self.filter.clone()
                f.set_parent(c)
                if not f.resolve():
                    continue

            item.set_parent(c)

            if self.mode == "nochain":
                lst.append(c)
            else:
                c.set_parent(self)
                val = c.resolve()
                if isinstance(val, list):
                    if self.mode == "flatten":
                        lst.extend(BoxingFactory.box(v) for v in flatten(val))
                    else:
                        lst.extend(BoxingFactory.box(v) for v in val)
                else:
                    lst.append(BoxingFactory.box(val))

        sq = Sequence(lst)
        sq.set_parent(self.parent)
        return sq