Normalizes bPoint type.

    * **value** must be an string.
    * **value** must be one of the following:

      +--------+
      | corner |
      +--------+
      | curve  |
      +--------+

    * Returned value will be an unencoded ``unicode`` string.
766332
def normalizeBPointType(value):
    
    allowedTypes = ['corner', 'curve']
    if not isinstance(value, basestring):
        raise TypeError("bPoint type must be a string, not %s."
                        % type(value).__name__)
    if value not in allowedTypes:
        raise ValueError("bPoint type must be 'corner' or 'curve', not %r."
                         % value)
    return unicode(value)
939276
def _safe_type(value):
    """"""

    if type(value) is str: dtype = 'string'
    if type(value) is unicode: dtype = 'string'
    if type(value) is int: dtype = 'integer'
    if type(value) is float: dtype = 'real'

    return dtype
27958
def _convert_value(vtype, value):
        
        # Normalize value
        value = value.strip()

        if vtype == TYPE_STRING:
            # Nothing to do
            return value
        elif vtype in TYPES_INT:
            return int(value)
        elif vtype in TYPES_FLOAT:
            return float(value)
        elif vtype in TYPES_BOOLEAN:
            # Compare lower-case value
            return value.lower() not in ("false", "0")
        elif vtype in TYPES_CHAR:
            return value[0]

        # No luck
        raise ValueError("Unknown value type: {0}".format(vtype))
1251450
def normalize(self):
        """"""
        chrfunc = chr if py3k else HTMLEntity._unichr
        if self.named:
            return chrfunc(htmlentities.name2codepoint[self.value])
        if self.hexadecimal:
            return chrfunc(int(self.value, 16))
        return chrfunc(int(self.value))
1335239
def _convert_value_to_native(value):
    
    if isinstance(value, Counter32):
        return int(value.prettyPrint())
    if isinstance(value, Counter64):
        return int(value.prettyPrint())
    if isinstance(value, Gauge32):
        return int(value.prettyPrint())
    if isinstance(value, Integer):
        return int(value.prettyPrint())
    if isinstance(value, Integer32):
        return int(value.prettyPrint())
    if isinstance(value, Unsigned32):
        return int(value.prettyPrint())
    if isinstance(value, IpAddress):
        return str(value.prettyPrint())
    if isinstance(value, OctetString):
        try:
            return value.asOctets().decode(value.encoding)
        except UnicodeDecodeError:
            return value.asOctets()
    if isinstance(value, TimeTicks):
        return timedelta(seconds=int(value.prettyPrint()) / 100.0)
    return value
559744
def _type_single(self, value, _type):
        '  '
        if value is None or _type in (None, NoneType):
            # don't convert null values
            # default type is the original type if none set
            pass
        elif isinstance(value, _type):  # or values already of correct type
            # normalize all dates to epochs
            value = dt2ts(value) if _type in [datetime, date] else value
        else:
            if _type in (datetime, date):
                # normalize all dates to epochs
                value = dt2ts(value)
            elif _type in (unicode, str):
                # make sure all string types are properly unicoded
                value = to_encoding(value)
            else:
                try:
                    value = _type(value)
                except Exception:
                    value = to_encoding(value)
                    logger.error("typecast failed: %s(value=%s)" % (
                        _type.__name__, value))
                    raise
        return value
1143019
def _norm(self, value):
        
        if isinstance(value, self.valid_types):
            self._byte_value = value * self._unit_value
            self._bit_value = self._byte_value * 8.0
        else:
            raise ValueError("Initialization value '%s' is of an invalid type: %s. "
                             "Must be one of %s" % (
                                 value,
                                 type(value),
                                 ", ".join(str(x) for x in self.valid_types)))
936969
def deflate(self, value):
        
        if not isinstance(value, NeomodelPoint):
            raise TypeError('Invalid datatype to deflate. Expected NeomodelPoint, received {}'.format(type(value)))

        if not value.crs == self._crs:
            raise ValueError('Invalid CRS. '
                             'Expected NeomodelPoint defined over {}, '
                             'received NeomodelPoint defined over {}'.format(self._crs, value.crs))

        if value.crs == 'cartesian-3d':
            return neo4j.types.spatial.CartesianPoint((value.x, value.y,  value.z))
        elif value.crs == 'cartesian':
            return neo4j.types.spatial.CartesianPoint((value.x,value.y))
        elif value.crs == 'wgs-84':
            return neo4j.types.spatial.WGS84Point((value.longitude, value.latitude))
        elif value.crs == 'wgs-84-3d':
            return neo4j.types.spatial.WGS84Point((value.longitude, value.latitude, value.height))
345813
function(value) {
  if (value && value._bsontype) {
    if (_.includes([ 'Decimal128', 'Long' ], value._bsontype)) {
      return value.toString();
    }
    if (_.includes([ 'Double', 'Int32' ], value._bsontype)) {
      return String(value.value);
    }
  }
  if (_.isString(value)) {
    return value;
  }
  return String(value);
}
653561
def normalizeFilePath(value):
    
    if not isinstance(value, basestring):
        raise TypeError("File paths must be strings, not %s."
                        % type(value).__name__)
    return unicode(value)
897006
def indent_marker(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "indent_marker", value)
            assert re.search(r"\s", value), "'{0}' attribute: '{1}' is not a whitespace character!".format(
                "indent_marker", value)
        self.__indent_marker = value
894016
def convert_to_xml(cls, value):
        
        # modulo normalizes negative and >360 degree values
        rot = int(round(value * cls.DEGREE_INCREMENTS)) % cls.THREE_SIXTY
        return str(rot)
889203
def end(self, value: typing.Union[float, NormPointType]) -> None:
        """"""
        self.set_property("end", value)
347739
def convert_values(self):
        
        def stringify(value):
            if self.encoding is not None:
                encoder = partial(pprint_thing_encoded,
                                  encoding=self.encoding)
            else:
                encoder = pprint_thing
            return encoder(value)

        lhs, rhs = self.lhs, self.rhs

        if is_term(lhs) and lhs.is_datetime and is_term(rhs) and rhs.is_scalar:
            v = rhs.value
            if isinstance(v, (int, float)):
                v = stringify(v)
            v = Timestamp(_ensure_decoded(v))
            if v.tz is not None:
                v = v.tz_convert('UTC')
            self.rhs.update(v)

        if is_term(rhs) and rhs.is_datetime and is_term(lhs) and lhs.is_scalar:
            v = lhs.value
            if isinstance(v, (int, float)):
                v = stringify(v)
            v = Timestamp(_ensure_decoded(v))
            if v.tz is not None:
                v = v.tz_convert('UTC')
            self.lhs.update(v)
1033887
def _type_convert(self, value):
        
        if value is None:
            return value

        try:
            return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
        except ValueError:
            pass

        try:
            return int(value)
        except ValueError:
            pass

        try:
            return decimal.Decimal(value)
        except decimal.InvalidOperation:
            pass

        return value
1028449
function normalizePosition(value) {
	if (typeof value === 'string') {
		value = value.split(',');
	}
	if (_.isArray(value)) {
		if (value.length !== 2) {
			throw new FieldError('invalid_type', 'Must be array in form [ long, lat ]');
		}
		value[0] = numberType.normalize(value[0], { type: 'number', min: -180, max: 180 });
		value[1] = numberType.normalize(value[1], { type: 'number', min: -90, max: 90 });
	}
	validatePosition(value);
	return value;
}
855498
def normalizeGlyphUnicode(value):
    
    if not isinstance(value, (int, basestring)) or isinstance(value, bool):
        raise TypeError("Glyph unicode must be a int or hex string, not %s."
                        % type(value).__name__)
    if isinstance(value, basestring):
        try:
            value = int(value, 16)
        except ValueError:
            raise ValueError("Glyph unicode hex must be a valid hex string.")
    if value < 0 or value > 1114111:
        raise ValueError("Glyph unicode must be in the Unicode range.")
    return value