import requests


def feedstock_name(package):
    """
    Check to see if a package has a conda-forge feedstock

    Parameters
    ------------
    package : str
      Name of a package to check

    Returns
    -------------
    name : str or None
      None if it doesn't exist
    """
    # base url to check
    base = 'https://github.com/conda-forge/{}-feedstock'

    #check_yes = requests.get(base.format('triangle'))
    #check_no = requests.get(base.format('blahahshdrraaa1123'))
    #assert check_no.status_code == 404
    #assert check_yes.status_code == 200

    # make sure name is clean
    package = package.lower().strip()

    # map packages to different name if known here
    name_map = {'msgpack': 'msgpack-python'}
    if package in name_map:
        package = name_map[package]

    # check the feedstock on github
    fetch = requests.get(base.format(package))
    exists = fetch.status_code == 200

    print(f'{package} exists={exists}')

    if exists:
        return package
    return None