Convert to the output value of a field
191607
protected Object convertFieldValue(Schema outputSchema, Field field, GenericRecord inputRecord,
      WorkUnitState workUnit)
      throws DataConversionException {
    if (field.name().equals(payloadField)) {
      return upConvertPayload(inputRecord);
    }
    return inputRecord.get(field.name());
  }
1072396
def field_value(field)
      element = find_field(field)
      value = (element.tag_name == 'textarea') ? element.text : element.value
      # If field value is an Array, take the first item
      if value.class == Array
        value = value.first
      end
      return value.to_s
    end
709283
def decode_field(self, field, value):
        
        for decoder in _GetFieldCodecs(field, 'decoder'):
            result = decoder(field, value)
            value = result.value
            if result.complete:
                return value
        if isinstance(field, messages.MessageField):
            field_value = self.decode_message(
                field.message_type, json.dumps(value))
        elif isinstance(field, messages.EnumField):
            value = GetCustomJsonEnumMapping(
                field.type, json_name=value) or value
            try:
                field_value = super(
                    _ProtoJsonApiTools, self).decode_field(field, value)
            except messages.DecodeError:
                if not isinstance(value, six.string_types):
                    raise
                field_value = None
        else:
            field_value = super(
                _ProtoJsonApiTools, self).decode_field(field, value)
        return field_value
1245530
def serialize_output(output):
    
    if not ('value' in output and 'script_hex' in output):
        raise Exception('Invalid output')

    return ''.join([
        hexlify(struct.pack('<Q', output['value'])), # pack into 8 bites
        hexlify(variable_length_int(len(output['script_hex'])/2)),
        output['script_hex']
    ])
712747
function(field) {
  var converted = field.fieldId;
  converted.values = field.fieldValues;
  converted.sectionIndex = field.sectionIndex;
  return converted;
}
475996
function convertFields (infields) {
  const fields = {}

  _.each(infields, (field) => {
    field.outName = convertFieldName(field.name)
    fields[field.name] = field
  })
  return fields
}
636211
def isfieldvalue(bunchdt, data, commdct, idfobj, fieldname, value, places=7):
    """"""
    # do a quick type check
    # if type(idfobj[fieldname]) != type(value):
    # return False # takes care of autocalculate and real
    # check float
    thiscommdct = getfieldcomm(bunchdt, data, commdct, idfobj, fieldname)
    if 'type' in thiscommdct:
        if thiscommdct['type'][0] in ('real', 'integer'):
            # test for autocalculate
            try:
                if idfobj[fieldname].upper() == 'AUTOCALCULATE':
                    if value.upper() == 'AUTOCALCULATE':
                        return True
            except AttributeError:
                pass
            return almostequal(float(idfobj[fieldname]), float(value), places, False)
    # check retaincase
    if is_retaincase(bunchdt, data, commdct, idfobj, fieldname):
        return idfobj[fieldname] == value
    else:
        return idfobj[fieldname].upper() == value.upper()
1130008
function (item, field) {
            var path = field.split("."), value = item;
            while (path.length && typeof(value) !== "undefined") {
                value = value[path.shift()];
            }
            return value;
        }
688987
def _field_value_html(self, field):
        """"""
        if field in self.fields:
            return unicode(self.get(field))
        else:
            return self.get_timemachine_instance(field)._object_name_html()
657880
private Object getFieldValue(Field field) {
        try {
            field.setAccessible(true);
            return field.get(this);
        } catch (IllegalArgumentException | IllegalAccessException e) {
            LOGGER.error("Can't access to field value", e);
            return null;
        }
    }
1211183
def _FormatField(self, field):
    
    if self._FIELD_DELIMITER and isinstance(field, py2to3.STRING_TYPES):
      return field.replace(self._FIELD_DELIMITER, ' ')
    return field
368255
private void writeObjectToField(String fieldname, Object value, Object object, Object alternative)
        throws Exception {
        Object target = object != null ? object : alternative;
        try {
            FieldUtils.writeField(target, fieldname, value, true);
        } catch (Exception e) {
            throw new IllegalArgumentException(String.format("Unable to write value '%s' to field '%s' of object %s",
                value.toString(), fieldname, target.getClass().getName()));
        }
    }
966228
public static Object getValueOfField(Field field, Object ref) {
		field.setAccessible(true);
		Object value = null;
		try {
			value = field.get(ref);
		} catch (IllegalArgumentException e) {
			log.warning(e.getClass().getSimpleName() + ": " + e.getMessage());
		} catch (IllegalAccessException e) {
			log.warning(e.getClass().getSimpleName() + ": " + e.getMessage());
		}
		return value;
	}
1216461
def parse_value(self, value):
        """"""
        parsed = super(IntField, self).parse_value(value)
        if parsed is None:
            return parsed
        return int(parsed)
1134612
def convert_field(self, name, field):
        
        if PEEWEE3:
            field_type = field.field_type.lower()
        else:
            field_type = field.db_field

        pwv_field = ModelValidator.FIELD_MAP.get(field_type, StringField)

        print('pwv_field', field_type, pwv_field)

        validators = []
        required = not bool(getattr(field, 'null', True))
        choices = getattr(field, 'choices', ())
        default = getattr(field, 'default', None)
        max_length = getattr(field, 'max_length', None)
        unique = getattr(field, 'unique', False)

        if required:
            validators.append(validate_required())

        if choices:
            print('CHOICES', choices)
            validators.append(validate_one_of([c[0] for c in choices]))

        if max_length:
            validators.append(validate_length(high=max_length))

        if unique:
            validators.append(validate_model_unique(field, self.instance.select(), self.pk_field, self.pk_value))

        if isinstance(field, peewee.ForeignKeyField):
            if PEEWEE3:
                rel_field = field.rel_field
            else:
                rel_field = field.to_field
            return ModelChoiceField(field.rel_model, rel_field, default=default, validators=validators)

        if isinstance(field, ManyToManyField):
            return ManyModelChoiceField(
                field.rel_model, field.rel_model._meta.primary_key,
                default=default, validators=validators)

        return pwv_field(default=default, validators=validators)
1072813
def format_field(self, field):
        
        if field is None:
            return "NULL"
        elif isinstance(field, TypeError):
            return "TypeError"
        elif isinstance(field, Decimal):
            if field % 1 == 0:
                return str(int(field))
            return str(float(field))
        elif isinstance(field, set):
            return "(" + ", ".join([self.format_field(v) for v in field]) + ")"
        elif isinstance(field, datetime):
            return field.isoformat()
        elif isinstance(field, timedelta):
            rd = relativedelta(
                seconds=int(field.total_seconds()), microseconds=field.microseconds
            )
            return delta_to_str(rd)
        elif isinstance(field, Binary):
            return "<Binary %d>" % len(field.value)
        pretty = repr(field)
        if pretty.startswith("u'"):
            return pretty[1:]
        return pretty
27104
def _to_str(self, value, field_begin, field_len):
        
        value_str = '{0:0{1}d}'.format(value, field_len)
        if self.precision is not None and \
                self.precision < field_begin + field_len:
            # field is partly or completely affected by precision
            # -> replace insignificant digits with asterisks
            precision_index = max(0, self.precision - field_begin)
            value_str = value_str[:precision_index] + \
                '*' * (field_len - precision_index)
        return value_str