pipeline.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:uroboroSQL-formatter 作者: future-architect 项目源码 文件源码
def __call__(self, stream):
        """Run the pipeline

        Return a static (non generator) version of the result
        """

        # Run the stream over all the filters on the pipeline
        for filter in self:
            # Functions and callable objects (objects with '__call__' method)
            if isinstance(filter, collections.Callable):
                stream = list(filter(stream))

            # Normal filters (objects with 'process' method)
            else:
                stream = filter.process(None, stream)

        # If last filter return a generator, staticalize it inside a list
        if isinstance(stream, GeneratorType):
            return list(stream)
        return stream
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号