cli.py 文件源码

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

项目:elm-doc 作者: ento 项目源码 文件源码
def validate_elm_make(ctx, param, value):
    if value is None:
        return value

    realpath = os.path.realpath(value)
    if not os.path.isfile(realpath):
        realpath = shutil.which(value)

    if realpath is None or not os.path.isfile(realpath):
        raise click.BadParameter('{} not found'.format(value))

    elm_make_mimetype = magic.from_file(realpath, mime=True)
    if not elm_make_mimetype.startswith('text'):
        return value

    perhaps_binwrap_of = os.path.normpath(
        os.path.join(
            os.path.dirname(realpath),
            os.pardir,
            'elm',
            'Elm-Platform',
            '*',
            '.cabal-sandbox',
            'bin',
            'elm-make'))
    raise click.BadParameter('''should be the real elm-make binary; this looks like a text file.
if you installed Elm through npm, then try {}'''.format(perhaps_binwrap_of))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号