Prevent "File listed twice" warning with %lang files outside of Python modules

This commit is contained in:
Miro Hrončok 2020-09-04 18:21:40 +02:00 committed by churchyard
parent b4fd1c2e74
commit c1d5d64f8c
2 changed files with 9 additions and 17 deletions

View File

@ -165,21 +165,26 @@ def add_file_to_module(paths, module_name, module_type, *files):
{"type": module_type, "files": list(files)} {"type": module_type, "files": list(files)}
) )
def add_lang_to_module(paths, module_name, path): def add_lang_to_module(paths, module_name, path):
""" """
Helper procedure, divides lang files by language and adds them to the module_name Helper procedure, divides lang files by language and adds them to the module_name
Returns True if the language code detection was successful
""" """
for i, parent in enumerate(path.parents): for i, parent in enumerate(path.parents):
if i > 0 and parent.name == 'locale': if i > 0 and parent.name == 'locale':
lang_country_code = path.parents[i-1].name lang_country_code = path.parents[i-1].name
break break
else: else:
return return False
# convert potential en_US to plain en # convert potential en_US to plain en
lang_code = lang_country_code.partition('_')[0] lang_code = lang_country_code.partition('_')[0]
if module_name not in paths["lang"]: if module_name not in paths["lang"]:
paths["lang"].update({module_name: defaultdict(list)}) paths["lang"].update({module_name: defaultdict(list)})
paths["lang"][module_name][lang_code].append(path) paths["lang"][module_name][lang_code].append(path)
return True
def classify_paths( def classify_paths(
record_path, parsed_record_content, sitedirs, python_version record_path, parsed_record_content, sitedirs, python_version
@ -242,9 +247,10 @@ def classify_paths(
break break
else: else:
warnings.warn(f"Unrecognized file: {path}") warnings.warn(f"Unrecognized file: {path}")
paths["other"]["files"].append(path)
if path.suffix == ".mo": if path.suffix == ".mo":
add_lang_to_module(paths, None, path) add_lang_to_module(paths, None, path) or paths["other"]["files"].append(path)
else:
paths["other"]["files"].append(path)
return paths return paths

View File

@ -1473,13 +1473,6 @@ classified:
- /usr/share/pronterface/reset.png - /usr/share/pronterface/reset.png
- /usr/share/pronterface/zoom_in.png - /usr/share/pronterface/zoom_in.png
- /usr/share/pronterface/zoom_out.png - /usr/share/pronterface/zoom_out.png
- /usr/share/locale/de/LC_MESSAGES/plater.mo
- /usr/share/locale/de/LC_MESSAGES/pronterface.mo
- /usr/share/locale/fr/LC_MESSAGES/plater.mo
- /usr/share/locale/fr/LC_MESSAGES/pronterface.mo
- /usr/share/locale/it/LC_MESSAGES/plater.mo
- /usr/share/locale/it/LC_MESSAGES/pronterface.mo
- /usr/share/locale/nl/LC_MESSAGES/pronterface.mo
dumped: dumped:
- - tensorflow - - tensorflow
@ -2744,13 +2737,6 @@ dumped:
- /usr/share/applications/plater.desktop - /usr/share/applications/plater.desktop
- /usr/share/applications/pronsole.desktop - /usr/share/applications/pronsole.desktop
- /usr/share/applications/pronterface.desktop - /usr/share/applications/pronterface.desktop
- /usr/share/locale/de/LC_MESSAGES/plater.mo
- /usr/share/locale/de/LC_MESSAGES/pronterface.mo
- /usr/share/locale/fr/LC_MESSAGES/plater.mo
- /usr/share/locale/fr/LC_MESSAGES/pronterface.mo
- /usr/share/locale/it/LC_MESSAGES/plater.mo
- /usr/share/locale/it/LC_MESSAGES/pronterface.mo
- /usr/share/locale/nl/LC_MESSAGES/pronterface.mo
- /usr/share/metainfo/plater.appdata.xml - /usr/share/metainfo/plater.appdata.xml
- /usr/share/metainfo/pronsole.appdata.xml - /usr/share/metainfo/pronsole.appdata.xml
- /usr/share/metainfo/pronterface.appdata.xml - /usr/share/metainfo/pronterface.appdata.xml