whatstyle.py 文件源码

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

项目:whatstyle 作者: mikr 项目源码 文件源码
def variants_for(self, option):
        # type: (Option) -> List[Style]

        def kvpairs(vs):
            # type: (Iterable[OptionValue]) -> List[Style]
            return stylevariants(stylename, vs)

        def numreplace(configs, numvalues):
            # type: (List[OptionValue], Iterable[int]) -> List[OptionValue]
            extconfigs = []  # type: List[OptionValue]
            for c in configs:
                if isinstance(c, text_type) and '#' in c:
                    for n in numvalues:
                        num = str(n)
                        nc = c.replace('#', num)
                        extconfigs.append(nc)
                else:
                    extconfigs.append(c)
            return extconfigs

        stylename = option_name(option)
        configs = option_configs(option)

        if stylename == self.columnlimitname:
            candidates = self.column_limit_candidates
            candidates = [c for c in candidates if 50 <= c <= 200]
            return kvpairs(candidates)
        if stylename == 'indent':
            return kvpairs(numreplace(configs, [2, 4, 8]))
        if stylename == 'min-conditional-indent':
            return kvpairs(numreplace(configs, [0, 1, 2, 3]))
        if stylename == 'max-instatement-indent':
            return kvpairs(numreplace(configs, inclusiverange(40, 120)))
        if stylename == 'mode':
            return []
        if configs:
            return kvpairs(numreplace(configs, [1, 2, 4, 8]))
        return []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号