constructor

        :param val: things used to construct uuid
        :type val: uuid as byte, string, or uuid.UUID
174784
def apply_with(self, _, val, ctx):
        
        if isinstance(val, uuid.UUID):
            self.v = val
        elif isinstance(val, six.string_types):
            try:
                self.v = uuid.UUID(val)
            except ValueError:
                self.v = uuid.UUID(bytes=val)
        elif isinstance(val, six.binary_type):
            # TODO: how to support bytes_le?
            self.v = uuid.UUID(bytes=val)
        else:
            raise ValueError('Unrecognized type for UUID: ' + str(type(val)))
161872
def uuid(value = nil)
      if value.nil?
        timeuuid_generator.now
      elsif value.is_a?(Time)
        timeuuid_generator.at(value)
      elsif value.is_a?(DateTime)
        timeuuid_generator.at(Time.at(value.to_f))
      else
        Type::Timeuuid.instance.cast(value)
      end
    end
1295800
function(val) {
      switch (typeof val) {
        case 'undefined':
        case 'boolean':
        case 'number':
        case 'string':
        case 'symbol':
        case 'function':
          return val;
        case 'object':
        default: {
          // typeof null === 'object'
          if (!val) return val;

          // This covers Uint8Array and friends, even without a TypedArray
          // base-class constructor.
          const isTypedArray =
              val.buffer && val.buffer.constructor == ArrayBuffer;
          if (isTypedArray) {
            return val;
          }

          if (seenObjects.has(val)) {
            return null;
          }

          const isArray = val.constructor == Array;
          if (val.constructor != Object && !isArray) {
            return null;
          }

          seenObjects.add(val);
          const ret = isArray ? [] : {};
          // Note |name| will equal a number for arrays.
          for (const name in val) {
            ret[name] = clone(val[name]);
          }

          // Length is a non-enumerable property, but we should copy it over in
          // case it is not the default.
          if (isArray) {
            ret.length = val.length;
          }
          return ret;
        }
      }
    }
993522
def tags(self, val: str) -> None:
        

        if not StorageRecord.ok_tags(val):
            LOGGER.debug('StorageRecord.__init__ <!< Tags %s must map strings to strings', val)
            raise BadRecord('Tags {} must map strings to strings'.format(val))

        self._tags = val or {}
985274
def default(self, value):
        
        if isinstance(value, uuid.UUID):
            return str(value)
        elif isinstance(value, datetime.datetime):
            return value.isoformat()
        elif callable(value):
            return str(value)
        return json.JSONEncoder.default(self, value)
1312027
def isHex(val: str) -> bool:
    
    if isinstance(val, bytes):
        # only decodes utf-8 string
        try:
            val = val.decode()
        except ValueError:
            return False
    return isinstance(val, str) and all(c in string.hexdigits for c in val)
345122
def value(self, value):
        
        try:
            struct.pack('>' + conf.TYPE_CHAR, value)
        except struct.error:
            raise IllegalDataValueError

        self._value = value
1186595
def set_const(const, val):
    ''''''
    try:
        cur = getattr(_c, const)
    except AttributeError:
        raise FSQEnvError(errno.ENOENT, u'no such constant:'\
                          u' {0}'.format(const))
    except TypeError:
        raise TypeError(errno.EINVAL, u'const name must be a string or'\
                        u' unicode object, not:'\
                        u' {0}'.format(const.__class__.__name__))
    should_be = cur.__class__
    try:
        if not isinstance(val, should_be):
            if should_be is unicode or cur is None:
                val = coerce_unicode(val, _c.FSQ_CHARSET)
            elif should_be is int and const.endswith('MODE'):
                val = int(val, 8)
            elif isinstance(cur, numbers.Integral):
                val = int(val)
            else:
                should_be(val)
    except (TypeError, ValueError, ):
        raise FSQEnvError(errno.EINVAL, u'invalid type for constant {0},'\
                          u' should be {1}, not:'\
                          u' {2}'.format(const, should_be.__name__,
                                         val.__class__.__name__))
    setattr(_c, const, val)
    return val
630845
def _to_string(val):
    """"""
    if isinstance(val, binary_type):
        return val.decode('utf-8')
    assert isinstance(val, text_type)
    return val
179542
function (val) {
        var color, mode;
        if (arguments.length > 1) color = arguments[1];
        if (arguments.length > 2) mode = arguments[2];

        return {
            is: 'tag',
            val: val,
            color: color,
            mode: mode,
            toString: function(env) {
                var attr = {};

                _.set(attr, 'value', val.ev(env).toString());
                if (color) {
                    _.set(attr, 'color', color.ev(env).toString());
                }
                if (mode) {
                    _.set(attr, 'mode', mode.ev(env).toString());
                }
                return {
                    '_name': 'stop',
                    '_attributes': attr
                };
            }
        };
    }
1303199
def uuidify(val):
    
    if uuidutils.is_uuid_like(val):
        return val
    else:
        try:
            int_val = int(val, 16)
        except ValueError:
            with excutils.save_and_reraise_exception():
                LOG.error("Invalid UUID format %s. Please provide an "
                          "integer in decimal (0-9) or hex (0-9a-e) "
                          "format", val)
        res = str(int_val)
        num = 12 - len(res)
        return "00000000-0000-0000-0000-" + "0" * num + res
495241
def dynamize_value(self, val):
        
        def _str(val):
            """
            DynamoDB stores booleans as numbers. True is 1, False is 0.
            This function converts Python booleans into DynamoDB friendly
            representation.
            """
            if isinstance(val, bool):
                return str(int(val))
            return str(val)

        dynamodb_type = self.get_dynamodb_type(val)
        if dynamodb_type == 'N':
            val = {dynamodb_type : _str(val)}
        elif dynamodb_type == 'S':
            val = {dynamodb_type : val}
        elif dynamodb_type == 'NS':
            val = {dynamodb_type : [ str(n) for n in val]}
        elif dynamodb_type == 'SS':
            val = {dynamodb_type : [ n for n in val]}
        return val
300784
function(val){
                            if (val === null) return 'null';
                            else if (val === undefined) return 'undefined';
                            else if (val.constructor === Array) return 'array';
                            else if (val.constructor === Object) return 'object';
                            else if (val.constructor === String) return 'string';
                            else if (val.constructor === Number) return 'number';
                            else if (val.constructor === Boolean) return 'boolean';
                            else if (val.constructor === Function) return 'function';
                            else return 'object'
                        }
42353
def attribute(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "attribute", value)
        self.__attribute = value
1216132
def hex_from(val):
    
    if isinstance(val, integer_types):
        hex_str = '%x' % val
        if len(hex_str) % 2:
            hex_str = '0' + hex_str
        return hex_str

    return hexlify(val)
1335175
def _parse_parameters(val_type, val):
    
    if val_type == "logical":
        return val == "T"
    elif val_type == "int":
        return int(val)
    elif val_type == "string":
        return val.strip()
    else:
        return float(val)
1240760
def field_uuid(self, attr, options):
        """"""
        options['validators'].append(validators.UUIDValidator(attr.entity))
        return wtf_fields.StringField, options