def get_crate(version, crate_root=None):
    """Retrieve a Crate tarball, extract it and return the path.

    Args:
        version: The Crate version to get.
            Can be specified in different ways:

            - A concrete version like '0.55.0'
            - A version including a `x` as wildcards. Like: '1.1.x' or '1.x.x'.
              This will use the latest version that matches.
            - Release branch, like `3.1`
            - An alias: 'latest-stable' or 'latest-testing'
            - A URI pointing to a crate tarball
        crate_root: Where to extract the tarball to.
            If this isn't specified ``$XDG_CACHE_HOME/.cache/cr8/crates``
            will be used.
    """
    if not crate_root:
        crate_root = _crates_cache()
        _remove_old_crates(crate_root)
    if _is_project_repo(version):
        return _extract_tarball(_build_tarball(version))
    m = BRANCH_VERSION_RE.match(version)
    if m:
        return _build_from_release_branch(m.group(0), crate_root)
    uri = _lookup_uri(version)
    crate_dir = _download_and_extract(uri, crate_root)
    return crate_dir
def get_crate ( version , crate_root = None ) : if not crate_root : crate_root = _crates_cache ( ) _remove_old_crates ( crate_root ) if _is_project_repo ( version ) : return _extract_tarball ( _build_tarball ( version ) ) m = BRANCH_VERSION_RE . match ( version ) if m : return _build_from_release_branch ( m . group ( 0 ) , crate_root ) uri = _lookup_uri ( version ) crate_dir = _download_and_extract ( uri , crate_root ) return crate_dir
Retrieve a Crate tarball, extract it and return the path.

    Args:
        version: The Crate version to get.
            Can be specified in different ways:

            - A concrete version like '0.55.0'
            - A version including a `x` as wildcards. Like: '1.1.x' or '1.x.x'.
              This will use the latest version that matches.
            - Release branch, like `3.1`
            - An alias: 'latest-stable' or 'latest-testing'
            - A URI pointing to a crate tarball
        crate_root: Where to extract the tarball to.
            If this isn't specified ``$XDG_CACHE_HOME/.cache/cr8/crates``
            will be used.