| 129 | |
| 130 | |
| 131 | def find_modules(): |
| 132 | modules = [] |
| 133 | for module_path in SOURCE_DIR.glob("**/*.py"): |
| 134 | # Determine the (dotted) relative package and module names. |
| 135 | package_path = module_path.parent.relative_to(PYTHON_DIR) |
| 136 | if package_path == SOURCE_DIR: |
| 137 | package_name = "" |
| 138 | module_name = module_path.stem |
| 139 | else: |
| 140 | package_name = package_path.as_posix().replace("/", ".") |
| 141 | module_name = package_name + "." + module_path.stem |
| 142 | |
| 143 | # Filter: first, accept anything in the whitelist; then, reject anything |
| 144 | # at package level, then module name level. |
| 145 | if any(include == module_name for include in INCLUDED_MODULES): |
| 146 | pass |
| 147 | elif any(ignored in package_name for ignored in IGNORED_PACKAGES): |
| 148 | continue |
| 149 | elif any(ignored in module_path.stem for ignored in IGNORED_MODULES): |
| 150 | continue |
| 151 | |
| 152 | if module_path.name == "__init__.py": |
| 153 | modules.append(package_name) |
| 154 | else: |
| 155 | modules.append(module_name) |
| 156 | |
| 157 | return modules |
| 158 | |
| 159 | |
| 160 | def write_automodule(module): |