Validate a directive.
        :param directive: The directive to validate.
        :return: A tuple of action, patterns, thedir, dir_patterns
779955
def _parse_directive(self, directive):
        
        words = directive.split()
        if len(words) == 1 and words[0] not in ('include', 'exclude',
                                                'global-include',
                                                'global-exclude',
                                                'recursive-include',
                                                'recursive-exclude',
                                                'graft', 'prune'):
            # no action given, let's use the default 'include'
            words.insert(0, 'include')

        action = words[0]
        patterns = thedir = dir_pattern = None

        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            if len(words) < 2:
                raise DistlibException(
                    '%r expects <pattern1> <pattern2> ...' % action)

            patterns = [convert_path(word) for word in words[1:]]

        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistlibException(
                    '%r expects <dir> <pattern1> <pattern2> ...' % action)

            thedir = convert_path(words[1])
            patterns = [convert_path(word) for word in words[2:]]

        elif action in ('graft', 'prune'):
            if len(words) != 2:
                raise DistlibException(
                    '%r expects a single <dir_pattern>' % action)

            dir_pattern = convert_path(words[1])

        else:
            raise DistlibException('unknown action %r' % action)

        return action, patterns, thedir, dir_pattern
1097015
async def validate(self, request: web.Request):
        
        parameters = {}
        files = {}
        errors = self.errors_factory()
        body = None

        if request.method in request.POST_METHODS:
            try:
                body = await self._content_receiver.receive(request)
            except ValueError as e:
                errors[request.content_type].add(str(e))
            except TypeError:
                errors[request.content_type].add('Not supported content type')

        for name, param in self._parameters.items():
            where = param['in']
            schema = param.get('schema', param)
            vtype = schema['type']
            is_array = vtype == 'array'

            if where == 'query':
                source = request.query
            elif where == 'header':
                source = request.headers
            elif where == 'path':
                source = request.match_info
            elif body is None:
                source = ()
            elif where == 'formData':
                source = body
            elif where == 'body':
                if isinstance(body, BaseException):
                    errors[name].add(str(body))
                else:
                    parameters[name] = body
                continue
            else:
                raise ValueError(where)

            if is_array and hasattr(source, 'getall'):
                collection_format = param.get('collectionFormat')
                default = param.get('default', [])
                value = get_collection(source, name,
                                       collection_format, default)
                if param.get('minItems') and not value \
                        and name not in self._required:
                    continue
            elif isinstance(source, Mapping) and name in source and (
                vtype not in ('number', 'integer') or source[name] != ''
            ):
                value = source[name]
            elif 'default' in param:
                parameters[name] = param['default']
                continue
            elif name in self._required:
                errors[name].add('Required')
                if isinstance(source, BaseException):
                    errors[name].add(str(body))
                continue
            else:
                continue

            if is_array:
                vtype = schema['items']['type']
                vformat = schema['items'].get('format')
            else:
                vformat = schema.get('format')

            if source is body and isinstance(body, dict):
                pass
            elif vtype not in ('string', 'file'):
                value = convert(name, value, vtype, vformat, errors)

            if vtype == 'file':
                files[name] = value
            else:
                parameters[name] = value

        parameters = self._validate(parameters, errors)
        parameters.update(files)
        return parameters, errors
474290
def validate_headers(self):
        
        super().validate()
        self.validate_header(self.channeldir, self.channelinfo, CHANNEL_INFO_HEADER)
        self.validate_header(self.channeldir, self.contentinfo, CONTENT_INFO_HEADER)
        if self.has_exercises():
            self.validate_header(self.channeldir, self.exercisesinfo, EXERCISE_INFO_HEADER)
            self.validate_header(self.channeldir, self.questionsinfo, EXERCISE_QUESTIONS_INFO_HEADER)
403505
def directive(apply_globally=False, api=None):
    """"""
    def decorator(directive_method):
        if apply_globally:
            hug.defaults.directives[underscore(directive_method.__name__)] = directive_method
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(directive_method)
            apply_to_api.add_directive(directive_method)
        directive_method.directive = True
        return directive_method
    return decorator
1197251
def validate(path):  # pragma: no cover
    """"""
    # reads the 'dynaconf_validators.toml' from path
    # for each section register the validator for specific env
    # call validate

    path = Path(path)

    if not str(path).endswith(".toml"):
        path = path / "dynaconf_validators.toml"

    if not path.exists():  # pragma: no cover  # noqa
        click.echo(
            click.style("{} not found".format(path), fg="white", bg="red")
        )
        sys.exit(1)

    validation_data = toml.load(open(str(path)))

    success = True
    for env, name_data in validation_data.items():
        for name, data in name_data.items():
            if not isinstance(data, dict):  # pragma: no cover
                click.echo(
                    click.style(
                        "Invalid rule for parameter '{}'".format(name),
                        fg="white",
                        bg="yellow",
                    )
                )
            else:
                data.setdefault("env", env)
                click.echo(
                    click.style(
                        "Validating '{}' with '{}'".format(name, data),
                        fg="white",
                        bg="blue",
                    )
                )
                try:
                    Validator(name, **data).validate(settings)
                except ValidationError as e:
                    click.echo(
                        click.style(
                            "Error: {}".format(e), fg="white", bg="red"
                        )
                    )
                    success = False

    if success:
        click.echo(click.style("Validation success!", fg="white", bg="green"))
224745
def validate(fname):
    
    validation = {
        "errors": [],
        "warnings": []
    }
    for line in _process(fname):
        kind, message = _determine(line)
        if kind in validation:
            validation[kind].append(message)
    return validation
931810
def validate(self):
        
        # Check all values for None
        for attr in self.__dict__:
            if self.__dict__[attr] is None:
                raise ValueError(attr + " is not set")

        # Validate name
        invalid_chars = GPTaskSpec.invalid_chars()
        if any(char in invalid_chars for char in self.name):
            raise ValueError("module name includes invalid characters: " + self.name)

        # Validate LSID
        self._valid_lsid()

        # Validate categories
        if not self.all_strings(self.categories):
            raise TypeError("categories contains non-string value: " + str(self.categories))

        # Validate file formats
        if not self.all_strings(self.file_format):
            raise TypeError("file_format contains non-string value: " + str(self.file_format))

        # Validate support files
        if not self.all_strings(self.support_files):
            raise TypeError("support_files contains non-string value: " + str(self.support_files))

        # Validate parameter list
        if not self._all_params(self.parameters):
            raise TypeError("parameters contains non-GPParamSpec value: " + str(self.parameters))

        # Validate individual parameters
        for param in self.parameters:
            param.validate()

        # Return that everything validates
        return True
808867
def validate_metadata(target_dir, metadata):
    
    if not os.path.isdir(target_dir):
        print("Error: " + target_dir + " is not a directory")
        return False
    file_list = os.listdir(target_dir)
    for filename in file_list:
        if filename not in metadata:
            print("Error: " + filename + " present at" + target_dir +
                  " not found in metadata file")
            return False
    for filename in metadata:
        if filename not in file_list:
            print("Error: " + filename + " present in metadata file " +
                  " not found on disk at: " + target_dir)
            return False
    return True
987752
def extract_directives(header)
        processed_header = String.new("")
        directives = []

        header.lines.each_with_index do |line, index|
          if directive = line[DIRECTIVE_PATTERN, 1]
            name, *args = Shellwords.shellwords(directive)
            if respond_to?("process_#{name}_directive", true)
              directives << [index + 1, name, *args]
              # Replace directive line with a clean break
              line = "\n"
            end
          end
          processed_header << line
        end

        processed_header.chomp!
        # Ensure header ends in a new line like before it was processed
        processed_header << "\n" if processed_header.length > 0 && header[-1] == "\n"

        return processed_header, directives
      end
252204
static void checkDeprecatedDirective(List<GraphQLError> errors, Directive directive, Supplier<InvalidDeprecationDirectiveError> errorSupplier) {
        if ("deprecated".equals(directive.getName())) {
            // it can have zero args
            List<Argument> arguments = directive.getArguments();
            if (arguments.size() == 0) {
                return;
            }
            // but if has more than it must have 1 called "reason" of type StringValue
            if (arguments.size() == 1) {
                Argument arg = arguments.get(0);
                if ("reason".equals(arg.getName()) && arg.getValue() instanceof StringValue) {
                    return;
                }
            }
            // not valid
            errors.add(errorSupplier.get());
        }
    }
403136
def validate(self, *args, **kwds):
        
        if self.behavior:
            return self.behavior.validate(self, *args, **kwds)
        return True
440952
def validate(self, data):
        
        for s in [self._schema(s, error=self._error, ignore_extra_keys=self._ignore_extra_keys) for s in self._args]:
            data = s.validate(data)
        return data
451450
def validate(self, **kwargs):
        

        default_data_schema = json.load(open(self.default_schema_file, 'r'))

        # even though we are using the yaml package to load,
        # it supports JSON and YAML
        data = kwargs.pop("data", None)
        file_path = kwargs.pop("file_path", None)

        if file_path is None:
            raise LookupError("file_path argument must be supplied")

        if data is None:

            try:
                data = yaml.load(open(file_path, 'r'), Loader=Loader)
            except Exception as e:
                self.add_validation_message(ValidationMessage(file=file_path, message=
                'There was a problem parsing the file.\n' + e.__str__()))
                return False

        try:

            if 'type' in data:
                custom_schema = self.load_custom_schema(data['type'])
                json_validate(data, custom_schema)
            else:
                json_validate(data, default_data_schema)

        except ValidationError as ve:

            self.add_validation_message(
                ValidationMessage(file=file_path,
                                    message=ve.message + ' in ' + str(ve.instance)))

        if self.has_errors(file_path):
            return False
        else:
            return True
37968
def validate(args):
    
    p = OptionParser(validate.__doc__)

    opts, args = p.parse_args(args)

    try:
        agpfile, componentfasta, targetfasta = args
    except Exception as e:
        sys.exit(p.print_help())

    agp = AGP(agpfile)
    build = Fasta(targetfasta)
    bacs = Fasta(componentfasta, index=False)

    # go through this line by line
    for aline in agp:
        try:
            build_seq = build.sequence(dict(chr=aline.object,
                start=aline.object_beg, stop=aline.object_end))

            if aline.is_gap:
                assert build_seq.upper() == aline.gap_length * 'N', \
                    "gap mismatch: %s" % aline
            else:
                bac_seq = bacs.sequence(dict(chr=aline.component_id,
                    start=aline.component_beg, stop=aline.component_end,
                    strand=aline.orientation))

                assert build_seq.upper() == bac_seq.upper(), \
                        "sequence mismatch: %s" % aline

            logging.debug("%s:%d-%d verified" % (aline.object,
                aline.object_beg, aline.object_end))

        except Exception as e:
            logging.error(e)
232347
def validate_data(args={})
      args = args.slice(:file_path, :data)
      args = args.compact
      file_path = args[:file_path]
      data = args[:data]

      utf_result = validate_csv(file_path) if file_path
      utf_result = validate_hashes(data) if data
      utf_result
    end
539305
function(name, cfg){
    if(!name) return;

    var type = typeof name;
    if(type === 'object' && !cfg){
      for(var k in name){
        if(name.hasOwnProperty(k)) this.directive(k, name[k]);
      }
      return this;
    }
    var directives = this._directives, directive;
    if(cfg == null){
      if( type === 'string' ){
        if( directive = directives[name] ) return directive;
        else{
          var regexp = directives.__regexp__;
          for(var i = 0, len = regexp.length; i < len ; i++){
            directive = regexp[i];
            var test = directive.regexp.test(name);
            if(test) return directive;
          }
        }
      }
    }else{
      if( typeof cfg === 'function') cfg = { link: cfg } 
      if( type === 'string' ) directives[name] = cfg;
      else{
        cfg.regexp = name;
        directives.__regexp__.push(cfg)
      }
      if(typeof cfg.link !== 'function') cfg.link = NOOP;
      return this
    }
  }
449310
def _path_is_valid(self, path):
        
        VALIDATORS = [
            (os.path.isabs, self._ERROR_PATH_NOT_ABSOLUTE),
            (os.path.exists, self._ERROR_PATH_DOESNT_EXISTS),
            (os.path.isdir, self._ERROR_PATH_NOT_A_DIR),
        ]

        for validator in VALIDATORS:
            func, str_err = validator
            if not func(path):
                self._print(str_err.format(path), 'red')
                return
        return True