diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 30246bd17f..0e62c1de77 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -84,13 +84,32 @@ aliases_by_board = { "pewpew10": ["pewpew13"], } +language_allow_list = set([ + "ID", + "de_DE", + "en_US", + "en_x_pirate", + "es", + "fil", + "fr", + "it_IT", + "ja", + "nl", + "pl", + "pt_BR", + "sv", + "zh_Latn_pinyin", +]) -def get_languages(): - languages = [] + +def get_languages(list_all = False): + languages = set() for f in os.scandir("../locale"): if f.name.endswith(".po"): - languages.append(f.name[:-3]) - return languages + languages.add(f.name[:-3]) + if not list_all: + languages = languages & language_allow_list + return sorted(list(languages), key = lambda s: s.casefold()) def get_board_mapping(): @@ -163,10 +182,7 @@ def get_current_info(): return git_info, current_info -def create_pr(changes, updated, git_info, user): - commit_sha, original_blob_sha = git_info - branch_name = "new_release_" + changes["new_release"] - +def create_json(updated): # Convert the dictionary to a list of boards. Liquid templates only handle arrays. updated_list = [] all_ids = sorted(updated.keys()) @@ -174,9 +190,15 @@ def create_pr(changes, updated, git_info, user): info = updated[id] info["id"] = id updated_list.append(info) + return json.dumps(updated_list, sort_keys=True, indent=1).encode("utf-8") + b"\n" - updated = json.dumps(updated_list, sort_keys=True, indent=1).encode("utf-8") + b"\n" + +def create_pr(changes, updated, git_info, user): + commit_sha, original_blob_sha = git_info + branch_name = "new_release_" + changes["new_release"] + updated = create_json(updated) # print(updated.decode("utf-8")) + pr_title = "Automated website update for release {}".format(changes["new_release"]) boards = "" if changes["new_boards"]: @@ -302,6 +324,7 @@ def generate_download_info(): create_pr(changes, current_info, git_info, user) else: print("No new release to update") + # print(create_json(current_info).decode("utf8")) if __name__ == "__main__": diff --git a/tools/build_release_files.py b/tools/build_release_files.py index 4e22e97254..68aa45f0a0 100755 --- a/tools/build_release_files.py +++ b/tools/build_release_files.py @@ -27,23 +27,10 @@ if "BOARDS" in os.environ: sha, version = build_info.get_version_info() languages = build_info.get_languages() -language_allow_list = [ - "ID", - "de_DE", - "en_US", - "en_x_pirate", - "es", - "fil", - "fr", - "it_IT", - "ja", - "nl", - "pl", - "pt_BR", - "sv", - "zh_Latn_pinyin", -] -print("Note: Not building languages", set(languages) - set(language_allow_list)) + +all_languages = build_info.get_languages(list_all=True) + +print("Note: Not building languages", set(all_languages) - set(languages)) exit_status = 0 cores = multiprocessing.cpu_count() @@ -53,7 +40,7 @@ for board in build_boards: os.makedirs(bin_directory, exist_ok=True) board_info = all_boards[board] - for language in language_allow_list: + for language in languages: bin_directory = "../bin/{board}/{language}".format(board=board, language=language) os.makedirs(bin_directory, exist_ok=True) start_time = time.monotonic()