Returns:
            EPublication: Structure when the object :meth:`is_valid`.

        Raises:
            MetaParsingException: When the object is not valid.
199725
def get_epublication(self):
        
        if not self.is_valid():
            bad_fields = filter(lambda x: not x.is_valid(), self.fields)
            bad_fields = map(
                lambda x: "Keyword '%s' (%s) not found." % (x.keyword, x.descr),
                bad_fields
            )

            raise MetaParsingException(
                "Missing field(s):\n\t" + "\n\t".join(bad_fields)
            )

        relevant_fields = self.fields
        relevant_fields += filter(lambda x: x.is_valid(), self.optional)

        epub_dict = dict(map(lambda x: (x.epub, x.value), relevant_fields))

        # make sure, that all fields present in EPublication has values also
        # in epub_dict
        for epublication_part in EPublication._fields:
            if epublication_part not in epub_dict:
                epub_dict[epublication_part] = None

        if not is_valid_isbn(epub_dict["ISBN"]):
            raise MetaParsingException(
                "ISBN '%s' is not valid!" % epub_dict["ISBN"]
            )

        return EPublication(**epub_dict)
846493
def validate(self, instance, value):
        """"""
        value = super(URL, self).validate(instance, value)
        parsed_url = urlparse(value)
        if not parsed_url.scheme or not parsed_url.netloc:
            self.error(instance, value, extra='URL needs scheme and netloc.')
        parse_result = ParseResult(
            scheme=parsed_url.scheme,
            netloc=parsed_url.netloc,
            path=parsed_url.path,
            params='' if self.remove_parameters else parsed_url.params,
            query='' if self.remove_parameters else parsed_url.query,
            fragment='' if self.remove_fragment else parsed_url.fragment,
        )
        parse_result = parse_result.geturl()
        return parse_result
894797
def is_valid(self):
        
        if len(self.geometry) == 0:
            return True

        try:
            referenced = {self.graph[i][1]
                          for i in self.graph.nodes_geometry}
        except BaseException:
            # if connectivity to world frame is broken return false
            return False

        # every geometry is referenced
        ok = referenced == set(self.geometry.keys())

        return ok
531910
def decode(data):
    
    decoded = None
    try:
        decoded = json.loads(data)
    except Exception, e:
        raise MetaParsingException("Can't parse your JSON data: %s" % e.message)

    decoded = validator.check_structure(decoded)

    return decoded
853800
def validate(self):
        
        if getattr(self, '_getting_validated', False):
            return True
        self._getting_validated = True
        self._validation_error_tuples = []
        self._non_validation_error = None
        try:
            for val in itervalues(self._class_validators):
                try:
                    if isinstance(val.func, string_types):
                        valid = getattr(self, val.func)()
                    else:
                        valid = val.func(self)
                    if valid is False:
                        raise utils.ValidationError(
                            'Validation failed', None, None, self
                        )
                except utils.ValidationError as val_err:
                    self._validation_error_tuples += val_err.error_tuples
                except GENERIC_ERRORS as err:
                    if not self._non_validation_error:
                        self._non_validation_error = err
            if self._validation_error_tuples:
                self._error_hook(self._validation_error_tuples)
                msgs = ['Validation failed:']
                msgs += [val.message for val in self._validation_error_tuples]
                raise utils.ValidationError(
                    message='\n- '.join(msgs),
                    _error_tuples=self._validation_error_tuples,
                )
            if self._non_validation_error:
                raise self._non_validation_error                               #pylint: disable=raising-bad-type
            return True
        finally:
            self._getting_validated = False
            self._validation_error_tuples = None
            self._non_validation_error = None
837168
def is_valid(self):
        
        return (
            self.requirement is not None and self.requirement.optional
        ) or bool(self._future_value)
784248
def iterable_validator(iterable_type, member_type):
    """"""

    def _validate_tuple(instance, attribute, value):
        # pylint: disable=unused-argument
        """Validate that a dictionary is structured as expected.

        :raises TypeError: if ``value`` is not of ``iterable_type`` type
        :raises TypeError: if ``value`` members are not all of ``member_type`` type
        """
        if not isinstance(value, iterable_type):
            raise TypeError('"{name}" must be a {type}'.format(name=attribute.name, type=iterable_type))

        for member in value:
            if not isinstance(member, member_type):
                raise TypeError(
                    '"{name}" members must all be of type "{type}"'.format(name=attribute.name, type=member_type)
                )

    return _validate_tuple
1227973
def validate(self, value):
        
        if not isinstance(value, dict):
            self.raise_error('Only Python dict may be used in the DictField vs provided {0}'
                             .format(type(value).__name__))
        super(DictField, self).validate(value)
70195
def is_valid(self, qstr=None):
        """"""
        if qstr is None:
            qstr = self.currentText()
        return QUrl(qstr).isValid()
191280
def validate(self):
        
        properties = (
            getattr(self.__class__, prop)
            for prop in self._property_list
            if hasattr(self.__class__, prop)
        )

        all_valid = True
        for prop in properties:
            if hasattr(prop, "validate"):
                # oh for fucks sake, brython has broken parser and return in
                # prop.validate() will also return from this function if used
                # with `and` operator
                result = prop.validate()
                all_valid = all_valid and result

        return all_valid
229489
def validate(cls):
        
        if cls.get_dict():
            cls.show_error(False)
            return True

        cls.show_error(True)
        return False
429361
def valid?
      begin
        self.each do |threshold|
          if threshold.respond_to?(:valid?)
            return false unless threshold.valid?
          else
            raise InvalidThresholdsObject, "Container object has unknown objects"
          end
        end
        return true
      rescue InvalidThresholdsObject
        return false
      end
    end
509166
def validate(self):
        
        for key, val in self.grammar.items():
            try:
                setattr(self, key, val)
            except ValueError as e:
                raise ValidationError('invalid contents: ' + e.args[0])
177815
def assert_valid(self, instance, value=None):
        """"""
        valid = super(Instance, self).assert_valid(instance, value)
        if not valid:
            return False
        if value is None:
            value = instance._get(self.name)
        if isinstance(value, HasProperties):
            value.validate()
        return True
612644
def validate(self, instance, value):
        
        if not self.coerce and not isinstance(value, self._class_container):
            self.error(instance, value)
        if self.coerce and not isinstance(value, CONTAINERS):
            value = [value]
        if not isinstance(value, self._class_container):
            out_class = self._class_container
        else:
            out_class = value.__class__
        out = []
        for val in value:
            try:
                out += [self.prop.validate(instance, val)]
            except ValueError:
                self.error(instance, val, extra='This item is invalid.')
        return out_class(out)
680299
def is_valid(cls, arg):
        
        return (isinstance(arg, (int, long)) and (arg >= 0)) or \
            isinstance(arg, str)
1204965
def parse_meta(filename, data):
    
    if "." not in filename:
        raise MetaParsingException(
            "Can't recognize type of your metadata ('%s')!" % filename
        )

    suffix = filename.rsplit(".", 1)[1].lower()

    if suffix not in SUPPORTED_FILES:
        raise MetaParsingException("Can't parse file of type '%s'!" % suffix)

    fp = validator.FieldParser()
    for key, val in SUPPORTED_FILES[suffix](data).items():
        fp.process(key, val)

    return fp.get_epublication()