diff --git a/release_scripts/localization_scripts/diffscript.py b/release_scripts/localization_scripts/diffscript.py index 9c980ea344..c2dc154b65 100644 --- a/release_scripts/localization_scripts/diffscript.py +++ b/release_scripts/localization_scripts/diffscript.py @@ -37,6 +37,9 @@ def main(): parser.add_argument('-l', '--language', dest='language', type=str, default=None, required=False, help='Specify the language in order to determine the first commit to use (i.e. \'ja\' for ' 'Japanese. This flag overrides the first-commit flag.') + parser.add_argument('-lf', '--language-updates-file', dest='language_file', type=str, default=None, required=False, + help='Specify the path to the properties file containing key value pairs of language mapped to ' + 'the commit of when bundles for that language were most recently updated.') parser.add_argument('-nt', '--no-translated-col', dest='no_translated_col', action='store_true', default=False, required=False, help="Don't include a column for translation.") @@ -47,10 +50,11 @@ def main(): commit_1_id = args.commit_1_id output_type = args.output_type show_translated_col = not args.no_translated_col + language_updates_file = args.language_file lang = args.language if lang is not None: - commit_1_id = get_commit_for_language(lang) + commit_1_id = get_commit_for_language(lang, language_updates_file) if commit_1_id is None: print('Either the first commit or language flag need to be specified. If specified, the language file, ' + diff --git a/release_scripts/localization_scripts/excelutil.py b/release_scripts/localization_scripts/excelutil.py index dbbdceb844..460006ec16 100644 --- a/release_scripts/localization_scripts/excelutil.py +++ b/release_scripts/localization_scripts/excelutil.py @@ -63,6 +63,9 @@ def write_results_to_xlsx(results: OutputResult, output_path: str): for sheet_name, values in workbook.items(): sheet = wb_file.add_worksheet(name=sheet_name) + if results.freeze_first_row: + sheet.freeze_panes(1, 0) + for col_idx in range(0, len(styles)): if styles[col_idx]: col_format, width = styles[col_idx] diff --git a/release_scripts/localization_scripts/langpropsutil.py b/release_scripts/localization_scripts/langpropsutil.py index 841574c9e9..463f570cc0 100644 --- a/release_scripts/localization_scripts/langpropsutil.py +++ b/release_scripts/localization_scripts/langpropsutil.py @@ -13,12 +13,25 @@ def _get_last_update_key(language: str) -> str: return "bundles.{lang}.lastupdated".format(lang=language) -def _get_props_path(): - return path.join(get_proj_dir(), LANG_FILENAME) +def _get_props_path(language_updates_file: Union[str, None]): + if language_updates_file: + return language_updates_file + else: + return path.join(get_proj_dir(), LANG_FILENAME) -def get_commit_for_language(language: str) -> Union[str, None]: - lang_dict = get_entry_dict_from_path(_get_props_path()) +def get_commit_for_language(language: str, language_updates_file: Union[str, None] = None) -> Union[str, None]: + """ + Retrieves the latest commit for a particular language. + Args: + language: The language key. + language_updates_file: The file containing the most recent updates. If not provided, the default file located + in the same directory as the running script is used. + + Returns: The most recent commit that the particular language has been updated or None if no key exists. + + """ + lang_dict = get_entry_dict_from_path(_get_props_path(language_updates_file)) if lang_dict is None: return None @@ -29,6 +42,15 @@ def get_commit_for_language(language: str) -> Union[str, None]: return lang_dict[key] -def set_commit_for_language(language: str, latest_commit: str): +def set_commit_for_language(language: str, latest_commit: str, language_updates_file: Union[str, None] = None): + """ + Sets the most recent update for a language within the language updates file. + Args: + language: The language key. + latest_commit: The commit for how recent the language is. + language_updates_file: The file containing the most recent updates. If not provided, the default file located + in the same directory as the running script is used. + + """ key = _get_last_update_key(language) - update_entry_dict({key: latest_commit}, _get_props_path()) + update_entry_dict({key: latest_commit}, _get_props_path(language_updates_file)) diff --git a/release_scripts/localization_scripts/outputresult.py b/release_scripts/localization_scripts/outputresult.py index 7d806b8f0d..a5169eede1 100644 --- a/release_scripts/localization_scripts/outputresult.py +++ b/release_scripts/localization_scripts/outputresult.py @@ -14,12 +14,14 @@ class OutputResult: Describes a result that is ready to be written to file(s). """ column_styles: List[ColumnStyle] + freeze_first_row: bool results: List[List[str]] omitted: Union[List[List[str]], None] deleted: Union[List[List[str]], None] def __init__(self, results: List[List[str]], omitted: Union[List[List[str]], None] = None, - deleted: Union[List[List[str]], None] = None, style: Union[List[ColumnStyle], None] = None): + deleted: Union[List[List[str]], None] = None, style: Union[List[ColumnStyle], None] = None, + freeze_first_row: bool = True): """ Constructs a ProcessingResult. Args: @@ -30,9 +32,11 @@ class OutputResult: deleted: Items to be written as omitted. Data will be written such that the item at row,cell will be located within result at results[row][col]. style: Style for each column. No column formatting will happen for null. + freeze_first_row: Whether or not first row should be frozen. """ self.results = results self.omitted = omitted self.deleted = deleted self.column_styles = style + self.freeze_first_row = freeze_first_row diff --git a/release_scripts/localization_scripts/updatepropsscript.py b/release_scripts/localization_scripts/updatepropsscript.py index 06a23b7cba..0ee1fcc172 100644 --- a/release_scripts/localization_scripts/updatepropsscript.py +++ b/release_scripts/localization_scripts/updatepropsscript.py @@ -325,6 +325,9 @@ def main(): parser.add_argument('-l', '--language', dest='language', type=str, default=None, required=False, help='Specify the language in order to update the last updated properties file and rename ' 'files within directories. This flag overrides the file-rename flag.') + parser.add_argument('-lf', '--language-updates-file', dest='language_file', type=str, default=None, required=False, + help='Specify the path to the properties file containing key value pairs of language mapped to ' + 'the commit of when bundles for that language were most recently updated.') args = parser.parse_args() @@ -378,7 +381,7 @@ def main(): # update the language last update if applicable if args.language and header is not None and len(header) > args.latest_commit_idx >= 0: - set_commit_for_language(args.language, header[args.latest_commit_idx]) + set_commit_for_language(args.language, header[args.latest_commit_idx], args.language_file) sys.exit(0)