How to use the identify.identify.tags_from_path function in identify

To help you get started, we’ve selected a few identify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asottile / all-repos / all_repos / sed.py View on Github external
def apply_fix(
        *,
        ls_files_cmd: Sequence[str],
        sed_cmd: Sequence[str],
) -> None:
    filenames_b = zsplit(subprocess.check_output(ls_files_cmd))
    filenames = [f.decode() for f in filenames_b]
    filenames = [f for f in filenames if tags_from_path(f) & {'file', 'text'}]
    autofix_lib.run(*sed_cmd, *filenames)
github asottile / dead / dead.py View on Github external
def _filenames(
        files_re: Pattern[str],
        exclude_re: Pattern[str],
        tests_re: Pattern[str],
) -> Generator[Tuple[str, bool], None, None]:
    # TODO: zsplit is more correct than splitlines
    out = subprocess.check_output(('git', 'ls-files')).decode()
    for filename in out.splitlines():
        if (
                not files_re.search(filename) or
                exclude_re.search(filename) or
                'python' not in tags_from_path(filename)
        ):
            continue

        yield filename, bool(tests_re.search(filename))
github pre-commit / pre-commit / pre_commit / commands / run.py View on Github external
def _types_for_file(self, filename):
        try:
            return self._types_cache[filename]
        except KeyError:
            ret = self._types_cache[filename] = tags_from_path(filename)
            return ret