def get_custom_subject()

in ghd-notifier.py [0:0]


def get_custom_subject(repository, action="catchall"):
    """Gets a subject template for a specific action, if specified via .asf.yaml"""
    gh_settings_path = os.path.join(GHSETTINGS_ROOT, f"ghsettings.{repository}.yml")  # Path to github settings yaml file
    if os.path.isfile(gh_settings_path):
        try:
            yml = yaml.safe_load(open(gh_settings_path))
        except yaml.parser.ParserError:  # Invalid YAML?!
            return
        custom_subjects = yml.get("custom_subjects")
        if custom_subjects and isinstance(custom_subjects, dict):
            if action in custom_subjects:
                return custom_subjects[action]
            elif "catchall_discussions" in custom_subjects:  # If no custom subject exists for this action, but catchall does...
                return custom_subjects["catchall_discussions"]