跳转至

统计文件数量

概述

OpenSRE 统计属于你的项目的文件:你编写的模块,而不是放在它们旁边的编译缓存和 vendored 包。在交互式 shell(opensre)中提问:

How many test files are under tests/interactive_shell?
How many Python files does surfaces/interactive_shell have?
How many workflow files are in .github/workflows?

返回结果

用一句话给出数量、模式和目录:

103 files matching test_*.py under tests/interactive_shell, not counting
generated directories

最多返回二十个匹配路径作为示例。计数本身始终覆盖整棵树。

跳过的内容

内容属于生成、vendored 或版本控制记账的目录会被跳过:__pycache__、.venv、venv、site-packages、node_modules、build、dist、.git,以及 .mypy_cache、.pytest_cache、.ruff_cache 和 .tox 缓存。

不会跟随符号链接目录,因此指回上层的链接不会让计数失控。

不支持的操作

  • 统计 YAML、JSON 或 TOML 文件内部的条目属于另一个问题:参见结构化文件读取。
  • 搜索文件内容需使用 rg 的 shell 命令。
  • 列出每个文件名:你只能得到计数和少量示例。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 op/opensre