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 / 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'}]*sed_cmd, *filenames)
github asottile / dead / 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 or
                'python' not in tags_from_path(filename)

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