maintainers.py 645 B

12345678910111213141516171819202122
  1. from pathlib import Path
  2. from qmk.json_schema import json_load
  3. def maintainers(file):
  4. """Yields maintainers for a file.
  5. """
  6. maintainers = 'qmk'
  7. file_dir = file if file.is_dir() else file.parent
  8. cur_path = Path('.')
  9. for path_part in file_dir.parts:
  10. cur_path = cur_path / path_part
  11. info_file = cur_path / 'info.json'
  12. if info_file.exists():
  13. new_info_data = json_load(info_file)
  14. maintainers = new_info_data.get('maintainer', maintainers)
  15. for maintainer in maintainers.replace(',', ' ').split():
  16. yield 'qmk/collaborators' if maintainer == 'qmk' else maintainer