HearthPacks.py 文件源码

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

项目:HearthPacks 作者: Arzaroth 项目源码 文件源码
def parse_args():
    opts = docopt(__doc__, version='.'.join(VERSION))
    schema = Schema({
        Optional('PACK_TYPE'):
        Or(None, lambda s: s.lower() in PACKS_TYPE,
           error="PACK_TYPE should be either %s" % (', '.join(PACKS_TYPE))),
        Optional('--config'):
        Or(None, Use(open),
           error="--config must be a readable file"),
        Optional('--attempts'):
        And(Use(int), lambda n: n > 0,
            error='--attempts must be a strictly positive integer'),
        Optional('--score'):
        And(Use(int),
            error='--score must be an integer'),
        Optional('--threshold'):
        And(Use(int), lambda n: n >= 0,
            error='--threshold must be a positive integer'),
        Optional('--low-threshold'):
        And(Use(int), lambda n: n > 0,
            error='--low-threshold must be a strictly positive integer'),
        Optional('--wait'):
        And(Use(int), lambda n: n >= 0,
            error='--wait must be a positive integer'),
        object: object,
    })
    opts = schema.validate(opts)
    opts['PACK_TYPE'] = opts['PACK_TYPE'].lower() if opts['PACK_TYPE'] else "wild"
    if opts['--config']:
        config = simplejson.loads(opts['--config'].read())
        opts.update(config)
    return opts
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号