ANALYZE FILE ] CHECK PATH [
543312
function checkContainsPathComponent(dirs, path) {
    return _.find(dirs, function(dir) {
      var v = path.indexOf(dir);
      return v == 0;
    });
  }
1316007
def has_files(the_path):
    """"""
    the_path = Path(the_path)
    try:
        for _ in the_path.walkfiles():
            return True
        return False
    except OSError as ex:
        if ex.errno == errno.ENOENT:
            # ignore
            return False
        else:
            raise
490869
def check_path(options, rootdir=None, candidates=None, code=None):
    
    if not candidates:
        candidates = []
        for path_ in options.paths:
            path = op.abspath(path_)
            if op.isdir(path):
                for root, _, files in walk(path):
                    candidates += [op.relpath(op.join(root, f), CURDIR)
                                   for f in files]
            else:
                candidates.append(path)

    if rootdir is None:
        rootdir = path if op.isdir(path) else op.dirname(path)

    paths = []
    for path in candidates:

        if not options.force and not any(l.allow(path)
                                         for _, l in options.linters):
            continue

        if not op.exists(path):
            continue

        paths.append(path)

    if options.concurrent:
        return check_async(paths, options, rootdir)

    errors = []
    for path in paths:
        errors += run(path=path, code=code, rootdir=rootdir, options=options)
    return errors
114861
def grep(pattern, *files_or_paths):
    """"""
    matches = []

    for fop in files_or_paths:
        with fileobj(fop) as fo:
            matches.extend((line for line in fo if re.match(pattern, line)))

    return matches
782961
def do_grep(self, path, match):
        
        try:
            children = self.get_children(path)
        except (NoNodeError, NoAuthError):
            children = []

        for child in children:
            full_path = os.path.join(path, child)
            try:
                value, _ = self.get(full_path)
            except (NoNodeError, NoAuthError):
                value = ""

            if value is not None:
                matches = [line for line in value.split("\n") if match.search(line)]
                if len(matches) > 0:
                    yield (full_path, matches)

            for mpath, matches in self.do_grep(full_path, match):
                yield (mpath, matches)
132486
def is_excluded_path(args, filepath):
    """"""
    # Try regular expressions first.
    for regexp_exclude_path in args.regexp:
        if re.match(regexp_exclude_path, filepath):
            return True
    abspath = os.path.abspath(filepath)
    if args.include:
        # If the file is outside of any include directories.
        out_of_include_dirs = True
        for incl_path in args.include:
            absolute_include_path = os.path.abspath(os.path.join(args.root, incl_path))
            if is_child_dir(absolute_include_path, abspath):
                out_of_include_dirs = False
                break
        if out_of_include_dirs:
            return True

    excl_rules = create_exclude_rules(args)
    for i, rule in enumerate(excl_rules):
        if rule[0] == abspath:
            return rule[1]
        if is_child_dir(rule[0], abspath):
            # continue to try to longest match.
            last_result = rule[1]
            for j in range(i + 1, len(excl_rules)):
                rule_deep = excl_rules[j]
                if not is_child_dir(rule_deep[0], abspath):
                    break
                last_result = rule_deep[1]
            return last_result
    return False
714545
def analyse(file, length=None, *, _termination=False):
    """"""
    seekset = file.tell()
    if not _termination:
        # FTP analysis
        flag, ftp = _analyse_ftp(file, length, seekset=seekset)
        if flag:
            return ftp

        # HTTP/1.* analysis
        flag, http = _analyse_httpv1(file, length, seekset=seekset)
        if flag:
            return http

        # NOTE: due to format similarity of HTTP/2 and TLS/SSL, HTTP/2 won't be analysed before TLS/SSL is implemented.
        # NB: the NOTE above is deprecated, since validations are performed

        # HTTP/2 analysis
        flag, http = _analyse_httpv2(file, length, seekset=seekset)
        if flag:
            return http

        # backup file offset
        file.seek(seekset, os.SEEK_SET)

    # raw packet analysis
    return Raw(file, length)
576011
function analyze(filename, analyzeCallback) {

    var stack = [];
    var input = fs.createReadStream(filename);
    var fileext = path.extname(filename);
    var lineN = 0;
    var objects = [];
    var lines = []

    // CHECK EXTLANG [

    function _configGetExtLang(filext) {
      var fileext1 = filext.indexOf('.') == 0 ? fileext.substring(1, filext.length) : fileext;
      if (!config.extlangs.hasOwnProperty(fileext1))
        return null;

      return config.extlangs[fileext1];
    };

    var extlang = _configGetExtLang(fileext);
    if (!extlang) {
      analyzeCallback()
      return;
    }

    // CHECK EXTLANG ]
    // READ LINES/LINE [

    readLines(input, function readLine(line, complete) {
  //    console.log(line);
      lines.push(line);
      lineN += 1;

      // checkCommentLine [

      function checkCommentLine(stack, fileext, line, lineN, cbs) {

        // custom comment format use config.extractCommentTagFromLine [

        function extractCommentTagFromLine(fileext, line) {
          line = line.trim();
          // CHECK FORMAT [
          var b;
          function chkfmt(b) {
            if (line.indexOf(b) == 0 && line.indexOf('[') == line.length-1) // begin
              return [line.substr(b.length, line.length-b.length-1).trim(), 0];
            if (line.indexOf(b) == 0 && line.indexOf(']') == line.length-1 && line.indexOf('[') == -1) // end
              return [line.substr(b.length, line.length-b.length-1).trim(), 1];
            return null;
          };
          // CHECK FORMAT ]

          // SUPPORT FORMATS [
          switch (fileext) {
            case '.js':
            case '.java':
            case '.c':
            case '.h':
            case '.cpp':
            case '.hpp':
            case '.less':
            case '.m':
            case '.mm':
              return chkfmt('//') || false;
            case '.css':
              return chkfmt('/*') || false;
            case '.acpul':
            case '.sh':
            case '.py':
            case '.pro':
              return chkfmt('#') || false;
            case '.ejs':
            case '.jade':
            case '.sass':
            case '.styl':
            case '.coffee':
              break;
            default:
              return null;
          }
          // SUPPORT FORMATS ]
          return false;
        }

        var tag = (config.extractCommentTagFromLine && config.extractCommentTagFromLine(fileext, line)) || extractCommentTagFromLine(fileext, line);
        if (tag === null)
          return false;

        // custom comment format use config.extractCommentTagFromLine ]

        if (tag) {
          // PROCESSING TAG [
          if (tag[1] == 0) {
            // ON BEGIN [
            var c = {name:tag[0], lines:[lineN, -1], parents:[]};
            stack.push(c);
            cbs.begin(stack, c);
            // ON BEGIN ]
          } else if (tag[1] == 1) {
            // ON END [
            if (stack.length > 0) {
              var ok = false;
              // dirty hack! [
              if (stack.slice(-1)[0].name == tag[0])
                ok = true;
              else if (stack.length > 1 && stack.slice(-2)[0].name == tag[0]) {
                var a = stack.slice(-2);
                var c = stack.pop();
                ok = true;
              } else
                cbs.error('Found close tag without match start tag'+tag[0]);
              // dirty hack! ]
              if (ok) {
                var c = stack.pop();
                c.lines[1] = lineN;
                //_.each(stack, function(p) {c.parents.push(p.name);});
                c.parents  = stack.slice(0);
                cbs.end(stack, c);
              }
            } else {
              cbs.error('Found close tag without any start tag '+tag[0]);
            }
            // ON END ]
          }
  //        console.log(filename);
  //        console.log(tag);
          // PROCESSING TAG ]
        }

        return true;
      };

      // checkCommentLine ]
      // complete [

      if (complete)
      {
        mergeChanges(filename, extlang, lines, objects);
        analyzeCallback()
        return true;
      }

      // complete ]
      // check line [

      var res = checkCommentLine(stack, fileext, line, lineN, {
        begin: function(stack, c) {
        },
        end: function(stack, c) {
  //        udb.add(c);
          if (isLogging('object.parsed'))
            console.log(c);
          objects.push(c);
        },
        error: function(msg) {
          console.log('ERROR:', msg);
        }
      });

      // check line ]

      return res;
    });
    // READ LINES/LINE ]

  }
517977
def _GetFilePaths(self, path, pathtype, kb):
    """"""

    environ_vars = artifact_utils.GetWindowsEnvironmentVariablesMap(kb)
    path_guesses = path_detection_windows.DetectExecutablePaths([path],
                                                                environ_vars)

    if not path_guesses:
      # TODO(user): yield a ParserAnomaly object
      return []

    return [
        rdf_paths.PathSpec(path=path, pathtype=pathtype)
        for path in path_guesses
    ]
557647
def find_in_path(path, file):
  """"""
  for p in path.split(os.pathsep):
    candidate = os.path.join(p, file)
    if os.path.exists(candidate) and os.path.isfile(candidate):
      return candidate
  return False
1079722
def check_path(file_path):
    '''
        
    '''
    directory = os.path.dirname(file_path)
    if directory != '':
        if not os.path.exists(directory):
            os.makedirs(directory, 0o775)
1329402
def find(self, path):
        '''
        
        '''
        if self.mindepth < 1:
            dirpath, name = os.path.split(path)
            match, fstat = self._check_criteria(dirpath, name, path)
            if match:
                for result in self._perform_actions(path, fstat=fstat):
                    yield result

        for dirpath, dirs, files in salt.utils.path.os_walk(path):
            relpath = os.path.relpath(dirpath, path)
            depth = path_depth(relpath) + 1
            if depth >= self.mindepth and (self.maxdepth is None or self.maxdepth >= depth):
                for name in dirs + files:
                    fullpath = os.path.join(dirpath, name)
                    match, fstat = self._check_criteria(dirpath, name, fullpath)
                    if match:
                        for result in self._perform_actions(fullpath, fstat=fstat):
                            yield result

            if self.maxdepth is not None and depth > self.maxdepth:
                dirs[:] = []
22880
def check(path)
      raise FileNotFoundError, "#{path}: no such file" unless File.exist?(path)

      valid = false
      unless disable_extension_check
        unless check_filename(path)
          errors[path] = ['File extension must be .yaml or .yml']
          return valid
        end
      end

      File.open(path, 'r') do |f|
        error_array = []
        valid = check_data(f.read, error_array)
        errors[path] = error_array unless error_array.empty?
      end

      valid
    end
761413
function readFilePaths(files) {
    const locations = [];
    for (let i = 0; i < files.length; i++) {
      const file = files[i];
      const location = path.join(__dirname, "../../../", file);
      locations.push(location);
    }
    return locations;
  }
130692
def analyze(self, filename):
        """"""
        if self.dockwidget and not self.ismaximized:
            self.dockwidget.setVisible(True)
            self.dockwidget.setFocus()
            self.dockwidget.raise_()
        self.pylint.analyze(filename)
1146657
function checkFile( path ) {
            if ( typeof path === "undefined" || ! grunt.file.exists( path ) ) {
                grunt.log.error( "Source file \"" + path + "\" not found." );
                return false;
            }

            return true;
        }
287011
def _where(filename, dirs=[], env="PATH"):
    """"""
    if not isinstance(dirs, list):
        dirs = [dirs]
    if glob(filename):
        return filename
    paths = [os.curdir] + os.environ[env].split(os.path.pathsep) + dirs
    for path in paths:
        for match in glob(os.path.join(path, filename)):
            if match:
                return os.path.normpath(match)
    raise IOError("File not found: %s" % filename)