ya2 · news · projects · code · about

other fixes for building master
authorFlavio Calva <f.calva@gmail.com>
Sat, 13 May 2023 07:36:32 +0000 (09:36 +0200)
committerFlavio Calva <f.calva@gmail.com>
Sat, 13 May 2023 07:36:32 +0000 (09:36 +0200)
prj.org
setup.py
tests/test_setup.py
tests/ya2/build/test_lang.py
ya2/build/lang.py

diff --git a/prj.org b/prj.org
index 5339a587e374f9777653ddd725d6f5a7f20becfe..f9da724310fceb2d7f6f2d8435d8b5654a0367cc 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -3,6 +3,8 @@
 #+CATEGORY: pmachines
 #+TAGS: bug(b) calendar(c) waiting(w)
 
+* DOING put the builder on my personal pc
+* rename: s/functional tests/system tests/
 * magnet, road cone, bucket
 * osx support
 * (python 3.11) manylinux2014_x86_64
index aa5273fc78b123cd39f0220111d752d614a34cd0..a7107545ee2fbd401de3689fe320a4d3c230bfe4 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -74,11 +74,11 @@ class L10nCommand(BaseCommand):
 
     def run(self):
         l = LanguageBuilder(
-            app_name, 'assets/locale/po/', 'assets/scenes/', 'assets/locale/')
-        l.build()
-        l = LanguageBuilder(
-            'test', 'tests/assets/locale/po/', 'tests/assets/scenes/', 'tests/assets/locale/')
+            app_name, 'assets/locale/po/', 'assets/scenes/', 'assets/locale/', '.')
         l.build()
+        # l = LanguageBuilder(
+        #     'test', 'assets/locale/po/', 'assets/scenes/', 'assets/locale/', 'tests')
+        # l.build()
 
 
 class BDistAppsCommand(bdist_apps):
index eb89afee07125b0e423978bf7778d870f7b3e57a..c16d8c51febf5dba264ae5cb42dffdaec071c797 100644 (file)
@@ -78,7 +78,7 @@ class SetupTests(TestCase):
     def test_l10n_command(self, l_mock):
         cmd = L10nCommand(Distribution())
         cmd.run()
-        assert l_mock.call_count == 2  # 1  -  added test building
+        assert l_mock.call_count == 1
         build_args = l_mock.call_args_list[0].args
         assert isinstance(build_args[0], str)
         assert 'locale' in build_args[1]
index aa5dbd7114029f3f35283b2d7c65d737a3271385..689bedd834c3b28c9c4284325a2f401d5b31a6ed 100644 (file)
@@ -22,7 +22,8 @@ class LangTests(TestCase):
             rmtree('./tests/' + dirname, ignore_errors=True)
 
     def test_lang(self):
-        l = LanguageBuilder('test_pmachines', './tests/po/', './tests/po/', './tests/locale/')
+        #l = LanguageBuilder('test_pmachines', './po/', './po/', './locale/', 'tests')
+        l = LanguageBuilder('test', 'assets/locale/po/', 'assets/scenes/', 'assets/locale/', 'tests')
         l.build()
-        self.assertTrue(exists('./tests/po/test_pmachines.pot'))
-        self.assertTrue(exists('./tests/locale/it_IT/LC_MESSAGES/test_pmachines.mo'))
+        self.assertTrue(exists('./tests/assets/locale/po/test.pot'))
+        self.assertTrue(exists('./tests/assets/locale/it_IT/LC_MESSAGES/test.mo'))
index 4a9a2c80ab0290449abcf02c4287ea415635bb5c..612624544777fd837f2eaaa5941444bdb6370df1 100644 (file)
@@ -1,5 +1,5 @@
 '''Tools for l10n.'''
-from os import system, makedirs, remove, listdir
+from os import system, makedirs, remove, listdir, getcwd, chdir
 from os.path import exists, isfile, join
 from shutil import move, copy
 from json import loads
@@ -10,19 +10,23 @@ from ya2.build.build import find_file_names, FindFileNamesArgs
 class LanguageBuilder:
     '''Tools for building files for l10n.'''
 
-    def __init__(self, app_name, po_path, json_path, mo_path):
+    def __init__(self, app_name, po_path, json_path, mo_path, root):
         self.__app_name = app_name
         self.__po_path = po_path
         self.__json_path = json_path
         self.__mo_path = mo_path
+        self.__root = root
 
     def build(self):
+        orig_dir = getcwd()
+        chdir(self.__root)
         self.__build_pot()
         po_files = [name for name in listdir(self.__po_path)
                    if isfile(join(self.__po_path, name)) and
                        name.endswith('.po')]
         language_codes = [f.split('.')[0] for f in po_files]
         for l in language_codes: self.__process_language(l)
+        chdir(orig_dir)
 
     def __build_pot(self):
         '''Builds the pot file in the lng_dir_code directory.'''