Return an array with the names of the files whose code was executed inside
 the block given to #run_hooked or between #install_hook and #remove_hook.
499770
def analyzed_files
      update_script_lines__
      raw_data_relative.select do |file, lines|
        @script_lines__.has_key?(file)
      end.map{|fname,| fname}
    end
571473
def get_filelist(run_module_names):
    
    # Prep search patterns
    spatterns = [{},{},{},{},{},{},{}]
    epatterns = [{}, {}]
    ignored_patterns = []
    for key, sps in config.sp.items():
        mod_name = key.split('/', 1)[0]
        if mod_name.lower() not in [m.lower() for m in run_module_names]:
            ignored_patterns.append(key)
            continue
        files[key] = list()
        if not isinstance(sps, list):
            sps = [sps]

        # Warn if we have any unrecognised search pattern keys
        expected_sp_keys = [
            'fn',
            'fn_re',
            'contents',
            'contents_re',
            'num_lines',
            'shared',
            'max_filesize',
            'exclude_fn',
            'exclude_fn_re',
            'exclude_contents',
            'exclude_contents_re'
        ]
        unrecognised_keys = [y for x in sps for y in x.keys() if y not in expected_sp_keys]
        if len(unrecognised_keys) > 0:
            logger.warn("Unrecognised search pattern keys for '{}': {}".format(key, ', '.join(unrecognised_keys)))

        # Split search patterns according to speed of execution.
        if any([x for x in sps if 'contents_re' in x]):
            if any([x for x in sps if 'num_lines' in x]):
                spatterns[4][key] = sps
            elif any([x for x in sps if 'max_filesize' in x]):
                spatterns[5][key] = sps
            else:
                spatterns[6][key] = sps
        elif any([x for x in sps if 'contents' in x]):
            if any([x for x in sps if 'num_lines' in x]):
                spatterns[1][key] = sps
            elif any([x for x in sps if 'max_filesize' in x]):
                spatterns[2][key] = sps
            else:
                spatterns[3][key] = sps
        else:
            spatterns[0][key] = sps

    if len(ignored_patterns) > 0:
        logger.debug("Ignored {} search patterns as didn't match running modules.".format(len(ignored_patterns)))

    def add_file(fn, root):
        """
        Function applied to each file found when walking the analysis
        directories. Runs through all search patterns and returns True
        if a match is found.
        """
        f = {'fn': fn, 'root': root}

        # Check that this is a file and not a pipe or anything weird
        if not os.path.isfile(os.path.join(root, fn)):
            return None

        # Check that we don't want to ignore this file
        i_matches = [n for n in config.fn_ignore_files if fnmatch.fnmatch(fn, n)]
        if len(i_matches) > 0:
            logger.debug("Ignoring file as matched an ignore pattern: {}".format(fn))
            return None

        # Limit search to small files, to avoid 30GB FastQ files etc.
        try:
            f['filesize'] = os.path.getsize(os.path.join(root,fn))
        except (IOError, OSError, ValueError, UnicodeDecodeError):
            logger.debug("Couldn't read file when checking filesize: {}".format(fn))
        else:
            if f['filesize'] > config.log_filesize_limit:
                return False

        # Test file for each search pattern
        for patterns in spatterns:
            for key, sps in patterns.items():
                for sp in sps:
                    if search_file (sp, f):
                        # Check that we shouldn't exclude this file
                        if not exclude_file(sp, f):
                            # Looks good! Remember this file
                            files[key].append(f)
                        # Don't keep searching this file for other modules
                        if not sp.get('shared', False):
                            return
                        # Don't look at other patterns for this module
                        else:
                            break

    # Go through the analysis directories and get file list
    for path in config.analysis_dir:
        if os.path.islink(path) and config.ignore_symlinks:
            continue
        elif os.path.isfile(path):
            searchfiles.append([os.path.basename(path), os.path.dirname(path)])
        elif os.path.isdir(path):
            for root, dirnames, filenames in os.walk(path, followlinks=(not config.ignore_symlinks), topdown=True):
                bname = os.path.basename(root)

                # Skip any sub-directories matching ignore params
                orig_dirnames = dirnames[:]
                for n in config.fn_ignore_dirs:
                    dirnames[:] = [d for d in dirnames if not fnmatch.fnmatch(d, n.rstrip(os.sep))]
                    if len(orig_dirnames) != len(dirnames):
                        removed_dirs = [os.path.join(root, d) for d in set(orig_dirnames).symmetric_difference(set(dirnames))]
                        logger.debug("Ignoring directory as matched fn_ignore_dirs: {}".format(", ".join(removed_dirs)))
                        orig_dirnames = dirnames[:]
                for n in config.fn_ignore_paths:
                    dirnames[:] = [d for d in dirnames if not fnmatch.fnmatch(os.path.join(root, d), n.rstrip(os.sep))]
                    if len(orig_dirnames) != len(dirnames):
                        removed_dirs = [os.path.join(root, d) for d in set(orig_dirnames).symmetric_difference(set(dirnames))]
                        logger.debug("Ignoring directory as matched fn_ignore_paths: {}".format(", ".join(removed_dirs)))

                # Skip *this* directory if matches ignore params
                d_matches = [n for n in config.fn_ignore_dirs if fnmatch.fnmatch(bname, n.rstrip(os.sep))]
                if len(d_matches) > 0:
                    logger.debug("Ignoring directory as matched fn_ignore_dirs: {}".format(bname))
                    continue
                p_matches = [n for n in config.fn_ignore_paths if fnmatch.fnmatch(root, n.rstrip(os.sep))]
                if len(p_matches) > 0:
                    logger.debug("Ignoring directory as matched fn_ignore_paths: {}".format(root))
                    continue
                # Search filenames in this directory
                for fn in filenames:
                    searchfiles.append([fn, root])
    # Search through collected files
    with click.progressbar(searchfiles, label="Searching {} files..".format(len(searchfiles))) as sfiles:
        for sf in sfiles:
            add_file(sf[0], sf[1])
196406
def load_hook_files(pathname):
    
    global hooks

    if sys.version_info[0] > 2 and sys.version_info[1] > 4:
        fsglob = sorted(glob.iglob(pathname, recursive=True))
    else:
        fsglob = sorted(glob.iglob(pathname))

    for path in fsglob:
        real_path = os.path.realpath(path)
        # Append hooks file directory to the sys.path so submodules can be
        # loaded too.
        if os.path.dirname(real_path) not in sys.path:
            sys.path.append(os.path.dirname(real_path))
        module = imp.load_source(os.path.basename(path), real_path)
        for name in dir(module):
            obj = getattr(module, name)
            if hasattr(obj, 'dredd_hooks') and callable(obj):
                func_hooks = getattr(obj, 'dredd_hooks')
                for hook, name in func_hooks:
                    if hook == BEFORE_ALL:
                        hooks._before_all.append(obj)
                    if hook == AFTER_ALL:
                        hooks._after_all.append(obj)
                    if hook == BEFORE_EACH:
                        hooks._before_each.append(obj)
                    if hook == AFTER_EACH:
                        hooks._after_each.append(obj)
                    if hook == BEFORE_EACH_VALIDATION:
                        hooks._before_each_validation.append(obj)
                    if hook == BEFORE_VALIDATION:
                        add_named_hook(hooks._before_validation, obj, name)
                    if hook == BEFORE:
                        add_named_hook(hooks._before, obj, name)
                    if hook == AFTER:
                        add_named_hook(hooks._after, obj, name)
1321321
function (workingDirectory) {
        var gitPath = getClosestGitPath(workingDirectory);

        if (!gitPath) {
            throw new Error('git-hooks must be run inside a git repository');
        }

        var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
        var hooksOldPath = path.resolve(gitPath, HOOKS_OLD_DIRNAME);

        if (!fsHelpers.exists(hooksPath)) {
            throw new Error('git-hooks is not installed');
        }

        fsHelpers.removeDir(hooksPath);

        if (fsHelpers.exists(hooksOldPath)) {
            fs.renameSync(hooksOldPath, hooksPath);
        }
    }
933697
def get_open_filenames(self):
        """"""
        editorstack = self.editorstacks[0]
        filenames = []
        filenames += [finfo.filename for finfo in editorstack.data]
        return filenames
478263
def getCodeBlocks():
    """"""
    raw=open("examples.py").read()
    d={}
    for block in raw.split("if __name__")[0].split("\ndef "):
        title=block.split("\n")[0].split("(")[0]
        if not title.startswith("demo_"):
            continue
        code=[x[4:] for x in block.split("\n")[1:] if x.startswith("    ")]
        d[title]="\n".join(code).strip()
    return d
966789
def _run_hooks(config, hooks, args, environ):
    """"""
    skips = _get_skips(environ)
    cols = _compute_cols(hooks, args.verbose)
    filenames = _all_filenames(args)
    filenames = filter_by_include_exclude(filenames, '', config['exclude'])
    classifier = Classifier(filenames)
    retval = 0
    for hook in hooks:
        retval |= _run_single_hook(classifier, hook, args, skips, cols)
        if retval and config['fail_fast']:
            break
    if retval and args.show_diff_on_failure and git.has_diff():
        if args.all_files:
            output.write_line(
                'pre-commit hook(s) made changes.\n'
                'If you are seeing this message in CI, '
                'reproduce locally with: `pre-commit run --all-files`.\n'
                'To run `pre-commit` as part of git workflow, use '
                '`pre-commit install`.',
            )
        output.write_line('All changes made by hooks:')
        subprocess.call(('git', '--no-pager', 'diff', '--no-ext-diff'))
    return retval
540299
def get_recent_files(self):
        """"""
        try:
            recent_files = self.CONF[WORKSPACE].get('main', 'recent_files',
                                                    default=[])
        except EnvironmentError:
            return []

        for recent_file in recent_files[:]:
            if not os.path.isfile(recent_file):
                recent_files.remove(recent_file)
        return list(OrderedDict.fromkeys(recent_files))
909858
public function listHookFiles() {
    $directory = $this->environment->getHooksDirectory();

    $files = array();

    // No need to verify $directory; our sanity check has taken care of it.
    $dh = opendir($directory);
    while (($file = readdir($dh)) !== FALSE) {
      // Ignore files that don't make sense to include.
      // System files and cruft.
      // TODO: replace all the .foo with one of the arcane PHP string checking functions
      if (in_array($file, array('.', '..', '.DS_Store', 'CVS', 'hooks_processed.php'))) {
        continue;
      }
      // Our own processed files.
      if (strpos($file, '_processed.php')) {
        continue;
      }

      $files[] = $file;
    }
    closedir($dh);

    return $files;
  }
230178
function(code) {
    var modules = [];

    var lex = Espruino.Core.Utils.getLexer(code);
    var tok = lex.next();
    var state = 0;
    while (tok!==undefined) {
      if (state==0 && tok.str=="require") {
        state=1;
      } else if (state==1 && tok.str=="(") {
        state=2;
      } else if (state==2 && (tok.type=="STRING")) {
        state=0;
        var module = tok.value;
        if (!isBuiltIn(module) && modules.indexOf(module)<0)
          modules.push(module);
      } else
        state = 0;
      tok = lex.next();
    }

    return modules;
  }
758802
private List<StackLine> getCodeLineHookedStackLines(
            final String hookedMethodSimpleName, final String actualHookedMethodSimpleName,
            final int hookedLine, final int actualHookedLine) {
        // this replacer replaces method name and line to the actual hooked method name and line
        LineReplacer replacer = new LineReplacer() {

            @Override
            public void replace(String classQualifiedName, String methodSimpleName, int line) {
                super.replace(classQualifiedName, methodSimpleName, line);
                // replacing root method name
                if (StringUtils.equals(methodSimpleName, currentActualRootMethodSimpleName)) {
                    replaceMethodSimpleName(currentRunResult.getRootMethod().getSimpleName());
                }
                // replacing hooked method name and line number
                if (StringUtils.equals(methodSimpleName, actualHookedMethodSimpleName)
                        && (line == actualHookedLine)) {
                    replaceMethodSimpleName(hookedMethodSimpleName);
                    replaceLine(hookedLine);
                }
            }
        };

        List<StackLine> result = StackLineUtils.getStackLines(
                srcTree, Thread.currentThread().getStackTrace(), replacer);
        assert result.size() > 0;
        return result;
    }
1300382
def get_hook_names(job, hook_method_prefix)
      methods = (job.respond_to?(:hooks) && job.hooks) || job_methods(job)
      methods.select{|m| m.start_with?(hook_method_prefix)}.sort
    end
570087
public function collect($job_list) {
    $hook_files = $this->gatherHookDocumentationFiles($job_list);

    // Copy the hook files to the hooks directory.
    // This is done after the files have been gathered, so when gathering
    // sample data for tests the filtered files only are written.
    foreach ($hook_files as $file_info) {
      copy($file_info['original'], $file_info['path']);
    }

    // Process the hook files into a single array for storage.
    $processed_hook_data = $this->processHookData($hook_files);

    return $processed_hook_data;
  }
880763
def executed_block_set(trace):
    
    executed_set = set()
    for entry in trace:
        if entry[0] == 'execute':
            executed_set.add(entry[get_trace_index('execute', 'BLOCK_NAME')])
    return executed_set
1283297
function listHookData() {
    // We may come here several times, so cache this.
    if (!empty($this->hook_data)) {
      return $this->hook_data;
    }

    $this->hook_data = $this->environment->getStorage()->retrieve('hooks');
    return $this->hook_data;
  }
224493
public function batchRun($is_hook, $method_name, array $params = NULL)
    {
        // Prevents annoying notices.
		if($params == NULL) {
			$params = array();
		}

        // We collect the results into an array.
        $results = array();
        if(!$this->modules) $this->modules = array();
        foreach($this->modules as $name => $module) {
            if(method_exists($module, $method_name)) {
                $result = call_user_func_array(array($module, $method_name), $params);
                if($is_hook) { // Hooks are pre-emptive if they return something.
                    if($result) {
                        return $result;
                    }
                } else { // Collecting
                    $results[$name] = $result;
                }
            }
		}

        return $is_hook? false : $results;
    }
1253714
private Set<ExecutableElement> getHookMethodsFromInterfaces() {
    return component
        .getInterfaces()
        .stream()
        .map(DeclaredType.class::cast)
        .map(DeclaredType::asElement)
        .map(TypeElement.class::cast)
        .flatMap(typeElement -> ElementFilter
            .methodsIn(typeElement.getEnclosedElements())
            .stream())
        .filter(method -> hasAnnotation(method, HookMethod.class))
        .peek(this::validateHookMethod)
        .collect(Collectors.toSet());
  }