def write_wgetrc(_path):
    """
    Write a valid gentoo wgetrc file to :path:.

    Args:
        path - The output path of the wgetrc
    """
    http_proxy = str(CFG["gentoo"]["http_proxy"])
    ftp_proxy = str(CFG["gentoo"]["ftp_proxy"])

    path.mkfile_uchroot("/etc/wgetrc")
    with open(_path, 'w') as wgetrc:
        if http_proxy is not None:
            http_s = "http_proxy = {0}".format(http_proxy)
            https_s = "https_proxy = {0}".format(http_proxy)
            wgetrc.write("use_proxy = on\n")
            wgetrc.write(http_s + "\n")
            wgetrc.write(https_s + "\n")

        if ftp_proxy is not None:
            fp_s = "ftp_proxy={0}".format(ftp_proxy)
            wgetrc.write(fp_s + "\n")