Property to retrieve to_cls as an entity when possible
543310
def to_cls(self):
        """"""
        # Checks if ``to_cls`` is a string
        #   If it is, checks if the entity is imported and available
        #   If it is, register the class
        try:
            if isinstance(self._to_cls, str):
                self._to_cls = fetch_entity_cls_from_registry(self._to_cls)
        except AssertionError:
            # Preserve ``to_cls`` as a string and we will hook up the entity later
            pass

        return self._to_cls
580689
def InstanceOf(cls, **kwargs):
    """"""
    return Property(types=cls, load=cls.load, **kwargs)
53220
def get_instance namespace, classname=nil, properties={}
    case namespace
    when Sfcc::Cim::ObjectPath
      objectpath = namespace
      namespace = objectpath.namespace
    else
      objectpath = objectpath namespace.to_s, classname, properties
    end
    ret = []
    @client.get_instance(objectpath)
  end
297400
Object getInstanceOfClass(Class cls) {
		if (Boolean.class.isAssignableFrom(cls) || Boolean.TYPE.isAssignableFrom(cls)) {
			return Boolean.FALSE;
		} else if (Integer.TYPE.isAssignableFrom(cls) || Short.TYPE.isAssignableFrom(cls) || Integer.class.isAssignableFrom(cls) || Short.class.isAssignableFrom(cls)) {
			return 0;
		} else if (Long.TYPE.isAssignableFrom(cls) || Long.class.isAssignableFrom(cls)) {
			return 0L;
		} else if (Float.TYPE.isAssignableFrom(cls) || Float.class.isAssignableFrom(cls)) {
			return 0.1F;
		} else if (Double.TYPE.isAssignableFrom(cls) || Double.class.isAssignableFrom(cls)) {
			return 0.1D;
		} else if (cls.isArray()) {
			Class<?> comp = cls.getComponentType();
			Object instance = getInstanceOfClass(comp);
			return new Object[]{instance, instance};
		} else {
			try {
				return cls.newInstance();
			} catch (InstantiationException | IllegalAccessException ex) {
				return getObjectFromConstantFields(cls);
			}
		}
	}
9278
def from_str(cls, s):
        """"""
        ast_obj = ast.parse(s).body[0]
        if not isinstance(ast_obj, cls._expected_ast_type):
            raise AssertionError(
                'Expected ast of type {!r} but got {!r}'.format(
                    cls._expected_ast_type,
                    ast_obj
                )
            )
        return cls(ast_obj)
1017951
def _get_old_style_getter_deps(cls, prop_name, _getter):  # @NoSelf
        """'"""
        args, _, _, defaults = inspect.getargspec(_getter)

        try:
            idx = args.index(KWARG_NAME_DEPS) - (len(args) - len(defaults))
            # finds the corresponding value
            if idx < 0:
                raise ValueError("In class %s.%s logical OP getter '%s'"
                                 "must have a default value set for "
                                 "argument '%s'" % \
                                 (cls.__module__, cls.__name__,
                                  _getter.__name__, KWARG_NAME_DEPS))
            _deps = defaults[idx]
            # checks types
            if not hasattr(_deps, '__iter__'):
                raise TypeError("In logical OP getter %s.%s.%s "
                                "default value of argument '%s' "
                                "must be an iterable" % \
                                (cls.__module__, cls.__name__,
                                 _getter.__name__, KWARG_NAME_DEPS))

            for dep in _deps:
                if not isinstance(dep, str):
                    raise TypeError("In logical OP getter %s.%s.%s "
                                    "values of argument '%s' "
                                    "must be strings" % \
                                    (cls.__module__, cls.__name__,
                                     _getter.__name__,
                                     KWARG_NAME_DEPS))
        except ValueError:
            _deps = ()

        return _deps
95894
def from_dict(cls, entity_cls, adict):
        """"""
        invalid_req = InvalidRequestObject()

        # Extract the pagination parameters from the input
        page = int(adict.pop('page', 1))
        per_page = int(adict.pop(
            'per_page', getattr(active_config, 'PER_PAGE', 10)))
        order_by = adict.pop('order_by', ())

        # Check for invalid request conditions
        if page < 0:
            invalid_req.add_error('page', 'is invalid')

        if invalid_req.has_errors:
            return invalid_req

        # Do we need to pop out random?
        # adict.pop('random', None)

        return cls(entity_cls, page, per_page, order_by, adict)
31057
def dump(cls):
        
        d = OrderedDict(cls.Items())
        d["__classname__"] = cls.__name__
        for attr, klass in cls.Subclasses():
            d[attr] = klass.dump()
        return OrderedDict([(cls.__name__, d)])
123569
def props(cls):
    
    return {k:v for (k, v) in inspect.getmembers(cls) if type(v) is Argument}
1055664
def get_properties(cls_def):
    
    # pdb.set_trace()
    prop_list = {prop: value for prop, value in cls_def.items() \
                 if 'rdf_Property' in value.get('rdf_type', "") or \
                 value.get('rdfs_domain')}

    return prop_list
698837
def get_props_from_doc(self, cls, id, doc):
        
        obj_node = doc.getElementsByTagName('object')[0]
        if not cls:
            class_name = obj_node.getAttribute('class')
            cls = find_class(class_name)
        if not id:
            id = obj_node.getAttribute('id')
        props = {}
        for prop_node in obj_node.getElementsByTagName('property'):
            prop_name = prop_node.getAttribute('name')
            prop = cls.find_property(prop_name)
            value = self.decode_value(prop, prop_node)
            value = prop.make_value_from_datastore(value)
            if value != None:
                props[prop.name] = value
        return (cls, props, id)
339773
def to_model(cls, value):
    

    if isinstance(value, cls) or value is None:
        pass  # skip if right type or value is None

    elif issubclass(cls, Enum):
        value = cls(value)

    elif is_model(cls) and isinstance(value, dict):
        value = convert_key_to_attr_names(cls, value)
        value = cls(**value)

    else:
        value = cls(value)

    return value
359763
def _from_string(cls, serialized):
        
        parse = cls.parse_url(serialized)

        if parse['version_guid']:
            parse['version_guid'] = cls.as_object_id(parse['version_guid'])

        return cls(**{key: parse.get(key) for key in cls.KEY_FIELDS})
136860
def _model_class_from_pk(definition_cls, definition_pk):
    
    try:
        return definition_cls.objects.get(pk=definition_pk).model_class()
    except definition_cls.DoesNotExist:
        pass
1020382
def _get_object_class(cls, class_name):
        

        class_name = class_name.lstrip(cls.__STRING_FORMAT_UNDERSCORE)

        if class_name in cls._override_field_map:
            class_name = cls._override_field_map[class_name]

        try:
            return getattr(endpoint, class_name)
        except AttributeError:
            pass

        try:
            return getattr(object_, class_name)
        except AttributeError:
            pass

        raise BunqException(cls._ERROR_MODEL_NOT_FOUND.format(class_name))
130038
def to_obj(self, ns_info=None):
        
        if ns_info:
            ns_info.collect(self)

        # null behavior for classes that inherit from Entity but do not
        # have _binding_class
        if not hasattr(self, "_binding_class"):
            return None

        entity_obj = self._binding_class()

        for field, val in six.iteritems(self._fields):
            # EntityLists with no list items should be dropped
            if isinstance(val, EntityList) and len(val) == 0:
                val = None
            elif field.multiple:
                if val:
                    val = [_objectify(field, x, ns_info) for x in val]
                else:
                    val = []
            else:
                val = _objectify(field, val, ns_info)

            setattr(entity_obj, field.name, val)

        self._finalize_obj(entity_obj)
        return entity_obj
82298
def from_def(cls, obj):
        
        prof = cls(obj["steamid"])
        prof._cache = obj

        return prof