import yaml


def makeYaml(input_file, dbDir, prodid, outDir, nproc, fitter, covmb=0, display=0):
    """
    Function to replace generic parameters of a yaml file

    Parameters
    --------------
    input_file: str
       input yaml file to modify
    dbDir: str
       database directory location
    prodid: str
       production id
    outDir: str
      output directory - where to put the results
    nproc: int
      number of procs for multiprocessing
    covmb: int, opt
      bool to estimate mb covariance data (default: 0)
    display: int, opt
      bool to display LC fit in real-time (default:0)

    Returns
    -----------
    dict with modified parameters

    """
    with open(input_file, 'r') as file:
        filedata = file.read()

    filedata = filedata.replace('prodidmain', '{}_{}'.format(prodid, fitter))
    filedata = filedata.replace('prodidsimu', prodid)
    filedata = filedata.replace('outDir', outDir)
    filedata = filedata.replace('dbDir', dbDir)
    filedata = filedata.replace('nnproc', str(nproc))
    filedata = filedata.replace('fittername', fitter)
    filedata = filedata.replace('covmbcalc', str(covmb))
    filedata = filedata.replace('displayval', str(display))

    return yaml.load(filedata, Loader=yaml.FullLoader)