Create a field descriptor for these attrs.
492856
def __FieldDescriptorFromProperties(self, name, index, attrs):
        """"""
        field = descriptor.FieldDescriptor()
        field.name = self.__names.CleanName(name)
        field.number = index
        field.label = self.__ComputeLabel(attrs)
        new_type_name_hint = self.__names.ClassName(
            '%sValue' % self.__names.ClassName(name))
        type_info = self.__GetTypeInfo(attrs, new_type_name_hint)
        field.type_name = type_info.type_name
        field.variant = type_info.variant
        if 'default' in attrs:
            # TODO(craigcitro): Correctly handle non-primitive default values.
            default = attrs['default']
            if not (field.type_name == 'string' or
                    field.variant == messages.Variant.ENUM):
                default = str(json.loads(default))
            if field.variant == messages.Variant.ENUM:
                default = self.__names.NormalizeEnumName(default)
            field.default_value = default
        extended_field = extended_descriptor.ExtendedFieldDescriptor()
        extended_field.name = field.name
        extended_field.description = util.CleanDescription(
            attrs.get('description', 'A %s attribute.' % field.type_name))
        extended_field.field_descriptor = field
        return extended_field
140374
def model_field_attr(model, model_field, attr):
    
    fields = dict([(field.name, field) for field in model._meta.fields])
    return getattr(fields[model_field], attr)
958847
public void setAttrs(String[] attrs, String[] descs) {
    for (int i = 0; i < attrs.length && i < descs.length; i++) {
      descriptions.put(attrs[i], descs[i]);
    }
    this.attrs = attrs;
  }
1021035
def describe_field(field_definition):
    
    field_descriptor = FieldDescriptor()
    field_descriptor.name = field_definition.name
    field_descriptor.number = field_definition.number
    field_descriptor.variant = field_definition.variant

    if isinstance(field_definition, messages.EnumField):
        field_descriptor.type_name = field_definition.type.definition_name()

    if isinstance(field_definition, messages.MessageField):
        field_descriptor.type_name = (
            field_definition.message_type.definition_name())

    if field_definition.default is not None:
        field_descriptor.default_value = _DEFAULT_TO_STRING_MAP[
            type(field_definition)](field_definition.default)

    # Set label.
    if field_definition.repeated:
        field_descriptor.label = FieldDescriptor.Label.REPEATED
    elif field_definition.required:
        field_descriptor.label = FieldDescriptor.Label.REQUIRED
    else:
        field_descriptor.label = FieldDescriptor.Label.OPTIONAL

    return field_descriptor
483667
def _init_fields(self):
        
        fields = {}
        forms = {}
        sets = {}

        for name in dir(self):
            if name.startswith('_'):
                continue
            field = getattr(self, name)
            is_field = isinstance(field, Field)
            is_form = isinstance(field, Form) or (
                inspect.isclass(field) and issubclass(field, Form))
            is_set = isinstance(field, FormSet)

            if is_field:
                field = copy(field)
                field.name = self._prefix + name
                field.form = self
                if field.prepare is None:
                    field.prepare = getattr(self, 'prepare_' + name, None)
                if field.clean is None:
                    field.clean = getattr(self, 'clean_' + name, None)
                fields[name] = field
                setattr(self, name, field)
            elif is_form:
                forms[name] = field
            elif is_set:
                field._name = self._prefix + name  # REALLY IMPORTANT
                sets[name] = field

        self._fields = fields
        self._forms = forms
        self._sets = sets
316709
def getFields(self):
        
        d = {}
        for i in self._attrsList:
            key = i
            value = getattr(self,  i)
            d[key] = value
        return d
754371
def attrs
      atrs = {
        :object_type => "object-type-#{obj_type}", :permission_id => 'manage',
        :name => name, :field_type => 'text', :is_required => false,
        :is_primary => true
      }

      if !id.nil?
        atrs.merge!(:field_id => id)
      end

      atrs
    end
644874
def create_attributes(klass, attributes, previous_object=None):
        """"""

        if previous_object is not None:
            return {'name': attributes.get('name', previous_object.name)}
        return {
            'name': attributes.get('name', ''),
            'defaultLocale': attributes['default_locale']
        }
1265657
def _AddPropertiesForExtensions(descriptor, cls):
  """"""
  extension_dict = descriptor.extensions_by_name
  for extension_name, extension_field in extension_dict.items():
    constant_name = extension_name.upper() + "_FIELD_NUMBER"
    setattr(cls, constant_name, extension_field.number)

  # TODO(amauryfa): Migrate all users of these attributes to functions like
  #   pool.FindExtensionByNumber(descriptor).
  if descriptor.file is not None:
    # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available.
    pool = descriptor.file.pool
    cls._extensions_by_number = pool._extensions_by_number[descriptor]
    cls._extensions_by_name = pool._extensions_by_name[descriptor]
1173778
def build_attrs(self, *args, **kwargs):
        """"""
        self.attrs.setdefault('data-minimum-input-length', 1)
        self.attrs.setdefault('data-tags', 'true')
        self.attrs.setdefault('data-token-separators', '[",", " "]')
        return super(Select2TagMixin, self).build_attrs(*args, **kwargs)
604324
def add_fields(self, **fields):
        """"""
        self.__class__ = type(self.__class__.__name__,
                            (self.__class__,), fields)
        for k, v in fields.items():
            v.init_inst(self)
592180
def _get_fields(attrs, field_class, pop=False, ordered=False):
    
    fields = [
        (field_name, field_value)
        for field_name, field_value in iteritems(attrs)
        if is_instance_or_subclass(field_value, field_class)
    ]
    if pop:
        for field_name, _ in fields:
            del attrs[field_name]
    if ordered:
        fields.sort(key=lambda pair: pair[1]._creation_index)
    return fields
274459
def attributes= (attrs)
      attrs.each_pair do |name, value|
        field = schema.fields[name.to_s] || FieldDefinition.new(name, :type => value.class)
        setter = "#{name}=".to_sym
        if respond_to?(setter)
          send(setter, value)
        else
          write_attribute(field, value, self)
        end
      end
    end
277485
private void parseField()
    throws IOException
  {
    int accessFlags = readShort();
    int nameIndex = readShort();
    int descriptorIndex = readShort();

    JavaField field = new JavaField();
    field.setJavaClass(_class);
    field.setName(_cp.getUtf8(nameIndex).getValue());
    field.setDescriptor(_cp.getUtf8(descriptorIndex).getValue());
    field.setAccessFlags(accessFlags);

    int attributesCount = readShort();

    for (int i = 0; i < attributesCount; i++) {
      Attribute attr = parseAttribute();

      field.addAttribute(attr);
    }

    _class.addField(field);
  }
130864
def visit_field_class(self, item, descriptor=None, fields=None):
        """"""
        discovered_fields = collections.OrderedDict()
        field_groups = {}
        for node in item.body:
            if isinstance(node, ast.ClassDef):
                field_groups[node.name] = self.visit_field_class(node)
                continue

            if not isinstance(node, ast.Assign):
                continue
            if not isinstance(node.value, ast.Call):
                continue
            if not isinstance(node.targets[0], ast.Name):
                continue

            # Build accessible symbols table.
            symtable = {}
            # All field types.
            symtable.update({
                field.__name__: field
                for field in get_available_fields()
            })
            # Field group classes.
            symtable.update(field_groups)

            evaluator = SafeEvaluator(symtable=symtable)

            name = node.targets[0].id
            try:
                field = evaluator.run(node.value)
            except Exception as ex:
                # TODO: Handle errors.
                raise ex

            if descriptor is not None:
                field.contribute_to_class(descriptor, fields, name)
            else:
                discovered_fields[name] = field

        if descriptor is None:
            class Fields:
                """Fields wrapper."""

            for name, field in discovered_fields.items():
                setattr(Fields, name, field)

            return Fields
188030
def convert_descriptor(self, descriptor):
        

        # Fields
        fields = []
        fallbacks = []
        schema = tableschema.Schema(descriptor)
        for index, field in enumerate(schema.fields):
            converted_type = self.convert_type(field.type)
            if not converted_type:
                converted_type = 'STRING'
                fallbacks.append(index)
            mode = 'NULLABLE'
            if field.required:
                mode = 'REQUIRED'
            fields.append({
                'name': _slugify_field_name(field.name),
                'type': converted_type,
                'mode': mode,
            })

        # Descriptor
        converted_descriptor = {
            'fields': fields,
        }

        return (converted_descriptor, fallbacks)
868846
def _describe_fields(cls):
        
        dispatch_table = {
            'ShortestPathModel': 'sssp',
            'GraphColoringModel': 'graph_coloring',
            'PagerankModel': 'pagerank',
            'ConnectedComponentsModel': 'connected_components',
            'TriangleCountingModel': 'triangle_counting',
            'KcoreModel': 'kcore',
            'DegreeCountingModel': 'degree_count',
            'LabelPropagationModel': 'label_propagation'
        }
        try:
            toolkit_name = dispatch_table[cls.__name__]
            toolkit = _tc.extensions._toolkits.graph.__dict__[toolkit_name]
            return toolkit.get_model_fields({})
        except:
            raise RuntimeError('Model %s does not have fields description' % cls.__name__)