Generic function for converting objects into instances of `CodeType`.
774867
def extract_code(obj, compile_mode):
    
    try:
        code = obj.__code__
        if isinstance(code, CodeType):
            return code
        raise ValueError(
            "{obj} has a `__code__` attribute, "
            "but it's an instance of {notcode!r}, not CodeType.".format(
                obj=obj,
                notcode=type(code).__name__,
            )
        )
    except AttributeError:
        raise ValueError("Don't know how to extract code from %s." % obj)
1294492
def as_pseudo(cls, obj):
        
        return obj if isinstance(obj, cls) else cls.from_file(obj)
96614
def _from_dict(cls, values, value_filter, dictionary, allow_unset=True):
        """"""
        if not isinstance(dictionary, Mapping):
            raise TypeError('dictionary should be mapping')
        obj = cls(values, value_filter)
        values = obj.__values
        for name, value in dictionary.items():
            if not isinstance(name, string_types):
                raise TypeError('Key %s is not a string' % str(name))
            setattr(values, name, value)
        if obj.missing and not allow_unset:
            raise ValueError('%d value(s) are unset' % len(obj.missing))
        return obj
1105404
def basicsize(obj, **opts):
    '''
    '''
    v = _typedefof(obj, **opts)
    if v:
        v = v.base
    return v
293775
@SuppressWarnings("unchecked")
   public static <T> T convert(Object object, @NonNull Class<T> desiredType) {
      if (object == null) {
         if (desiredType != null && desiredType.isPrimitive()) {
            return Defaults.defaultValue(desiredType);
         }
         return null;
      }


      if (object instanceof Val) {
         return convert(Cast.as(object, Val.class).get(), desiredType);
      }

      //Handle Enums
      if (Enum.class.isAssignableFrom(desiredType)) {
         Class<? extends Enum> enumClass = Cast.as(desiredType);
         return Cast.as(new EnumConverter(enumClass).apply(object));
      }

      //Handle Object arrays
      if (desiredType.isArray() && !desiredType.getComponentType().isPrimitive()) {
         Class<?> componentType = desiredType.getComponentType();
         return Cast.as(new ArrayConverter<>(componentType).apply(object));
      }

      if (converters.containsKey(desiredType)) {
         Object output = converters.get(desiredType).apply(object);
         if (output == null && desiredType.isPrimitive()) {
            return Defaults.defaultValue(desiredType);
         }
         return Cast.as(output);
      }

      if (Map.class.isAssignableFrom(desiredType)) {
         return Cast.as(convert(object, desiredType, Object.class, Object.class));
      }


      T result = new NewObjectConverter<>(desiredType).apply(object);
      if (result != null) {
         return result;
      }

      if (desiredType.isAssignableFrom(object.getClass())) {
         return Cast.as(object);
      }

      log.fine("Unable to convert object of type {0} to desired type of {1}", object.getClass(), desiredType);
      return null;
   }
578728
function convertStrItems2Obj(obj) {
	var result = {};
	for (var key in obj) {
		var val = obj[key];
		val = extractTypeAndCast(val);
		convertStrItem2Obj(key, val, result);
	}

	return result;
}
1155531
private static Object transformType(Object value) {
    if (value == null) {
      return null;
    }
    String valueString = value.toString();

    // check for boolean
    boolean boolValue = BooleanUtils.toBoolean(valueString);
    if (StringUtils.equals(valueString, Boolean.toString(boolValue))) {
      return boolValue;
    }

    // check for integer
    int intValue = NumberUtils.toInt(valueString);
    if (StringUtils.equals(valueString, Integer.toString(intValue))) {
      return intValue;
    }

    return value;
  }
283367
private Object convertStringToNearestObjectType(String value) {
    switch (value) {
      case "true":
        return true;
      case "false":
        return false;
      default: {
        if (NumberUtils.isParsable(value)) {
          return Integer.parseInt(value);
        }
        return value;
      }
    }
  }
1249217
private V8Object convertJavaObject(Object o) {
		V8Object v8o = new V8Object(runtime);
		Method[] methods = o.getClass().getMethods();
		for (Method m : methods) {
			v8o.registerJavaMethod(o, m.getName(), m.getName(),
					m.getParameterTypes());
		}
		return v8o;
	}
164501
def create_event_object(self,
                            event_type,
                            code,
                            value,
                            timeval=None):
        """"""
        if not timeval:
            self.update_timeval()
            timeval = self.timeval
        try:
            event_code = self.type_codes[event_type]
        except KeyError:
            raise UnknownEventType(
                "We don't know what kind of event a %s is." % event_type)

        event = struct.pack(EVENT_FORMAT,
                            timeval[0],
                            timeval[1],
                            event_code,
                            code,
                            value)
        return event
341271
function createTypeAnnotationBasedOnTypeof(type) {
  if (type === "string") {
    return t.stringTypeAnnotation();
  } else if (type === "number") {
    return t.numberTypeAnnotation();
  } else if (type === "undefined") {
    return t.voidTypeAnnotation();
  } else if (type === "boolean") {
    return t.booleanTypeAnnotation();
  } else if (type === "function") {
    return t.genericTypeAnnotation(t.identifier("Function"));
  } else if (type === "object") {
    return t.genericTypeAnnotation(t.identifier("Object"));
  } else if (type === "symbol") {
    return t.genericTypeAnnotation(t.identifier("Symbol"));
  } else {
    throw new Error("Invalid typeof value");
  }
}
928331
public static TypeCode toTypeCode(Object value) {
		if (value == null)
			return TypeCode.Unknown;

		return toTypeCode(value.getClass());
	}
193521
function processObjectType(object: GraphQLObjectType) {
  return reduce(
    object._typeConfig,
    (def, value, key) => {
      return setDef(
        def,
        key,
        value,
        [
          'description',
          'interfaces',
          'fields',
          'isTypeOf',
          'astNode',
          'onConflict',
        ],
        object,
      );
    },
    { type: 'Object' },
    true,
  );
}
649924
function (instance, instanceKey, type, json, jsonKey) {
    var jsonObject = (jsonKey !== undefined) ? (json[jsonKey] || []) : json;
    var jsonArraySize = jsonObject.length;
    var conversionFunctionsList = [];
    var arrayInstance = [];
    instance[instanceKey] = arrayInstance;
    if (jsonArraySize > 0) {
        for (var i = 0; i < jsonArraySize; i++) {
            if (jsonObject[i]) {
                var typeName = getTypeNameFromInstance(type);
                if (!isSimpleType(typeName)) {
                    var typeInstance = new type();
                    conversionFunctionsList.push({ functionName: Constants.OBJECT_TYPE, instance: typeInstance, json: jsonObject[i] });
                    arrayInstance.push(typeInstance);
                }
                else {
                    arrayInstance.push(conversionFunctions[Constants.FROM_ARRAY](jsonObject[i], typeName));
                }
            }
        }
    }
    return conversionFunctionsList;
}
572986
def pycode(argcount,
           kwonlyargcount,
           nlocals,
           stacksize,
           flags,
           codestring,
           constants,
           names,
           varnames,
           filename,
           name,
           firstlineno,
           lnotab,
           freevars=(),
           cellvars=()):
    
    return CodeType(
        argcount,
        kwonlyargcount,
        nlocals,
        stacksize,
        flags,
        codestring,
        constants,
        names,
        varnames,
        filename,
        name,
        firstlineno,
        lnotab,
        freevars,
        cellvars,
    )
229739
def _instance_callable(obj):
    """"""
    if not isinstance(obj, ClassTypes):
        # already an instance
        return getattr(obj, '__call__', None) is not None

    if six.PY3:
        # *could* be broken by a class overriding __mro__ or __dict__ via
        # a metaclass
        for base in (obj,) + obj.__mro__:
            if base.__dict__.get('__call__') is not None:
                return True
    else:
        klass = obj
        # uses __bases__ instead of __mro__ so that we work with old style classes
        if klass.__dict__.get('__call__') is not None:
            return True

        for base in klass.__bases__:
            if _instance_callable(base):
                return True
    return False
208008
def get_type(obj, **kwargs):
    """"""
    t = type(obj)

    s = extract_type(str(t))

    return 'Type: {}'.format(s)