def get_icons_for_building(icomoon_json_path: str, devicon_json_path: str, token: str, logfile: FileIO): """ Get the icons for building. :param icomoon_json_path - the path to the `icomoon.json`. :param devicon_json_path - the path to the `devicon.json`. :param token - the token to access the GitHub API. :param logfile. :return a list of dict containing info on the icons. These are from the `devicon.json`. """ devicon_json = filehandler.get_json_file_content(devicon_json_path) pull_reqs = api_handler.get_merged_pull_reqs_since_last_release(token, logfile) new_icons = [] for pull_req in pull_reqs: if api_handler.is_feature_icon(pull_req): filtered_icon = util.find_object_added_in_pr(devicon_json, pull_req["title"]) if filtered_icon not in new_icons: new_icons.append(filtered_icon) # get any icons that might not have been found by the API # sometimes happen due to the PR being opened before the latest build release new_icons_from_devicon_json = filehandler.find_new_icons_in_devicon_json( devicon_json_path, icomoon_json_path) for icon in new_icons_from_devicon_json: if icon not in new_icons: new_icons.append(icon) return new_icons
def get_release_message(token, logfile: FileIO): """ Get the release message for the latest build and write the result in a file. :param token: the GitHub API token to access the API. """ # fetch first page by default data = api_handler.get_merged_pull_reqs_since_last_release(token, logfile) newIcons = [] features = [] print("Parsing through the pull requests...", file=logfile) for pullData in data: authors = api_handler.find_all_authors(pullData, token) markdown = f"- [{pullData['title']}]({pullData['html_url']}) by {authors}." if api_handler.is_feature_icon(pullData): newIcons.append(markdown) else: features.append(markdown) print("Constructing message...", file=logfile) thankYou = "A huge thanks to all our maintainers and contributors for making this release possible!" iconTitle = f"**{len(newIcons)} New Icons**" featureTitle = f"**{len(features)} New Features**" finalString = "{0}\n\n {1}\n{2}\n\n {3}\n{4}".format(thankYou, iconTitle, "\n".join(newIcons), featureTitle, "\n".join(features)) print("--------------Here is the build message--------------\n", finalString, file=logfile) release_message_path = "./release_message.txt" filehandler.write_to_file(release_message_path, finalString) print("Script finished", file=logfile)
def main(): try: print("Please wait a few seconds...") args = arg_getters.get_release_message_args() # fetch first page by default data = api_handler.get_merged_pull_reqs_since_last_release(args.token) newIcons = [] features = [] print("Parsing through the pull requests") for pullData in data: authors = api_handler.find_all_authors(pullData, args.token) markdown = f"- [{pullData['title']}]({pullData['html_url']}) by {authors}." if api_handler.is_feature_icon(pullData): newIcons.append(markdown) else: features.append(markdown) print("Constructing message") thankYou = "A huge thanks to all our maintainers and contributors for making this release possible!" iconTitle = f"**{len(newIcons)} New Icons**" featureTitle = f"**{len(features)} New Features**" finalString = "{0}\n\n {1}\n{2}\n\n {3}\n{4}".format( thankYou, iconTitle, "\n".join(newIcons), featureTitle, "\n".join(features)) print("--------------Here is the build message--------------\n", finalString) print("Script finished") except Exception as e: util.exit_with_err(e)
def get_icons_for_building(devicon_json_path: str, token: str): """ Get the icons for building. :param devicon_json_path - the path to the `devicon.json`. :param token - the token to access the GitHub API. """ all_icons = filehandler.get_json_file_content(devicon_json_path) pull_reqs = api_handler.get_merged_pull_reqs_since_last_release(token) new_icons = [] for pull_req in pull_reqs: if api_handler.is_feature_icon(pull_req): filtered_icon = util.find_object_added_in_this_pr( all_icons, pull_req["title"]) if filtered_icon not in new_icons: new_icons.append(filtered_icon) return new_icons