Populate the ``246`` MARC field.

    Also populates the ``245`` MARC field through side effects.
551659
def titles2marc(self, key, values):
    
    first, rest = values[0], values[1:]

    self.setdefault('245', []).append({
        'a': first.get('title'),
        'b': first.get('subtitle'),
        '9': first.get('source'),
    })

    return [
        {
            'a': value.get('title'),
            'b': value.get('subtitle'),
            '9': value.get('source'),
        } for value in rest
    ]
686416
def fill(cdb, defs, pparms):
        
        #print "defs =", defs
        parms = {n:v[2] for (n,v) in defs.items()}  # Create parms for default field values.
        parms.update(pparms)  # Insert real parameters.
        for (name, value) in parms.items():
            if name not in defs:
                raise Exception("unknown field: "+name)
            width = defs[name][1]
            start = defs[name][0]
            if type(start) == type(0):  # must be either number or list of 2
                start = (start,7)
            # TODO Check type of start.

            if type(value) == type("str"):
                if len(value) > width/8:
                    raise Exception("value too large for field: "+name)
                if start[1] != 7:
                    raise Exception("string must start in bit 7: "+name)
                value += " " * (width/8 - len(value))  # Fill with blanks.
                cdb[start[0]:start[0]+len(value)] = value
            else:
                if value >= 1<<width:
                    raise Exception("value too large for field: "+name)
                startbitnum = start[0]*8 + (7-start[1])  # Number bits l-to-r.
                bitnum = startbitnum + defs[name][1] - 1
                # TODO Is value inserted backwards?
                while width > 0:
                    if bitnum % 8 == 7 and width >= 8:
                        bitlen= 8
                        cdb[bitnum//8] = value & 0xff;
                    else:
                        startofbyte = bitnum // 8 * 8  # Find first bit num in byte.
                        firstbit = max(startofbyte, bitnum-width+1)
                        bitlen= bitnum-firstbit+1
                        shift = (7 - bitnum%8)
                        vmask = (1 << bitlen) - 1
                        bmask = ~(vmask << shift)
                        cdb[bitnum//8] &= bmask
                        cdb[bitnum//8] |= (value & vmask) << shift
                    bitnum -= bitlen
                    value >>= bitlen
                    width  -= bitlen
55535
def force_populate(self):
        
        if not os.path.exists(self.ref):
            raise FileNotFoundError("The reference file path '{}' does not exists.".format(self.ref))
        with open(self.ref, 'r') as f:
            for word in f:
                word = word.strip('\n')
                self.db.add(word)
        self.populated = True
219042
def _create_field_vectors(self):
        """"""
        field_vectors = {}
        term_idf_cache = {}

        for field_ref, term_frequencies in self.field_term_frequencies.items():
            _field_ref = FieldRef.from_string(field_ref)
            field_name = _field_ref.field_name
            field_length = self.field_lengths[field_ref]
            field_vector = Vector()
            field_boost = self._fields[field_name].boost
            doc_boost = self._documents[_field_ref.doc_ref].get("boost", 1)

            for term, tf in term_frequencies.items():
                term_index = self.inverted_index[term]["_index"]

                if term not in term_idf_cache:
                    idf = Idf(self.inverted_index[term], self.document_count)
                    term_idf_cache[term] = idf
                else:
                    idf = term_idf_cache[term]

                score = (
                    idf
                    * ((self._k1 + 1) * tf)
                    / (
                        self._k1
                        * (
                            1
                            - self._b
                            + self._b
                            * (field_length / self.average_field_length[field_name])
                        )
                        + tf
                    )
                )
                score *= field_boost
                score *= doc_boost
                score_with_precision = round(score, 3)

                field_vector.insert(term_index, score_with_precision)

            field_vectors[field_ref] = field_vector

        self.field_vectors = field_vectors
920570
function populateFieldDataFromDataSources(populatedForms, cb) {
    logger.debug("populateFieldDataFromDataSources", populatedForms);
    var DataSource = models.get(connections.mongooseConnection, models.MODELNAMES.DATA_SOURCE);
    //If no data source cache data is expected, then there is no need to load the Data Source Cache Data.

    if (!options.expectDataSourceCache) {
      return cb(undefined, populatedForms);
    }
    var dataSourceIds = getDataSourceIds(populatedForms);

    logger.debug("populateFieldDataFromDataSources", {dataSourceIds: dataSourceIds});

    //If none of the forms refer to any data sources, then no need to search
    if (dataSourceIds.length === 0) {
      return cb(undefined, populatedForms);
    }

    var query = {
      _id: {
        "$in": dataSourceIds
      }
    };

    //One query to populate all data sources
    DataSource.find(query).exec(function(err, dataSources) {
      if (err) {
        logger.error("Error Finding Data Sources", {error: err, dataSourceIds:dataSourceIds});
        return cb(err);
      }

      logger.debug("populateFieldDataFromDataSources", {dataSources: dataSources});

      var validatonError = _validateReturnedDataSources(dataSourceIds, dataSources);

      if (validatonError) {
        logger.error("Error Getting Form With Data Sources", {error: validatonError});
        return cb(validatonError);
      }

      var cacheEntries = {};

      //Assigning a lookup for cache entries
      _.each(dataSources, function(dataSource) {
        cacheEntries[dataSource._id] = dataSource.cache[0].data;
      });

      //Overriding field options for a field with data source data if the field is defined as being sourced from a data source.
      populatedForms = _.map(populatedForms, function(populatedForm) {
        populatedForm.pages = _.map(populatedForm.pages, function(page) {
          page.fields =  _.map(page.fields, function(field) {
            //If it is a data source type field, then return the data source data
            if (field.dataSourceType === models.FORM_CONSTANTS.DATA_SOURCE_TYPE_DATA_SOURCE) {
              //No guarantee these are set
              field.fieldOptions = field.fieldOptions || {};
              field.fieldOptions.definition = field.fieldOptions.definition || {};

              //Setting the data source data
              field.fieldOptions.definition.options = models.convertDSCacheToFieldOptions(field.type, cacheEntries[field.dataSource]);
            }
            return field;
          });
          return page;
        });

        return populatedForm;
      });

      logger.debug("populateFieldDataFromDataSources", {populatedForms: JSON.stringify(populatedForms)});

      //Finished, return the merged forms
      return cb(undefined, populatedForms);
    });

  }
786225
def autosize_fieldname(idfobject):
    """"""
    # undocumented stuff in this code
    return [fname for (fname, dct) in zip(idfobject.objls,
                                          idfobject['objidd'])
            if 'autosizable' in dct]
748277
def _init_fields(self):
        """"""
        if self.opts.fields:
            available_field_names = self.set_class(self.opts.fields)
        else:
            available_field_names = self.set_class(self.declared_fields.keys())
            if self.opts.additional:
                available_field_names |= self.set_class(self.opts.additional)

        invalid_fields = self.set_class()

        if self.only is not None:
            # Return only fields specified in only option
            field_names = self.set_class(self.only)

            invalid_fields |= field_names - available_field_names
        else:
            field_names = available_field_names

        # If "exclude" option or param is specified, remove those fields.
        exclude_field_names = set(self.opts.exclude) | set(self.exclude)
        if exclude_field_names:
            # Note that this isn't available_field_names, since we want to
            # apply "only" for the actual calculation.
            field_names = field_names - exclude_field_names

            invalid_fields |= exclude_field_names - available_field_names

        if invalid_fields:
            message = 'Invalid fields for {}: {}.'.format(self, invalid_fields)
            raise ValueError(message)

        fields_dict = self.dict_class()
        for field_name in field_names:
            field_obj = self.declared_fields.get(field_name, ma_fields.Inferred())
            self._bind_field(field_name, field_obj)
            fields_dict[field_name] = field_obj

        dump_data_keys = [
            obj.data_key or name for name, obj in iteritems(fields_dict) if not obj.load_only
        ]
        if len(dump_data_keys) != len(set(dump_data_keys)):
            data_keys_duplicates = {x for x in dump_data_keys if dump_data_keys.count(x) > 1}
            raise ValueError(
                'The data_key argument for one or more fields collides '
                "with another field's name or data_key argument. "
                'Check the following field names and '
                'data_key arguments: {}'.format(list(data_keys_duplicates)),
            )

        load_attributes = [
            obj.attribute or name for name, obj in iteritems(fields_dict) if not obj.dump_only
        ]
        if len(load_attributes) != len(set(load_attributes)):
            attributes_duplicates = {x for x in load_attributes if load_attributes.count(x) > 1}
            raise ValueError(
                'The attribute argument for one or more fields collides '
                "with another field's name or attribute argument. "
                'Check the following field names and '
                'attribute arguments: {}'.format(list(attributes_duplicates)),
            )

        return fields_dict
1283412
def fill_data_field!
      @all_titles = titles
      @meta_data = collect_metadates
      @title_h1_h2 = all_titles_h1_h2
      @page_text_size = text_size
      @page_a_tags = all_a_tags
      @meta_desc_content = all_meta_description_content
      @h2_text = h2
      @hlu = bad_url
      @title_good = title_good?
      @title_and_h1_good = title_and_h1_good?
      @meta_description_good = metadescription_good?
      @meta_keywords = keywords_good?
      @code_less = code_less?
      @meta_title_duplicates = metadates_good?
      @have_h2 = h2?
    end
214499
def p_field_optional1_2(self, p):
        
        p[0] = Field(name=p[2], alias=p[1], directives=p[3], selections=p[5])
1107305
def add_field(self, name, fragment_size=150, number_of_fragments=3, fragment_offset=None, order="score", type=None):
        
        data = {}
        if fragment_size:
            data['fragment_size'] = fragment_size
        if number_of_fragments is not None:
            data['number_of_fragments'] = number_of_fragments
        if fragment_offset is not None:
            data['fragment_offset'] = fragment_offset
        if type is not None:
            data['type'] = type
        data['order'] = order
        self.fields[name] = data
749461
def p_field_optional2_4(self, p):
        
        p[0] = Field(name=p[2], alias=p[1], selections=p[3])
848933
def generate_fieldvalues(self, count=1):
        
        ar_context = self.get_ar()

        # mapping of UID index to AR objects {1: <AR1>, 2: <AR2> ...}
        copy_from = self.get_copy_from()

        out = {}
        # the original schema fields of an AR (including extended fields)
        fields = self.get_ar_fields()

        # generate fields for all requested ARs
        for arnum in range(count):
            source = copy_from.get(arnum)
            parent = None
            if source is not None:
                parent = self.get_parent_ar(source)
            for field in fields:
                value = None
                fieldname = field.getName()
                if source and fieldname not in SKIP_FIELD_ON_COPY:
                    # get the field value stored on the source
                    context = parent or source
                    value = self.get_field_value(field, context)
                else:
                    # get the default value of this field
                    value = self.get_default_value(
                        field, ar_context, arnum=arnum)
                # store the value on the new fieldname
                new_fieldname = self.get_fieldname(field, arnum)
                out[new_fieldname] = value

        return out
369415
private void populate(Field field, Object target, String stringValue) {
        field.setAccessible(true);
        try {
            final Class fieldType = field.getType();
            final Object value = TypeConverter.convert(stringValue).to(fieldType);
            field.set(target, value);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Could not populate field " + field, e);
        }
    }
575610
def field(self, name, fieldType="C", size="50", decimal=0):
        """"""
        self.fields.append((name, fieldType, size, decimal))
325331
def __recordFmt(self):
        """"""
        if not self.numRecords:
            self.__dbfHeader()
        fmt = ''.join(['%ds' % fieldinfo[2] for fieldinfo in self.fields])
        fmtSize = calcsize(fmt)
        return (fmt, fmtSize)
1283911
private void populateModel()
   {
      if (m_count != 0)
      {
         m_count = 0;
         Arrays.fill(m_flags, false);
      }

      for (Resource resource : m_parentFile.getResources())
      {
         for (int loop = 0; loop < MPXResourceField.MAX_FIELDS; loop++)
         {
            if (resource.getCachedValue(MPXResourceField.getMpxjField(loop)) != null)
            {
               if (m_flags[loop] == false)
               {
                  m_flags[loop] = true;
                  m_fields[m_count] = loop;
                  ++m_count;
               }
            }
         }
      }

      //
      // Ensure the the model fields always appear in the same order
      //
      Arrays.sort(m_fields);
      System.arraycopy(m_fields, m_fields.length - m_count, m_fields, 0, m_count);
   }
586732
private void fillFields() {

        String folderName = getModuleFolder(m_module.getName());
        if (folderName != null) {
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_parentFormatter.getValue())) {
                m_parentFormatter.setValue(folderName + FORMATTER);
            }
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_parentSchema.getValue())) {
                m_parentSchema.setValue(folderName + SCHEMA);
            }
        }
        if (m_cms.existsResource(folderName + CmsEditModuleForm.CONFIG_FILE)) {
            m_config.setValue(folderName + CmsEditModuleForm.CONFIG_FILE);
        }
        m_parentFormatter.removeAllValidators();
        m_parentSchema.removeAllValidators();
        m_config.removeAllValidators();
        m_config.addValidator(new ResourceValidator());
        m_bundle.addValidator(new BundleValidator());
        m_parentFormatter.addValidator(new ResourceValidator());
        m_parentSchema.addValidator(new ResourceValidator());
        CmsResource bundle = getMessageBundle();
        if (bundle != null) {
            m_bundle.setValue(bundle.getRootPath());

        }
    }