Generator yielding paths which contain the given key.
(
key: str,
paths: Sequence[str] = paths,
)
| 289 | |
| 290 | |
| 291 | def paths_containing_key( |
| 292 | key: str, |
| 293 | paths: Sequence[str] = paths, |
| 294 | ) -> Iterator[pathlib.Path]: |
| 295 | """ |
| 296 | Generator yielding paths which contain the given key. |
| 297 | """ |
| 298 | # Check existing config files for any which contains this key. |
| 299 | for path_ in paths: |
| 300 | for path, config in collect_yaml([path_], return_paths=True): |
| 301 | try: |
| 302 | get(key, config=config) |
| 303 | except KeyError: |
| 304 | continue |
| 305 | else: |
| 306 | yield pathlib.Path(path) |
| 307 | |
| 308 | |
| 309 | def ensure_file( |