mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
changes for freezing first row of excel and allowing dynamic location of language updates file
This commit is contained in:
parent
3f4a4a15fd
commit
8c56f4a305
@ -37,6 +37,9 @@ def main():
|
|||||||
parser.add_argument('-l', '--language', dest='language', type=str, default=None, required=False,
|
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 '
|
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.')
|
'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,
|
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.")
|
required=False, help="Don't include a column for translation.")
|
||||||
@ -47,10 +50,11 @@ def main():
|
|||||||
commit_1_id = args.commit_1_id
|
commit_1_id = args.commit_1_id
|
||||||
output_type = args.output_type
|
output_type = args.output_type
|
||||||
show_translated_col = not args.no_translated_col
|
show_translated_col = not args.no_translated_col
|
||||||
|
language_updates_file = args.language_file
|
||||||
|
|
||||||
lang = args.language
|
lang = args.language
|
||||||
if lang is not None:
|
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:
|
if commit_1_id is None:
|
||||||
print('Either the first commit or language flag need to be specified. If specified, the language file, ' +
|
print('Either the first commit or language flag need to be specified. If specified, the language file, ' +
|
||||||
|
@ -63,6 +63,9 @@ def write_results_to_xlsx(results: OutputResult, output_path: str):
|
|||||||
|
|
||||||
for sheet_name, values in workbook.items():
|
for sheet_name, values in workbook.items():
|
||||||
sheet = wb_file.add_worksheet(name=sheet_name)
|
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)):
|
for col_idx in range(0, len(styles)):
|
||||||
if styles[col_idx]:
|
if styles[col_idx]:
|
||||||
col_format, width = styles[col_idx]
|
col_format, width = styles[col_idx]
|
||||||
|
@ -13,12 +13,25 @@ def _get_last_update_key(language: str) -> str:
|
|||||||
return "bundles.{lang}.lastupdated".format(lang=language)
|
return "bundles.{lang}.lastupdated".format(lang=language)
|
||||||
|
|
||||||
|
|
||||||
def _get_props_path():
|
def _get_props_path(language_updates_file: Union[str, None]):
|
||||||
return path.join(get_proj_dir(), LANG_FILENAME)
|
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]:
|
def get_commit_for_language(language: str, language_updates_file: Union[str, None] = None) -> Union[str, None]:
|
||||||
lang_dict = get_entry_dict_from_path(_get_props_path())
|
"""
|
||||||
|
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:
|
if lang_dict is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -29,6 +42,15 @@ def get_commit_for_language(language: str) -> Union[str, None]:
|
|||||||
return lang_dict[key]
|
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)
|
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))
|
||||||
|
@ -14,12 +14,14 @@ class OutputResult:
|
|||||||
Describes a result that is ready to be written to file(s).
|
Describes a result that is ready to be written to file(s).
|
||||||
"""
|
"""
|
||||||
column_styles: List[ColumnStyle]
|
column_styles: List[ColumnStyle]
|
||||||
|
freeze_first_row: bool
|
||||||
results: List[List[str]]
|
results: List[List[str]]
|
||||||
omitted: Union[List[List[str]], None]
|
omitted: Union[List[List[str]], None]
|
||||||
deleted: 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,
|
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.
|
Constructs a ProcessingResult.
|
||||||
Args:
|
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
|
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].
|
located within result at results[row][col].
|
||||||
style: Style for each column. No column formatting will happen for null.
|
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.results = results
|
||||||
self.omitted = omitted
|
self.omitted = omitted
|
||||||
self.deleted = deleted
|
self.deleted = deleted
|
||||||
self.column_styles = style
|
self.column_styles = style
|
||||||
|
self.freeze_first_row = freeze_first_row
|
||||||
|
@ -325,6 +325,9 @@ def main():
|
|||||||
parser.add_argument('-l', '--language', dest='language', type=str, default=None, required=False,
|
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 '
|
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.')
|
'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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -378,7 +381,7 @@ def main():
|
|||||||
|
|
||||||
# update the language last update if applicable
|
# update the language last update if applicable
|
||||||
if args.language and header is not None and len(header) > args.latest_commit_idx >= 0:
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user