Genera texto en markdown a partir de los metadatos de un `field`.

    Args:
        field (dict): Diccionario con metadatos de un `field`.

    Returns:
        str: Texto que describe un `field`.
2317
def field_to_markdown(field):
    
    if "title" in field:
        field_title = "**{}**".format(field["title"])
    else:
        raise Exception("Es necesario un `title` para describir un campo.")

    field_type = " ({})".format(field["type"]) if "type" in field else ""
    field_desc = ": {}".format(
        field["description"]) if "description" in field else ""

    text_template = "{title}{type}{description}"
    text = text_template.format(title=field_title, type=field_type,
                                description=field_desc)

    return text
497084
public function handleField(Field $field)
    {
        $prefix = $this->prefix . strtoupper($field->name);

        if (!isset($field->label)) {
            $field->label = $prefix . '_LABEL';
        }

        if (preg_match('~^([A-Z_]+)$~', $field->label, $match)) {
            $prefix = $match[1];
        }

        if (preg_match('~^([A-Z_]+?)_LABEL$~', $field->label, $match)) {
            $prefix = $match[1];
        }

        if (!isset($field->description)) {
            $field->description = $prefix . '_DESC';
        }

        if (preg_match('~^([A-Z_]+?)_DESC$~', $field->description, $match)) {
            $prefix = $match[1];
        }

        if (!isset($field->hint)) {
            $field->hint = $prefix . '_HINT';
        }

        if (!isset($field->role)) {
            if (isset($this->special[$field->name])) {
                $field->role = $this->special[$field->name];
            }
        }

        if (isset($field->role)) {
            $this->fieldAliases[$field->role] = $field->name;
        }

        $this->reflector->addField($field);
    }
71786
def _MergeField(self, tokenizer, message):
    
    message_descriptor = message.DESCRIPTOR
    if (hasattr(message_descriptor, 'syntax') and
        message_descriptor.syntax == 'proto3'):
      # Proto3 doesn't represent presence so we can't test if multiple
      # scalars have occurred.  We have to allow them.
      self._allow_multiple_scalars = True
    if tokenizer.TryConsume('['):
      name = [tokenizer.ConsumeIdentifier()]
      while tokenizer.TryConsume('.'):
        name.append(tokenizer.ConsumeIdentifier())
      name = '.'.join(name)

      if not message_descriptor.is_extendable:
        raise tokenizer.ParseErrorPreviousToken(
            'Message type "%s" does not have extensions.' %
            message_descriptor.full_name)
      # pylint: disable=protected-access
      field = message.Extensions._FindExtensionByName(name)
      # pylint: enable=protected-access
      if not field:
        if self.allow_unknown_extension:
          field = None
        else:
          raise tokenizer.ParseErrorPreviousToken(
              'Extension "%s" not registered.' % name)
      elif message_descriptor != field.containing_type:
        raise tokenizer.ParseErrorPreviousToken(
            'Extension "%s" does not extend message type "%s".' %
            (name, message_descriptor.full_name))

      tokenizer.Consume(']')

    else:
      name = tokenizer.ConsumeIdentifierOrNumber()
      if self.allow_field_number and name.isdigit():
        number = ParseInteger(name, True, True)
        field = message_descriptor.fields_by_number.get(number, None)
        if not field and message_descriptor.is_extendable:
          field = message.Extensions._FindExtensionByNumber(number)
      else:
        field = message_descriptor.fields_by_name.get(name, None)

        # Group names are expected to be capitalized as they appear in the
        # .proto file, which actually matches their type names, not their field
        # names.
        if not field:
          field = message_descriptor.fields_by_name.get(name.lower(), None)
          if field and field.type != descriptor.FieldDescriptor.TYPE_GROUP:
            field = None

        if (field and field.type == descriptor.FieldDescriptor.TYPE_GROUP and
            field.message_type.name != name):
          field = None

      if not field:
        raise tokenizer.ParseErrorPreviousToken(
            'Message type "%s" has no field named "%s".' %
            (message_descriptor.full_name, name))

    if field:
      if not self._allow_multiple_scalars and field.containing_oneof:
        # Check if there's a different field set in this oneof.
        # Note that we ignore the case if the same field was set before, and we
        # apply _allow_multiple_scalars to non-scalar fields as well.
        which_oneof = message.WhichOneof(field.containing_oneof.name)
        if which_oneof is not None and which_oneof != field.name:
          raise tokenizer.ParseErrorPreviousToken(
              'Field "%s" is specified along with field "%s", another member '
              'of oneof "%s" for message type "%s".' %
              (field.name, which_oneof, field.containing_oneof.name,
               message_descriptor.full_name))

      if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
        tokenizer.TryConsume(':')
        merger = self._MergeMessageField
      else:
        tokenizer.Consume(':')
        merger = self._MergeScalarField

      if (field.label == descriptor.FieldDescriptor.LABEL_REPEATED and
          tokenizer.TryConsume('[')):
        # Short repeated format, e.g. "foo: [1, 2, 3]"
        while True:
          merger(tokenizer, message, field)
          if tokenizer.TryConsume(']'):
            break
          tokenizer.Consume(',')

      else:
        merger(tokenizer, message, field)

    else:  # Proto field is unknown.
      assert self.allow_unknown_extension
      _SkipFieldContents(tokenizer)

    # For historical reasons, fields may optionally be separated by commas or
    # semicolons.
    if not tokenizer.TryConsume(','):
      tokenizer.TryConsume(';')
21810
def get_field(cls, model, opts, label, field):
    

    trans_model = model._meta.translation_model
    try:
        (f, lang_id) = trans_model._meta.translated_fields[field]
        return f
    except KeyError:
        # fall back to the old way -- see if model contains the field
        # directly
        pass

    try:
        return opts.get_field(field)
    except models.FieldDoesNotExist:
        raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is " \
            "missing from model '%s'." \
            % (cls.__name__, label, field, model.__name__))
1127461
def translate_doc(self, d, field_mapping=None, map_identifiers=None, **kwargs):
        
        if field_mapping is not None:
            self.map_doc(d, field_mapping)
        subject = self.translate_obj(d, M.SUBJECT)
        obj = self.translate_obj(d, M.OBJECT)

        # TODO: use a more robust method; we need equivalence as separate field in solr
        if map_identifiers is not None:
            if M.SUBJECT_CLOSURE in d:
                subject['id'] = self.map_id(subject, map_identifiers, d[M.SUBJECT_CLOSURE])
            else:
                logging.info("NO SUBJECT CLOSURE IN: "+str(d))

        if M.SUBJECT_TAXON in d:
            subject['taxon'] = self.translate_obj(d,M.SUBJECT_TAXON)
        if M.OBJECT_TAXON in d:
            obj['taxon'] = self.translate_obj(d, M.OBJECT_TAXON)

        qualifiers = []
        if M.RELATION in d and isinstance(d[M.RELATION],list):
            # GO overloads qualifiers and relation
            relation = None
            for rel in d[M.RELATION]:
                if rel.lower() == 'not':
                    qualifiers.append(rel)
                else:
                    relation = rel
            if relation is not None:
                d[M.RELATION] = relation
            else:
                d[M.RELATION] = None

        negated = 'not' in qualifiers

        assoc = {'id':d.get(M.ID),
                 'subject': subject,
                 'object': obj,
                 'negated': negated,
                 'relation': self.translate_obj(d,M.RELATION),
                 'publications': self.translate_objs(d,M.SOURCE),  # note 'source' is used in the golr schema
        }

        if self.invert_subject_object and assoc['relation'] is not None:
            assoc['relation']['inverse'] = True

        if len(qualifiers) > 0:
            assoc['qualifiers'] = qualifiers

        if M.OBJECT_CLOSURE in d:
            assoc['object_closure'] = d.get(M.OBJECT_CLOSURE)
        if M.IS_DEFINED_BY in d:
            if isinstance(d[M.IS_DEFINED_BY],list):
                assoc['provided_by'] = d[M.IS_DEFINED_BY]
            else:
                # hack for GO Golr instance
                assoc['provided_by'] = [d[M.IS_DEFINED_BY]]
        if M.EVIDENCE_OBJECT in d:
            assoc['evidence'] = d[M.EVIDENCE_OBJECT]
            assoc['types'] = [t for t in d[M.EVIDENCE_OBJECT] if t.startswith('ECO:')]

        if self._use_amigo_schema(self.object_category):
            for f in M.AMIGO_SPECIFIC_FIELDS:
                if f in d:
                    assoc[f] = d[f]

        # solr does not allow nested objects, so evidence graph is json-encoded
        if M.EVIDENCE_GRAPH in d:
            assoc[M.EVIDENCE_GRAPH] = json.loads(d[M.EVIDENCE_GRAPH])
        return assoc
850122
def parse_field(lexer: Lexer) -> FieldNode:
    """"""
    start = lexer.token
    name_or_alias = parse_name(lexer)
    if expect_optional_token(lexer, TokenKind.COLON):
        alias: Optional[NameNode] = name_or_alias
        name = parse_name(lexer)
    else:
        alias = None
        name = name_or_alias
    return FieldNode(
        alias=alias,
        name=name,
        arguments=parse_arguments(lexer, False),
        directives=parse_directives(lexer, False),
        selection_set=parse_selection_set(lexer)
        if peek(lexer, TokenKind.BRACE_L)
        else None,
        loc=loc(lexer, start),
    )
509192
def text(name, options = {})
      field name, CharField.new(options.merge(widget: Widgets::Textarea.new))
    end
979578
def parse_field(setting, field_name, default):
    
    if isinstance(setting, dict):
        return setting.get(field_name, default)
    else:
        return setting
656238
def gen_fields(field: Field) -> Generator[Field, None, None]:
    
    yield field
    for c in field.children:
        for f in gen_fields(c):
            yield f
377775
def get_document_field_display(self, field_name, field):
        
        document = getattr(self.instance, field_name)
        if document:
            return mark_safe(
                '<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % (
                    document.url,
                    document.title,
                    document.file_extension.upper(),
                    filesizeformat(document.file.size),
                )
            )
        return self.model_admin.get_empty_value_display()
456940
def build(self, field: Field) -> Mapping[str, Any]:
        
        return dict(self.iter_parsed_values(field))
206429
def get_metadata_display(self, field_formats = {}, escape=True):
        
        def field_format(field):
            if field in field_formats:
                return field_formats[field]
            return u'%s'
        t = join_formatted('', self.title, format=field_format('title'), escape=escape)
        t = join_formatted(t, self.description, u'%s: %s', escape=escape)
        if self.publish_author:
            t = join_formatted(t, self.author, u'%s' + u' – ' + u'Author: %s', u'%s' + u'Author: %s', escape=escape)
        if self.publish_copyright:
            t = join_formatted(t, self.copyright, u'%s, %s', escape=escape)
        if self.publish_date_time and self.date_time:
            date_time_formatted = dateformat.format(self.date_time, get_format('DATE_FORMAT'))
            t = join_formatted(t, date_time_formatted, u'%s (%s)', '%s%s', escape=escape)
        return t
748848
protected function markup(array $field)
    {
        $attributes = $field['attributes'];
        $attributes = $this->addAttribute($attributes, 'id', $field['id']);
        $attributes = $this->addAttribute($attributes, 'name', $field['name']);
        $output = '';
        $output .= $this->getWrapper('markup', $attributes);
        $output .= $field['value'];
        $output .= $this->getWrapperEnd('markup');
        return $output;
    }
953290
def get_field_description(f):
    """"""
    type_name = get_field_type(f)
    if type_name == 'MESSAGE' and \
            {sf.name for sf in f.message_type.fields} == {'key', 'value'}:
        return 'map<string, string>'
    elif type_name == 'MESSAGE':
        return f.message_type.full_name
    elif type_name == 'ENUM':
        return f.enum_type.full_name
    else:
        return type_name.lower()
602596
public function localizeField($field) {
        $re = "/(?:[-])(".$this->multilingual_parameters['default_language'].")(?:[-])/";
        $language = "-".$this->languageDetection()."-";
        $field = preg_replace($re, $language,$field);
        return $field;
    }
1257601
def render_field(field, **kwargs):
    
    renderer_cls = get_field_renderer(**kwargs)
    return renderer_cls(field, **kwargs).render()
1254891
def get_fields(model, fields, meta=None):
    
    model = get_model(model)
    if fields is not None:
        f = fields
    elif meta and hasattr(model, meta):
        m = getattr(model, meta)
        if hasattr(m, 'fields'):
            f = m.fields
        else:
            f = model._fields_list
    else:
        f = model._fields_list
        
    fields_list = []
    for x in f:
        field = {}
        if isinstance(x, str):  #so x is field_name
            field['name'] = x
        elif isinstance(x, tuple):
            field['name'] = x[0]
            field['field'] = x[1]
        elif isinstance(x, dict):
            field = x.copy()
        else:
            raise UliwebError('Field definition {!r} is not right, it should be just like (field_name, form_field_obj)'.format(x))
        
        if 'prop' not in field:
            if hasattr(model, field['name']):
                field['prop'] = getattr(model, field['name'])
            else:
                field['prop'] = None
        
        fields_list.append((field['name'], field))
    return fields_list