def _latest_pkg_version(env, brew_cmd, pkg, devel=False):
    i = 0
    version, is_linked = None, False
    with settings(warn_only=True):
        info_str = env.safe_run_output("{brew_cmd} info {pkg}".format(**locals()))
    for i, git_line in enumerate(info_str.split("\n")):
        if git_line.strip():
            if i == 0:
                _, version_str = git_line.split(":")
                versions = version_str.split(",")
                if devel:
                    dev_strs = [x for x in versions if x.strip().startswith("devel")]
                    version = dev_strs[0].split()[-1].strip()
                else:
                    version = versions[0].replace("(bottled)", "").split()[-1].strip()
            elif git_line.find("Cellar/%s" % pkg) > 0 and git_line.find(" files,") > 0:
                is_linked = git_line.strip().split()[-1] == "*"
    return version, is_linked
Retrieve the latest available version of a package and if it is linked.
dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/package/brew.py/_latest_pkg_version