Check if this object configuration is correct ::

        * Check our own specific properties
        * Call our parent class is_correct checker

        :return: True if the configuration is correct, otherwise False
        :rtype: bool
2558
def is_correct(self):
        # pylint: disable=too-many-branches
        
        state = True

        if hasattr(self, 'trigger') and getattr(self, 'trigger', None):
            self.add_warning("[%s::%s] 'trigger' property is not allowed"
                             % (self.my_type, self.get_name()))

        # If no notif period, set it to None, mean 24x7
        if not hasattr(self, 'notification_period'):
            self.notification_period = None

        # If freshness_threshold is not set, use check interval or retry interval
        if hasattr(self, 'freshness_threshold') and not self.freshness_threshold:
            if getattr(self, 'check_interval', 0):
                self.freshness_threshold = self.check_interval * 60
                # self.add_warning("[%s::%s] using check interval as a freshness threshold: %d s"
                #                  % (self.my_type, self.get_name(), self.freshness_threshold))
            elif getattr(self, 'retry_interval', 0):
                self.freshness_threshold = self.retry_interval * 60
                # self.add_warning("[%s::%s] using retry interval as a freshness threshold: %d s"
                #                  % (self.my_type, self.get_name(), self.freshness_threshold))

        # If we got an event handler, it should be valid
        if getattr(self, 'event_handler', None) and not self.event_handler.is_valid():
            self.add_error("[%s::%s] event_handler '%s' is invalid"
                           % (self.my_type, self.get_name(), self.event_handler.command))
            state = False

        if not hasattr(self, 'check_command'):
            # todo: This should never happen because the default exists as an empty string
            self.add_error("[%s::%s] no property check_command" % (self.my_type, self.get_name()))
            state = False
        # Ok got a command, but maybe it's invalid
        else:
            # if not self.check_command:
            #     self.add_warning("[%s::%s] no check_command, will always be considered as Up"
            #                      % (self.my_type, self.get_name()))
            if self.check_command and not self.check_command.is_valid():
                self.add_error("[%s::%s] check_command '%s' invalid"
                               % (self.my_type, self.get_name(), self.check_command.command))
                state = False
            if self.got_business_rule:
                if not self.business_rule.is_valid():
                    self.add_error("[%s::%s] business_rule invalid"
                                   % (self.my_type, self.get_name()))
                    for bperror in self.business_rule.configuration_errors:
                        self.add_error("[%s::%s]: %s" % (self.my_type, self.get_name(), bperror))
                    state = False

        if not hasattr(self, 'notification_interval') \
                and self.notifications_enabled is True:  # pragma: no cover, should never happen
            self.add_error("[%s::%s] no notification_interval but notifications enabled"
                           % (self.my_type, self.get_name()))
            state = False

        # if no check_period, means 24x7, like for services
        if not hasattr(self, 'check_period'):
            self.check_period = None

        state = super(SchedulingItem, self).is_correct()
        return state
175706
def is_active(self, key, *instances, **kwargs):
        
        try:
            default = kwargs.pop('default', False)

            # Check all parents for a disabled state
            parts = key.split(':')
            if len(parts) > 1:
                child_kwargs = kwargs.copy()
                child_kwargs['default'] = None
                result = self.is_active(':'.join(parts[:-1]), *instances,
                                        **child_kwargs)

                if result is False:
                    return result
                elif result is True:
                    default = result

            try:
                switch = self[key]
            except KeyError:
                # switch is not defined, defer to parent
                return default

            if switch.status == GLOBAL:
                return True
            elif switch.status == DISABLED:
                return False
            elif switch.status == INHERIT:
                return default

            conditions = switch.value
            # If no conditions are set, we inherit from parents
            if not conditions:
                return default

            instances = list(instances) if instances else []
            instances.extend(self.context.values())

            # check each switch to see if it can execute
            return_value = False

            for namespace, condition in conditions.iteritems():
                condition_set = registry_by_namespace.get(namespace)
                if not condition_set:
                    continue
                result = condition_set.has_active_condition(condition,
                                                            instances)
                if result is False:
                    return False
                elif result is True:
                    return_value = True
        except:
            log.exception('Error checking if switch "%s" is active', key)
            return_value = False

        # there were no matching conditions, so it must not be enabled
        return return_value
1196329
def is_inheritance_parent(self, field):
        '''
        
        '''
        return (
            isinstance(field, related.OneToOneField) and
            field.primary_key and
            issubclass(field.model, get_remote_field_to(field))
        )
1270959
def should_we_load(kls):
    
    # we don't load abstract classes
    if kls.__name__.endswith("AbstractCheck"):
        return False
    # and we only load checks
    if not kls.__name__.endswith("Check"):
        return False
    mro = kls.__mro__
    # and the class needs to be a child of AbstractCheck
    for m in mro:
        if m.__name__ == "AbstractCheck":
            return True
    return False
724166
def parent(self, parent_object, limit_parent_language=True):
        
        lookup = get_parent_lookup_kwargs(parent_object)

        # Filter the items by default, giving the expected "objects for this parent" items
        # when the parent already holds the language state.
        if limit_parent_language:
            language_code = get_parent_language_code(parent_object)
            if language_code:
                lookup['language_code'] = language_code

        return self.filter(**lookup)
377938
def check_config(data):
    

    is_right = True

    if "title" not in data:
        logging.error("No 'title' in _config.yml")
        is_right = False

    return is_right
309434
def _validate_configuration_type(self, configuration_type):
        

        if configuration_type.lower() != 'running' and configuration_type.lower() != 'startup':
            raise Exception(self.__class__.__name__, 'Configuration Type is invalid. Should be startup or running')
294604
function checkOptions(opts1, opts2) {
        for (var prop in opts1) {
            if (opts1.hasOwnProperty(prop)) {
                if (opts1[prop] !== opts2[prop]) {
                    return true;
                }
            }
        }
        return false;
    }
234450
def is_valid(self):
        # type: () -> bool
        
        assert self._bundle_context
        assert self._container_props is not None
        assert self._get_distribution_provider()
        assert self.get_config_name()
        assert self.get_namespace()
        return True
959109
def check_property(prop, name, **kwargs):
    

    checkers = {
        'color': check_color,
        'alpha': check_alpha,
        'size': check_size,
        'thickness': check_thickness,
        'index': check_index,
        'coordinates': check_coordinates,
        'colormap': check_colormap,
        'bins': check_bins,
        'spec': check_spec
    }

    if name in checkers:
        return checkers[name](prop, **kwargs)
    elif isinstance(prop, list) or isinstance(prop, ndarray) or isscalar(prop):
        return check_1d(prop, name)
    else:
        return prop
340998
def validate(self):
        

        missing = self.missing_property_names()

        if len(missing) > 0:
            raise validators.ValidationError(
                "'{0}' are required attributes for {1}"
                            .format(missing, self.__class__.__name__))

        for prop, val in six.iteritems(self._properties):
            if val is None:
                continue

            if isinstance(val, ProtocolBase):
                val.validate()
            elif getattr(val, 'isLiteralClass', None) is True:
                val.validate()
            elif isinstance(val, list):
                for subval in val:
                  subval.validate()
            else:
                # This object is of the wrong type, but just try setting it
                # The property setter will enforce its correctness
                # and handily coerce its type at the same time
                setattr(self, prop, val)

        return True
572589
def check_config(self, config, fields_spec):
        
        for field, type_info in fields_spec.items():
            has_default = not isinstance(type_info, type)
            if field not in config and not has_default:
                raise RuntimeError(
                    "Configuration not complete. %s missing" % field)
258279
def is_correct(self):
        
        state = True
        cls = self.__class__

        hname = getattr(self, 'host_name', '')
        hgname = getattr(self, 'hostgroup_name', '')
        sdesc = getattr(self, 'service_description', '')

        if not sdesc:
            self.add_error("a %s has been defined without service_description, from: %s"
                           % (cls, self.imported_from))
        elif not hname:
            self.add_error("[%s::%s] not bound to any host."
                           % (self.my_type, self.get_name()))
        elif not hname and not hgname:
            self.add_error("a %s has been defined without host_name nor "
                           "hostgroup_name, from: %s" % (self.my_type, self.imported_from))
        elif self.host is None:
            self.add_error("[%s::%s] unknown host_name '%s'"
                           % (self.my_type, self.get_name(), self.host_name))

        # Set display_name if needed
        if not getattr(self, 'display_name', ''):
            self.display_name = "%s/%s" % (hname, sdesc)

        for char in cls.illegal_object_name_chars:
            if char not in self.service_description:
                continue

            self.add_error("[%s::%s] service_description got an illegal character: %s"
                           % (self.my_type, self.get_name(), char))

        return super(Service, self).is_correct() and state
1200894
def has_own_property(self, attr):
        
        try:
            object.__getattribute__(self, attr)
        except AttributeError:
            return False
        else:
            return True
6356
def is_active(self, key, *instances, **kwargs):
        
        default = kwargs.pop('default', False)

        # Check all parents for a disabled state
        parts = key.split(':')
        if len(parts) > 1:
            child_kwargs = kwargs.copy()
            child_kwargs['default'] = None
            result = self.is_active(':'.join(parts[:-1]), *instances, **child_kwargs)

            if result is False:
                return result
            elif result is True:
                default = result

        try:
            switch = self[key]
        except KeyError:
            # switch is not defined, defer to parent
            return default

        if switch.status == GLOBAL:
            return True
        elif switch.status == DISABLED:
            return False
        elif switch.status == INHERIT:
            return default

        conditions = switch.value
        # If no conditions are set, we inherit from parents
        if not conditions:
            return default

        if instances:
            # HACK: support request.user by swapping in User instance
            instances = list(instances)
            for v in instances:
                if isinstance(v, HttpRequest) and hasattr(v, 'user'):
                    instances.append(v.user)

        # check each switch to see if it can execute
        return_value = False

        for switch in self._registry.itervalues():
            result = switch.has_active_condition(conditions, instances)
            if result is False:
                return False
            elif result is True:
                return_value = True

        # there were no matching conditions, so it must not be enabled
        return return_value
1257670
def _is_modified_property(self, prop):
        
        if type(prop) is str:
            return prop in self._modified_members
        return False
1080362
def is_locked(self):
        
        if not self.__locked__:
            return False
        elif self.get_parent():
            return self.get_parent().is_locked()

        return True