def create_custom_field(connection, cf_type, cf_name, auto_attached, value_names=None, bundle_policy="0"):
    if (value_names is None) and (not auto_attached or "[" not in cf_type):
        _create_custom_field_prototype(connection, cf_type, cf_name, auto_attached)
        return
    if value_names is None:
        value_names = set([])
    else:
        value_names = set(value_names)
    field = _get_custom_field(connection, cf_name)
    bundle = None
    if field is not None:
        if hasattr(field, "defaultBundle"):
            bundle = connection.getBundle(field.type, field.defaultBundle)
        elif field.autoAttached:
            return 
        else:
            bundle = create_bundle_safe(connection, cf_name + "_bundle", cf_type)
    else:
        bundle = create_bundle_safe(connection, cf_name + "_bundle", cf_type)
        _create_custom_field_prototype(connection, cf_type, cf_name, auto_attached,
                {"defaultBundle": bundle.name,
                 "attachBundlePolicy": bundle_policy})
    for value_name in value_names:
        try:
            connection.addValueToBundle(bundle, value_name)
        except YouTrackException:
            pass
#
#    values_to_add = calculate_missing_value_names(bundle, value_names)
#    [connection.addValueToBundle(bundle, name) for name in values_to_add]


#    if field is None:
#        bundle_name = cf_name + "_bundle"
#        _create_bundle_safe(connection, bundle_name, cf_type)
#        bundle = connection.getBundle(cf_type, bundle_name)
#        values_to_add = calculate_missing_value_names(bundle, value_names)
#
#
#        for value in values_to_add:
#            connection.addValueToBundle(bundle, value)
#
#
Creates custom field prototype(if not exist) and sets default values bundle if needed
dataset/ETHPy150Open gini/youtrack-githook/youtrack/importHelper.py/create_custom_field