def _prepare_cfg_export_curve(obj):
    """ Prepares curve object for libconfig-type export.

    :param obj: curve object
    :return: curve data as a string
    """
    line = ""

    # Start exporting object
    line += "\ttype = \"curve\";\n"
    line += "\tdegree = " + str(obj.degree) + ";\n"
    line += "\tknotvector = [" + ", ".join(str(kv) for kv in obj.knotvector) + "];\n"
    line += "\tcontrol_points = ("
    ctrlpts_size = len(obj.ctrlpts)
    for idx, pt in enumerate(obj.ctrlpts):
        line += " (" + ", ".join(str(p) for p in pt) + ")"
        line += " " if idx == ctrlpts_size - 1 else ","
    line += ");\n"
    try:
        line += "\tweights = [" + ", ".join(str(w) for w in obj.weights) + "];\n"
    except AttributeError:
        line += "\tweights = 0;\n"

    # Export misc info
    line += "\tmisc: \n\t{\n"
    line += "\t\tname = \"" + obj.name + "\";\n"
    line += "\t\tsample_size = " + str(obj.sample_size) + ";\n"
    line += "\t};\n"

    return line