From 5c985139d3b7712f5538a0d2f445da523cb47b94 Mon Sep 17 00:00:00 2001 From: Nicolas Grosjean Date: Fri, 27 Sep 2024 16:36:40 +0200 Subject: [PATCH] Use poetry in CI --- .github/workflows/flake8_test_coverage.yml | 17 ++- README.md | 110 +++++++++--------- compile_update_paratranz.py | 2 +- copy_on_other_languages/README.txt | 2 +- .../add_missing_lines.py | 2 +- .../apply_diff.py | 2 +- .../apply_diff_all.py | 12 +- .../copy_on_other_languages.py | 0 .../download_paratranz.py | 0 .../extract_existing_translation.py | 2 +- .../extract_paratranz_translation.py | 2 +- .../get_duplicates_key.py | 2 +- .../read_localization_file.py | 0 .../update_paratranz.py | 17 ++- .../update_source.py | 0 {src => paradox-localization-utils}/utils.py | 0 tests/test_apply_diff.py | 2 +- tests/test_apply_diff_all.py | 2 +- tests/test_copy_on_other_languages.py | 2 +- tests/test_extract_existing_translation.py | 2 +- tests/test_extract_paratranz_translation.py | 2 +- tests/test_read_localization_file.py | 2 +- tests/test_update_paratranz.py | 4 +- 23 files changed, 98 insertions(+), 88 deletions(-) rename {src => paradox-localization-utils}/add_missing_lines.py (97%) rename {src => paradox-localization-utils}/apply_diff.py (97%) rename {src => paradox-localization-utils}/apply_diff_all.py (95%) rename {src => paradox-localization-utils}/copy_on_other_languages.py (100%) rename {src => paradox-localization-utils}/download_paratranz.py (100%) rename {src => paradox-localization-utils}/extract_existing_translation.py (97%) rename {src => paradox-localization-utils}/extract_paratranz_translation.py (96%) rename {src => paradox-localization-utils}/get_duplicates_key.py (92%) rename {src => paradox-localization-utils}/read_localization_file.py (100%) rename {src => paradox-localization-utils}/update_paratranz.py (83%) rename {src => paradox-localization-utils}/update_source.py (100%) rename {src => paradox-localization-utils}/utils.py (100%) diff --git a/.github/workflows/flake8_test_coverage.yml b/.github/workflows/flake8_test_coverage.yml index e14950e..d94f216 100644 --- a/.github/workflows/flake8_test_coverage.yml +++ b/.github/workflows/flake8_test_coverage.yml @@ -8,21 +8,18 @@ on: branches: [ master ] jobs: - build: - + ci: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest coverage genbadge[all] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Install poetry + uses: abatilo/actions-poetry@v3.0.0 + - name: Install the project dependencies + run: poetry install - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/README.md b/README.md index 42feb8b..3136138 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ # Paradox localization utils -> A set of tools to manipulate Paradox localization files particularly for translating +> A set of tools to manipulate Paradox localization files particularly for translating ## Terms -* Source: It refers to the source language of your translation -* Destination (shorten dest): It refers to the destination language of your translation +- Source: It refers to the source language of your translation +- Destination (shorten dest): It refers to the destination language of your translation Example : If I translate from English to French, the source directory refers to the directory of English localisation files. @@ -27,7 +27,7 @@ poetry install -Install pre-commit +Install pre-commit ```shell pre-commit install @@ -49,7 +49,7 @@ Activate the conda environment activate paradox_loc ``` -Install Levenshtein package (only needed for *apply_diff_all*) +Install Levenshtein package (only needed for _apply_diff_all_) ```shell conda install python-levenshtein @@ -61,7 +61,7 @@ OR pip install python-levenshtein ``` -Install pandas package (only needed for *extract_existing_translation*) +Install pandas package (only needed for _extract_existing_translation_) ```shell pip install pandas @@ -71,7 +71,7 @@ pip install pandas -Install pre-commit +Install pre-commit ```shell pip install pre-commit @@ -86,13 +86,13 @@ pre-commit install > It also copy in the parent of the target directory an extract of the source localization and all files in target_dir. ```shell -python src/update_source.py +python paradox-localization-utils/update_source.py ``` Example to update the English files of the HoI4 mod Kaiserreich ```shell -python src/update_source.py <...>\Steam\steamapps\workshop\content\394360\1521695605 <...>\GitHub\Traduction-FR-Kaiserreich\Traduction-FR-Kaiserreich english +python paradox-localization-utils/update_source.py <...>\Steam\steamapps\workshop\content\394360\1521695605 <...>\GitHub\Traduction-FR-Kaiserreich\Traduction-FR-Kaiserreich english ``` ### Update Paratranz @@ -104,13 +104,13 @@ Get your Paratranz API token in the settings tab of your Paratranz profile. Get the Paratranz project id by open the project and see the number in the url. ```shell -python src/update_paratranz.py +python paradox-localization-utils/update_paratranz.py ``` Example to update the RICE project (translation from English) on Paratranz ```shell -python src/update_paratranz.py 2617 <...>\GitHub\RICE-for-CK3\RICE\localization english +python paradox-localization-utils/update_paratranz.py 2617 <...>\GitHub\RICE-for-CK3\RICE\localization english ``` To compile the code, run the following command @@ -130,7 +130,7 @@ Get your Paratranz API token in the settings tab of your Paratranz profile. Get the Paratranz project id by open the project and see the number in the url. ```shell -python src/download_paratranz.py +python paradox-localization-utils/download_paratranz.py ``` ### Add missing lines @@ -140,28 +140,27 @@ python src/download_paratranz.py +python paradox-localization-utils/add_missing_lines.py ``` Example to add in French files missing lines from English files ```shell -python src/add_missing_lines.py "<...>\game\localization\english" "<...>\game\localization\french" +python paradox-localization-utils/add_missing_lines.py "<...>\game\localization\english" "<...>\game\localization\french" ``` #### For EUIV, HoI4 or Stellaris ```shell -python src/add_missing_lines.py -source_lang -dest_lang +python paradox-localization-utils/add_missing_lines.py -source_lang -dest_lang ``` Example to add in French files missing lines from English files ```shell -python src/add_missing_lines.py "<...>\localisation" "<...>\localisation" -source_lang english -dest_lang french +python paradox-localization-utils/add_missing_lines.py "<...>\localisation" "<...>\localisation" -source_lang english -dest_lang french ``` - ### Apply diff all > Apply the differences between an old source version and a current source version to your current destination files. @@ -169,32 +168,32 @@ python src/add_missing_lines.py "<...>\localisation" "<...>\localisation" -sourc #### For Imperator Rome and sooner, and new EUIV, HoI4 or Stellaris localisation format (a subdirectory for each language) ```shell -python src/apply_diff_all.py +python paradox-localization-utils/apply_diff_all.py ``` -* contains the localisation of the old source version -* contains the localisation of the new source version -* contains the localisation of the old destination version +- contains the localisation of the old source version +- contains the localisation of the new source version +- contains the localisation of the old destination version Example to apply in French files the modifications done in English ```shell -python src/apply_diff_all.py "<...>\V1\localisation\english" "<...>\V2\localisation\english" -dest_dir "<...>\V1\localisation\french" +python paradox-localization-utils/apply_diff_all.py "<...>\V1\localisation\english" "<...>\V2\localisation\english" -dest_dir "<...>\V1\localisation\french" ``` #### For old EUIV, HoI4 or Stellaris localisation format (all files in the same directory) ```shell -python src/apply_diff_all.py -source_lang -dest_lang +python paradox-localization-utils/apply_diff_all.py -source_lang -dest_lang ``` -* contains the localisation of the old source version -* contains the localisation of both new source version and old destination version +- contains the localisation of the old source version +- contains the localisation of both new source version and old destination version Example to apply in French files the modifications done in English ```shell -python src/apply_diff_all.py "<...>\V1\localisation" "<...>\V2\localisation" -source_lang english -dest_lang french +python paradox-localization-utils/apply_diff_all.py "<...>\V1\localisation" "<...>\V2\localisation" -source_lang english -dest_lang french ``` #### Both format @@ -206,7 +205,7 @@ The new and edited lines contains `:9 "`. If there is less than 10 modifications (according Levenshtein distance), the destination text is kept. -All the lines to translate are exported in to_translate/file_to_translate_.yml. +All the lines to translate are exported in to*translate/file_to_translate*.yml. We can also add the following parameter to the command line -keys_to_ignore , to simply copy-paste lines with these keys. @@ -217,24 +216,25 @@ It is useful when you have keys like spellcheck_ignore in the source files. > Extract existing translation from another game or mod to apply to your translation #### Limits + The target is EUIV or sooner whereas the source can be CK2/Vic2 or EUIV and sooner. #### Usage ```shell -python src/extract_existing_translation.py -source_col_ck2 -dest_col_ck2 +python paradox-localization-utils/extract_existing_translation.py -source_col_ck2 -dest_col_ck2 ``` Example to add in French CK3 files some texts from CK2 files. ```shell -python src/extract_existing_translation.py "<...>\CK2\localisation" "<...>\CK2\localisation" "<...>\CK3\localization\english" "<...>\CK3\localization\french" english french -source_col_ck2 1 -dest_col_ck2 2 +python paradox-localization-utils/extract_existing_translation.py "<...>\CK2\localisation" "<...>\CK2\localisation" "<...>\CK3\localization\english" "<...>\CK3\localization\french" english french -source_col_ck2 1 -dest_col_ck2 2 ``` Example to add in French HoI IV mod files some texts from Vanilla files. ```shell -python src/extract_existing_translation.py "<...>\Steam\steamapps\common\Hearts of Iron IV\localisation" "<...>\Steam\steamapps\common\Hearts of Iron IV\localisation" "<...>\mod\localisation" "<...>\mod\localisation" english french +python paradox-localization-utils/extract_existing_translation.py "<...>\Steam\steamapps\common\Hearts of Iron IV\localisation" "<...>\Steam\steamapps\common\Hearts of Iron IV\localisation" "<...>\mod\localisation" "<...>\mod\localisation" english french ``` ### Extract Paratranz translation @@ -242,18 +242,19 @@ python src/extract_existing_translation.py "<...>\Steam\steamapps\common\Hearts > Extract translations from JSON files downloaded from [Paratranz](https://paratranz.cn) to apply to your translation. #### Limits + This script only works for EUIV and sooner. #### Usage ```shell -python src/extract_paratranz_translation.py +python paradox-localization-utils/extract_paratranz_translation.py ``` Example to extract french reviewed translations ```shell -python src/extract_paratranz_translation.py "<...>\paratranz" "<...>\localisation" french +python paradox-localization-utils/extract_paratranz_translation.py "<...>\paratranz" "<...>\localisation" french ``` By default it extracts only reviewed translation. @@ -262,7 +263,7 @@ If you want to extract not reviewed translation, add `-extract_not_review` to th Example to extract french translations (reviewed or not) ```shell -python src/extract_paratranz_translation.py "<...>\paratranz" "<...>\localisation" french -extract_not_review +python paradox-localization-utils/extract_paratranz_translation.py "<...>\paratranz" "<...>\localisation" french -extract_not_review ``` ### Copy localization in other languages @@ -270,67 +271,69 @@ python src/extract_paratranz_translation.py "<...>\paratranz" "<...>\localisatio > Copy the localization of a language in other languages to allow to run your game/mod with this language with source texts instead of keys. #### Limits + It works only for Imperator Rome and sooner. #### Basic Usage [Windows only] + The usage is explicated in this [Steam guide](https://steamcommunity.com/sharedfiles/filedetails/?id=2342385980). #### Developer Usage ```shell -python src/copy_on_other_languages.py ... +python paradox-localization-utils/copy_on_other_languages.py ... ``` -Example to add some languages to available only in English and French (the added languages will have English text). +Example to add some languages to available only in English and French (the added languages will have English text). ```shell -python src/copy_on_other_languages.py "<...>\MyMod\localisation" english korean german russian simp_chinese spanish +python paradox-localization-utils/copy_on_other_languages.py "<...>\MyMod\localisation" english korean german russian simp_chinese spanish ``` To compile it (after running once `pip install cx_Freeze`), use the following command ```shell -cxfreeze -c src/copy_on_other_languages.py +cxfreeze -c paradox-localization-utils/copy_on_other_languages.py ``` - + ### Get duplicates keys > Get the list of duplicated keys in the localization to avoid localization erased by others. - + #### Limits - + The duplicated keys are searched in English localisation files only. - + #### Usage - + To get the full list of duplicated keys run the following command ```shell -python src/get_duplicates_key.py "<...>\MyMod\localisation" +python paradox-localization-utils/get_duplicates_key.py "<...>\MyMod\localisation" ``` - + To get only the list of duplicated keys which already cause a bug -(the value is not the same for each duplication), add *-only_different_value* to the command. - - +(the value is not the same for each duplication), add _-only_different_value_ to the command. + ### [DEPRECATED] Apply diff for EUIV and sooner ```shell -python src/apply_diff.py +python paradox-localization-utils/apply_diff.py ``` The destination file is override so don't hesitate to have a backup before running this. The new and edited lines contains `:9 "` Optionnal parameters : -* ```-space_prefix ``` : Prefix (generally spaces) before key in files -* ```-keep_edited``` : Keep destination value in case of edition. -The default behavior replace the destination value by the new source value. + +- `-space_prefix ` : Prefix (generally spaces) before key in files +- `-keep_edited` : Keep destination value in case of edition. + The default behavior replace the destination value by the new source value. Example to apply the English update from 0.11.1 to 0.11.2 to Russia file in French: ```shell -python src/apply_diff.py <...>\0.11.1\localisation\KR_Russia_l_english.yml <...>\0.11.2\localisation\KR_Russia_l_english.yml <...>\Translation_FR\localisation\KR_Russia_l_french.yml -space_prefix " " -keep_edited +python paradox-localization-utils/apply_diff.py <...>\0.11.1\localisation\KR_Russia_l_english.yml <...>\0.11.2\localisation\KR_Russia_l_english.yml <...>\Translation_FR\localisation\KR_Russia_l_french.yml -space_prefix " " -keep_edited ``` After running this, the new and edited lines need to be fixed by hand by seeking `:9 "` @@ -343,8 +346,7 @@ Run the tests with pytest pytest ``` -If some tests fails with error `ModuleNotFoundError: No module named 'src'`, run the following command in the root directory. - +If some tests fails with error `ModuleNotFoundError: No module named 'paradox-localization-utils'`, run the following command in the root directory. On Windows: diff --git a/compile_update_paratranz.py b/compile_update_paratranz.py index f5cc9ac..ef9a3f0 100644 --- a/compile_update_paratranz.py +++ b/compile_update_paratranz.py @@ -7,5 +7,5 @@ version="0.1", description="Update translation on Paratranz", options={"build_exe": build_exe_options}, - executables=[Executable("src/update_paratranz.py")], + executables=[Executable("paradox-localization-utils/update_paratranz.py")], ) diff --git a/copy_on_other_languages/README.txt b/copy_on_other_languages/README.txt index cf0d08d..49be78f 100644 --- a/copy_on_other_languages/README.txt +++ b/copy_on_other_languages/README.txt @@ -1,5 +1,5 @@ Usage guide : https://steamcommunity.com/sharedfiles/filedetails/?id=2342385980 -Source code : https://github.com/NicolasGrosjean/Paradox_localization_utils/blob/master/src/copy_on_other_languages.py +Source code : https://github.com/NicolasGrosjean/Paradox_localization_utils/blob/master/paradox-localization-utils/copy_on_other_languages.py Licence MIT : https://github.com/NicolasGrosjean/Paradox_localization_utils/blob/master/Licence.md \ No newline at end of file diff --git a/src/add_missing_lines.py b/paradox-localization-utils/add_missing_lines.py similarity index 97% rename from src/add_missing_lines.py rename to paradox-localization-utils/add_missing_lines.py index 814bd9d..be4b16e 100644 --- a/src/add_missing_lines.py +++ b/paradox-localization-utils/add_missing_lines.py @@ -4,7 +4,7 @@ import sys sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) -from src.read_localization_file import file_to_keys_and_lines, get_key_value_and_version, BadLocalizationException +from paradox-localization-utils.read_localization_file import file_to_keys_and_lines, get_key_value_and_version, BadLocalizationException def get_args(): diff --git a/src/apply_diff.py b/paradox-localization-utils/apply_diff.py similarity index 97% rename from src/apply_diff.py rename to paradox-localization-utils/apply_diff.py index 9013b72..7551624 100644 --- a/src/apply_diff.py +++ b/paradox-localization-utils/apply_diff.py @@ -4,7 +4,7 @@ import sys sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) -from src.read_localization_file import ( +from paradox-localization-utils.read_localization_file import ( file_to_keys_and_lines, get_key_value_and_version, BadLocalizationException, diff --git a/src/apply_diff_all.py b/paradox-localization-utils/apply_diff_all.py similarity index 95% rename from src/apply_diff_all.py rename to paradox-localization-utils/apply_diff_all.py index e8d6b80..62533fb 100644 --- a/src/apply_diff_all.py +++ b/paradox-localization-utils/apply_diff_all.py @@ -5,7 +5,7 @@ import sys sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) -from src.read_localization_file import ( +from paradox-localization-utils.read_localization_file import ( file_to_keys_and_lines, get_key_value_and_version, BadLocalizationException, @@ -131,11 +131,11 @@ def apply_diff_one_file( first_line = False -def apply_diff_all(old_dir, current_src_dir, current_dest_dir, source_lang, dest_lang, keys_to_ignore): +def apply_diff_all(old_dir, current_paradox-localization-utils_dir, current_dest_dir, source_lang, dest_lang, keys_to_ignore): """ Apply diff for all files :param old_dir: Directory with source Paradox files for previous version - :param current_src_dir: Directory with source Paradox files for new version + :param current_paradox-localization-utils_dir: Directory with source Paradox files for new version :param current_dest_dir: Directory with destination Paradox files for new version :param source_lang: Source language :param dest_lang: Destination language @@ -176,15 +176,15 @@ def apply_diff_all(old_dir, current_src_dir, current_dest_dir, source_lang, dest lines_to_update_source = [f"\ufeffl_{source_lang}:\n"] lines_to_update_dest = [f"\ufeffl_{dest_lang}:\n"] # Apply diff with current source texts - for root, _, files in os.walk(current_src_dir): + for root, _, files in os.walk(current_paradox-localization-utils_dir): for file in files: if file.endswith(source_lang + ".yml"): abs_path = os.path.abspath(os.path.join(root, file)) - rel_path = abs_path[: abs_path.find("_l_")].replace(current_src_dir, "") + rel_path = abs_path[: abs_path.find("_l_")].replace(current_paradox-localization-utils_dir, "") if rel_path in rel_to_dest_abs_path: dest_file_path = rel_to_dest_abs_path[rel_path] else: - dest_file_path = abs_path.replace(current_src_dir, current_dest_dir).replace( + dest_file_path = abs_path.replace(current_paradox-localization-utils_dir, current_dest_dir).replace( source_lang + ".yml", dest_lang + ".yml" ) apply_diff_one_file( diff --git a/src/copy_on_other_languages.py b/paradox-localization-utils/copy_on_other_languages.py similarity index 100% rename from src/copy_on_other_languages.py rename to paradox-localization-utils/copy_on_other_languages.py diff --git a/src/download_paratranz.py b/paradox-localization-utils/download_paratranz.py similarity index 100% rename from src/download_paratranz.py rename to paradox-localization-utils/download_paratranz.py diff --git a/src/extract_existing_translation.py b/paradox-localization-utils/extract_existing_translation.py similarity index 97% rename from src/extract_existing_translation.py rename to paradox-localization-utils/extract_existing_translation.py index debeb78..a154df2 100644 --- a/src/extract_existing_translation.py +++ b/paradox-localization-utils/extract_existing_translation.py @@ -5,7 +5,7 @@ import sys sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) -from src.read_localization_file import file_to_keys_and_values, get_key_value_and_version, BadLocalizationException +from paradox-localization-utils.read_localization_file import file_to_keys_and_values, get_key_value_and_version, BadLocalizationException def get_args(): diff --git a/src/extract_paratranz_translation.py b/paradox-localization-utils/extract_paratranz_translation.py similarity index 96% rename from src/extract_paratranz_translation.py rename to paradox-localization-utils/extract_paratranz_translation.py index bed4c2a..214a1e6 100644 --- a/src/extract_paratranz_translation.py +++ b/paradox-localization-utils/extract_paratranz_translation.py @@ -5,7 +5,7 @@ import sys sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) -from src.read_localization_file import get_key_value_and_version, BadLocalizationException +from paradox-localization-utils.read_localization_file import get_key_value_and_version, BadLocalizationException def get_args(): diff --git a/src/get_duplicates_key.py b/paradox-localization-utils/get_duplicates_key.py similarity index 92% rename from src/get_duplicates_key.py rename to paradox-localization-utils/get_duplicates_key.py index 10ab3be..80f718b 100644 --- a/src/get_duplicates_key.py +++ b/paradox-localization-utils/get_duplicates_key.py @@ -4,7 +4,7 @@ import sys sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__)))) -from src.read_localization_file import get_key_value_and_version, BadLocalizationException +from paradox-localization-utils.read_localization_file import get_key_value_and_version, BadLocalizationException def get_args(): diff --git a/src/read_localization_file.py b/paradox-localization-utils/read_localization_file.py similarity index 100% rename from src/read_localization_file.py rename to paradox-localization-utils/read_localization_file.py diff --git a/src/update_paratranz.py b/paradox-localization-utils/update_paratranz.py similarity index 83% rename from src/update_paratranz.py rename to paradox-localization-utils/update_paratranz.py index 1a1e0aa..99edcc6 100644 --- a/src/update_paratranz.py +++ b/paradox-localization-utils/update_paratranz.py @@ -4,7 +4,7 @@ import requests import time -from src.utils import compute_time, manage_request_error +from paradox-localization-utils.utils import compute_time, manage_request_error def get_args(): @@ -19,7 +19,7 @@ def get_args(): return parser.parse_args() -def create_or_update_files(project_id: int, token: str, loc_dir: str, language: str, parallel_nb: int): +def create_or_update_files(project_id: int, token: str, loc_dir: str, language: str, parallel_nb: int) -> list[str]: __assert_localisation_directory_format(loc_dir, language) start = time.time() try: @@ -46,6 +46,7 @@ def create_or_update_files(project_id: int, token: str, loc_dir: str, language: for file in files_with_errors: print(file) print(f"Total time of the execution: {compute_time(start)}") + return [] # TODO def __assert_localisation_directory_format(loc_dir: str, language: str): if not os.path.isdir(loc_dir): @@ -91,6 +92,15 @@ def create_or_update_file( except requests.HTTPError: files_with_errors.append(file_relative_path) +def delete_files_if_wanted(token: str, project_id: int, loc_dir: str, parallel_nb: int, files_to_delete: list[str]): + if len(files_to_delete) > 0: + print(f"{len(files_to_delete)} files are in Paratranz but not in {loc_dir}:\n{files_to_delete}") + will_delete_files = input("Do you want to delete these files from Paratranz? [y/N]") + if will_delete_files == "y": + delete_files(token, project_id, parallel_nb, files_to_delete) + else: + print("Files NOT deleted") + def __post_file_to_paratranz_with_retry( token: str, @@ -125,4 +135,5 @@ def __post_file_to_paratranz(url: str, headers: dict, filepath: str, paratranz_p if __name__ == "__main__": print("Version of the software: 1.1 (27th September 2024)") args = get_args() - create_or_update_files(args.project_id, args.token, args.loc_dir, args.language, args.parallel_nb) + files_to_delete = create_or_update_files(args.project_id, args.token, args.loc_dir, args.language, args.parallel_nb) + delete_files_if_wanted(args.token, args.project_id, args.loc_dir, args.parallel_nb, files_to_delete) diff --git a/src/update_source.py b/paradox-localization-utils/update_source.py similarity index 100% rename from src/update_source.py rename to paradox-localization-utils/update_source.py diff --git a/src/utils.py b/paradox-localization-utils/utils.py similarity index 100% rename from src/utils.py rename to paradox-localization-utils/utils.py diff --git a/tests/test_apply_diff.py b/tests/test_apply_diff.py index 3784fc9..886b5ed 100644 --- a/tests/test_apply_diff.py +++ b/tests/test_apply_diff.py @@ -3,7 +3,7 @@ import os import shutil -from src.apply_diff import apply_diff +from paradox-localization-utils.apply_diff import apply_diff from tests.utils import get_data_dir diff --git a/tests/test_apply_diff_all.py b/tests/test_apply_diff_all.py index c874b1f..d633ac6 100644 --- a/tests/test_apply_diff_all.py +++ b/tests/test_apply_diff_all.py @@ -4,7 +4,7 @@ import shutil from tests.utils import get_data_dir -from src.apply_diff_all import DIR_TO_TRANSLATE, DIR_TO_UPDATE, FILE_TO_TRANSLATE_PREFIX, FILE_TO_UPDATE_DEST_PREFIX, FILE_TO_UPDATE_OLD_SOURCE_PREFIX, FILE_TO_UPDATE_SOURCE_PREFIX, apply_diff_all_old_formats +from paradox-localization-utils.apply_diff_all import DIR_TO_TRANSLATE, DIR_TO_UPDATE, FILE_TO_TRANSLATE_PREFIX, FILE_TO_UPDATE_DEST_PREFIX, FILE_TO_UPDATE_OLD_SOURCE_PREFIX, FILE_TO_UPDATE_SOURCE_PREFIX, apply_diff_all_old_formats class TestApplyDiffAll(unittest.TestCase): diff --git a/tests/test_copy_on_other_languages.py b/tests/test_copy_on_other_languages.py index 46234c1..622984f 100644 --- a/tests/test_copy_on_other_languages.py +++ b/tests/test_copy_on_other_languages.py @@ -2,7 +2,7 @@ import shutil import unittest -from src.copy_on_other_languages import copy_on_other_languages +from paradox-localization-utils.copy_on_other_languages import copy_on_other_languages from tests.utils import get_data_dir diff --git a/tests/test_extract_existing_translation.py b/tests/test_extract_existing_translation.py index 969c885..708f66e 100644 --- a/tests/test_extract_existing_translation.py +++ b/tests/test_extract_existing_translation.py @@ -2,7 +2,7 @@ import shutil import unittest -from src.extract_existing_translation import extract_existing_translation +from paradox-localization-utils.extract_existing_translation import extract_existing_translation from tests.utils import get_data_dir diff --git a/tests/test_extract_paratranz_translation.py b/tests/test_extract_paratranz_translation.py index 706523e..1f141ec 100644 --- a/tests/test_extract_paratranz_translation.py +++ b/tests/test_extract_paratranz_translation.py @@ -2,7 +2,7 @@ import shutil import unittest -from src.extract_paratranz_translation import extract_paratranz_localisation, extract_paratranz_localisation_dir +from paradox-localization-utils.extract_paratranz_translation import extract_paratranz_localisation, extract_paratranz_localisation_dir from tests.utils import get_data_dir diff --git a/tests/test_read_localization_file.py b/tests/test_read_localization_file.py index 168ee22..8133f92 100644 --- a/tests/test_read_localization_file.py +++ b/tests/test_read_localization_file.py @@ -1,7 +1,7 @@ import unittest import os -from src.read_localization_file import get_key_value_and_version, BadLocalizationException, file_to_keys_and_values +from paradox-localization-utils.read_localization_file import get_key_value_and_version, BadLocalizationException, file_to_keys_and_values from tests.utils import get_data_dir diff --git a/tests/test_update_paratranz.py b/tests/test_update_paratranz.py index a20c057..ed09e2f 100644 --- a/tests/test_update_paratranz.py +++ b/tests/test_update_paratranz.py @@ -5,7 +5,7 @@ import requests import responses -from src.update_paratranz import create_or_update_file, create_or_update_files, get_project_files +from paradox-localization-utils.update_paratranz import create_or_update_file, create_or_update_files, get_project_files from tests.utils import generate_random_str @@ -139,7 +139,7 @@ def raise_error_first_call(url: str, headers: dict, filepath: str, paratranz_pat first_call = False raise requests.HTTPError() - mocker.patch("src.update_paratranz.__post_file_to_paratranz", new=raise_error_first_call) + mocker.patch("paradox-localization-utils.update_paratranz.__post_file_to_paratranz", new=raise_error_first_call) current_files = dict() files_with_errors = [] create_or_update_file(token, project_id, tmp_path, language, str(empty_file), current_files, files_with_errors)