'Creates the information needed by the metadata editor for a specific field.'

def _create_metadata_editor_info(self, field):

    def jsonify_value(field, json_choice):
        '\n                                                Convert    field    value    to    JSON,    if    needed.\n                                                '
        if isinstance(json_choice, dict):
            new_json_choice = dict(json_choice)
            if ('display_name' in json_choice):
                new_json_choice['display_name'] = get_text(json_choice['display_name'])
            if ('value' in json_choice):
                new_json_choice['value'] = field.to_json(json_choice['value'])
        else:
            new_json_choice = field.to_json(json_choice)
        return new_json_choice
    def get_text(value):
        'Localize    a    text    value    that    might    be    None.'
        if (value is None):
            return None
        else:
            return self.runtime.service(self, 'i18n').ugettext(value)
    metadata_field_editor_info = self.runtime.get_field_provenance(self, field)
    metadata_field_editor_info['field_name'] = field.name
    metadata_field_editor_info['display_name'] = get_text(field.display_name)
    metadata_field_editor_info['help'] = get_text(field.help)
    metadata_field_editor_info['value'] = field.read_json(self)
    editor_type = 'Generic'
    values = field.values
    if ('values_provider' in field.runtime_options):
        values = field.runtime_options['values_provider'](self)
    if (isinstance(values, (tuple, list)) and (len(values) > 0)):
        editor_type = 'Select'
        values = [jsonify_value(field, json_choice) for json_choice in values]
    elif isinstance(field, Integer):
        editor_type = 'Integer'
    elif isinstance(field, Float):
        editor_type = 'Float'
    elif isinstance(field, List):
        editor_type = 'List'
    elif isinstance(field, Dict):
        editor_type = 'Dict'
    elif isinstance(field, RelativeTime):
        editor_type = 'RelativeTime'
    elif (isinstance(field, String) and (field.name == 'license')):
        editor_type = 'License'
    metadata_field_editor_info['type'] = editor_type
    metadata_field_editor_info['options'] = ([] if (values is None) else values)
    return metadata_field_editor_info
