version.py 文件源码

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

项目:courseraoauth2client 作者: coursera 项目源码 文件源码
def command_version(args):
    # See http://stackoverflow.com/questions/17583443
    from pkg_resources import get_distribution, DistributionNotFound
    import os.path

    try:
        _dist = get_distribution('courseraoauth2client')
        # Normalize case for Windows systems
        dist_loc = os.path.normcase(_dist.location)
        here = os.path.normcase(__file__)
        if not here.startswith(os.path.join(dist_loc, 'courseraoauth2client')):
            # not installed, but there is another version that *is*
            raise DistributionNotFound
    except DistributionNotFound:
        __version__ = 'Please install this project with setup.py'
    else:
        __version__ = _dist.version

    if args.quiet and args.quiet > 0:
        print __version__
    else:
        print "Your %(prog)s's version is:\n\t%(version)s" % {
            "prog": sys.argv[0],
            "version": __version__
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号