docopt.py 文件源码

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

项目:alfred-mpd 作者: deanishe 项目源码 文件源码
def parse(class_, option_description):
        short, long, argcount, value = None, None, 0, False
        options, _, description = option_description.strip().partition('  ')
        options = options.replace(',', ' ').replace('=', ' ')
        for s in options.split():
            if s.startswith('--'):
                long = s
            elif s.startswith('-'):
                short = s
            else:
                argcount = 1
        if argcount:
            matched = re.findall('\[default: (.*)\]', description, flags=re.I)
            value = matched[0] if matched else None
        return class_(short, long, argcount, value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号