cli.py 文件源码

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

项目:rivalcfg 作者: flozz 项目源码 文件源码
def _check_colorshift(option, opt_str, values, parser):
    """OptionParser callback to check if the given colors are valid.
    Also transfroms a little bit the args to make it works:
    [color1, color2, speed] -> [[color1, color2], speed]
    """
    colors = values[:-1]
    speed = values[-1]
    for color in colors:
        if not helpers.is_color(color):
            raise OptionValueError("option %s: invalid color: '%s'" % (opt_str, color))  # noqa
    if not speed.isdigit():
        raise OptionValueError("option %s: invalid speed: '%s'" % (opt_str, speed))  # noqa
    setattr(parser.values, option.dest, [colors, int(speed)])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号