From 4e328dca8334bd44e1980af0b89b0919c5c620ad Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Tue, 9 Jan 2018 13:12:35 +0100 Subject: [PATCH] fix i18n _(...) --- commands/check.py | 12 ++++---- commands/clean.py | 4 +-- commands/find_duplicates.py | 5 ++-- commands/jobs.py | 32 ++++++++++----------- commands/profile.py | 9 +++--- commands/run.py | 4 +-- commands/test.py | 14 ++++----- src/i18n/build_strings.sh | 16 +++++++---- src/i18n/fr/LC_MESSAGES/salomeTools.po | 36 +++++++++++++----------- src/product.py | 26 ++++++++--------- src/test_module.py | 39 ++++++++++++-------------- 11 files changed, 102 insertions(+), 95 deletions(-) diff --git a/commands/check.py b/commands/check.py index c5ff767..15ccc4a 100644 --- a/commands/check.py +++ b/commands/check.py @@ -50,9 +50,9 @@ def get_products_list(options, cfg, logger): products = options.products for p in products: if p not in cfg.APPLICATION.products: - raise src.SatException(_("Product %(product)s " - "not defined in application %(application)s") % - { 'product': p, 'application': cfg.VARS.application} ) + msg = _("Product %(1)s not defined in application %(2)s") % + { '1': p, '2': cfg.VARS.application} + raise src.SatException(msg) # Construct the list of tuple containing # the products name and their definition @@ -142,10 +142,10 @@ def check_product(p_name_info, config, logger): command = src.get_cfg_param(p_info, "test_build", "Not found") if command == "Not found": cmd_found = False - msg = _('''\ + msg = _("""\ WARNING: The product %(name)s is defined as having tests. - But it is compiled using a script and the key "test_build" - is not defined in the definition of %(name)''') % {"name": p_name} + But it is compiled using a script and the key 'test_build' + is not defined in the definition of %(name)""") % {"name": p_name} logger.write("%s\n" % msg, 4) if ignored or not cmd_found: diff --git a/commands/clean.py b/commands/clean.py index 07239bc..8d76389 100644 --- a/commands/clean.py +++ b/commands/clean.py @@ -162,7 +162,7 @@ def suppress_directories(l_paths, logger): ''' for path in l_paths: if not path.isdir(): - msg = _("Warning: the path %s does not " + msg = _("WARNING: the path %s does not " "exists (or is not a directory)\n" % path.__str__()) logger.write(src.printcolors.printcWarning(msg), 1) else: @@ -245,4 +245,4 @@ def run(args, runner, logger): # Suppress the list of paths suppress_directories(l_dir_to_suppress, logger) - return 0 \ No newline at end of file + return 0 diff --git a/commands/find_duplicates.py b/commands/find_duplicates.py index 56e7143..bd7ddc7 100644 --- a/commands/find_duplicates.py +++ b/commands/find_duplicates.py @@ -273,8 +273,9 @@ def run(args, runner, logger): # Check that there are no singletons in the result (it would be a bug) for elem in dic_fic_paths: if len(dic_fic_paths[elem])<2: - logger.write(_("Warning : element %s has not more than" - " two paths.\n") % elem, 3) + logger.write( + _("WARNING : element %s has not more than two paths.\n") % elem, + 3 ) # Display the results diff --git a/commands/jobs.py b/commands/jobs.py index 0eb037c..be19628 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -122,7 +122,7 @@ class Machine(object): ''' if self._connection_successful == None: message = _("""\ -Warning : trying to ask if the connection to +WARNING : trying to ask if the connection to (name: %(1)s host: %(2)s, port: %(3)s, user: %(4)s) is OK whereas there were no connection request""" % {"1": self.name, "2": self.host, "3": self.port, "4": self.user} ) @@ -533,7 +533,7 @@ class Job(object): # Prevent multiple run if self.has_begun(): - msg = _("Warning: A job can only be launched one time") + msg = _("WARNING: A job can only be launched one time") msg2 = _("Trying to launch the job \"%s\" whereas it has " "already been launched." % self.name) self.logger.write(src.printcolors.printcWarning("%s\n%s\n" % (msg, @@ -708,8 +708,9 @@ class Jobs(object): for job_def in self.cfg_jobs.jobs : if not "machine" in job_def: - msg = _('WARNING: The job "%s" do not have the key ' - '"machine", this job is ignored.\n\n' % job_def.name) + msg = _("""\ +WARNING: The job '%s' do not have the key 'machine'. + This job is ignored.\n""") % job_def.name self.logger.write(src.printcolors.printcWarning(msg)) continue name_machine = job_def.machine @@ -762,13 +763,12 @@ class Jobs(object): host_list.append((host, port)) if a_machine == None: - msg = _("WARNING: The job \"%(job_name)s\" requires the " - "machine \"%(machine_name)s\" but this machine " - "is not defined in the configuration file.\n" - "The job will not be launched\n") - self.logger.write(src.printcolors.printcWarning( - msg % {"job_name" : job_def.name, - "machine_name" : name_machine})) + msg = _("""\ +WARNING: The job '%(job)s' requires the machine '%(machine)s'. + This machine is not defined in the configuration file. + The job will not be launched. +""") % {"job" : job_def.name, "machine" : name_machine} + self.logger.write(src.printcolors.printcWarning(msg)) continue a_job = self.define_job(job_def, a_machine) @@ -791,7 +791,7 @@ class Jobs(object): "Establishing connection with all the machines :\n"))) for machine in self.lmachines: # little algorithm in order to display traces - begin_line = (_("Connection to %s: " % machine.name)) + begin_line = (_("Connection to %s: ") % machine.name) if pad - len(begin_line) < 0: endline = " " else: @@ -853,7 +853,7 @@ class Jobs(object): (begin_line, endline, src.printcolors.printc(src.KO_STATUS), - _("Copy of SAT failed: %s" % res_copy)), 3) + _("Copy of SAT failed: %s") % res_copy), 3) else: self.logger.write('\r%s' % ((len(begin_line)+len(endline)+20) * " "), 3) @@ -1326,8 +1326,8 @@ class Gui(object): global_xml = src.xmlManager.ReadXmlFile(file_path) l_globalxml.append(global_xml) except Exception as e: - msg = _("\nWarning: the file '%(1)s' can not be read, it will be " - "ignored\n%(2)s" % {"1": file_path, "2": e}) + msg = _("WARNING: the file '%(1)s' can not be read, it will be " + "ignored\n%(2)s") % {"1": file_path, "2": e} self.logger.write("%s\n" % src.printcolors.printcWarning( msg), 5) @@ -1862,7 +1862,7 @@ def run(args, runner, logger): try: jb.kill_remote_process() except Exception as e: - msg = _("Failed to kill job %(1)s: %(2)s\n" % {"1": jb.name, "2": e}) + msg = _("Failed to kill job %(1)s: %(2)s\n") % {"1": jb.name, "2": e} logger.write(src.printcolors.printcWarning(msg)) if jb.res_job != "0": res = 1 diff --git a/commands/profile.py b/commands/profile.py index 6f9a0be..18e46a8 100644 --- a/commands/profile.py +++ b/commands/profile.py @@ -121,8 +121,8 @@ def generate_profile_sources( config, options, logger ): prefix = os.path.join( options.prefix, name ) if os.path.exists( prefix ) : if not options.force : - raise src.SatException( _("The path %s already exists, use option" - " --force to remove it." %prefix ) ) + raise src.SatException( + _("The path %s already exists, use option --force to remove it.") % prefix ) else : shutil.rmtree( prefix ) @@ -162,8 +162,9 @@ def update_pyconf( config, options, logger ): #Save previous version pyconf = config.VARS.product + '.pyconf' pyconfBackup = config.VARS.product + '-backup.pyconf' - logger.write(_("Updating %(new)s (previous version saved " - "as %(old)s).") % { "new": pyconf, "old": pyconfBackup }, 3) + logger.write( + _("Updating %(new)s (previous version saved as %(old)s)." ) % + { "new": pyconf, "old": pyconfBackup }, 3) path = config.getPath( pyconf ) shutil.copyfile( os.path.join( path, pyconf ), os.path.join( path, pyconfBackup ) ) diff --git a/commands/run.py b/commands/run.py index 42ab7d8..8947485 100644 --- a/commands/run.py +++ b/commands/run.py @@ -46,7 +46,7 @@ def run(args, runner, logger): if launcher_name not in os.listdir(launcher_dir): message = _("""\ The launcher %(1)s was not found in directory '%(2)s'. -Did you run the command 'sat launcher' ?\n""" % {"1": launcher_name, "2": launcher_dir} ) +Did you run the command 'sat launcher' ?\n""") % {"1": launcher_name, "2": launcher_dir} raise src.SatException(message) launcher_path = os.path.join(launcher_dir, launcher_name) @@ -54,7 +54,7 @@ Did you run the command 'sat launcher' ?\n""" % {"1": launcher_name, "2": launch if not os.path.exists(launcher_path): message = _("""\ The launcher at path '%s' is missing. -Did you run the command 'sat launcher' ?\n""" % launcher_path ) +Did you run the command 'sat launcher' ?\n""") % launcher_path raise src.SatException(message) # Determine the command to launch (add the additional arguments) diff --git a/commands/test.py b/commands/test.py index 4352c54..5832213 100644 --- a/commands/test.py +++ b/commands/test.py @@ -98,7 +98,7 @@ def ask_a_path(): return ask_a_path() elif os.path.exists(path): - result = raw_input("Warning, the content of %s will be deleted. Are you" + result = raw_input("WARNING: the content of %s will be deleted. Are you" " sure to continue ? [y/n] " % path) if result == "y": return path @@ -556,20 +556,20 @@ def run(args, runner, logger): runner.cfg.VARS.application), 1) with_application = True elif not options.base: - raise src.SatException(_('A test base is required. Use the --base ' - 'option')) + raise src.SatException( + _('A test base is required. Use the --base option') ) # the launcher is specified either by the application, or by the --launcher option if with_application: # check if environment is loaded if 'KERNEL_ROOT_DIR' in os.environ: - logger.write(src.printcolors.printcWarning(_("WARNING: " - "SALOME environment already sourced")) + "\n", 1) + logger.write( src.printcolors.printcWarning( + _("WARNING: SALOME environment already sourced")) + "\n", 1 ) elif options.launcher: - logger.write(src.printcolors.printcWarning(_("Running SALOME " - "application.")) + "\n\n", 1) + logger.write(src.printcolors.printcWarning( + _("Running SALOME application.")) + "\n\n", 1) else: msg = _("Impossible to find any launcher.\nPlease specify an " "application or a launcher") diff --git a/src/i18n/build_strings.sh b/src/i18n/build_strings.sh index de0abf7..c61512b 100755 --- a/src/i18n/build_strings.sh +++ b/src/i18n/build_strings.sh @@ -11,11 +11,17 @@ echo "Build strings for French, create and merging salomeTools.po" poFile=$I18HOME/fr/LC_MESSAGES/salomeTools.po refFile=$I18HOME/fr/LC_MESSAGES/ref.pot -xgettext $SRC_DIR/*.py $SRC_DIR/commands/*.py $SRC_DIR/src/*.py \ - --no-wrap --no-location --language=Python --omit-header \ - --output=$refFile - -msgmerge --quiet --update $poFile $refFile +xgettext $SRC_DIR/src/i18n/*.py \ + $SRC_DIR/*.py \ + $SRC_DIR/commands/*.py \ + $SRC_DIR/src/*.py \ + --no-wrap \ + --no-location \ + --language=Python \ + --omit-header \ + --output=$refFile + +msgmerge --quiet --update --previous $poFile $refFile #retirer les messages obsolètes « #~ » #msgattrib --no-obsolete -o $poFile $poFile diff --git a/src/i18n/fr/LC_MESSAGES/salomeTools.po b/src/i18n/fr/LC_MESSAGES/salomeTools.po index d16e170..195ad0c 100644 --- a/src/i18n/fr/LC_MESSAGES/salomeTools.po +++ b/src/i18n/fr/LC_MESSAGES/salomeTools.po @@ -13,7 +13,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -# test accentué +#, python-format msgid "Georges says '%(1)s' for %(2)s." msgstr "pour %(2)s Hervé dit '%(1)s'." @@ -171,7 +171,7 @@ msgid "" msgstr "" #, python-format -msgid "Product %(product)s not defined in application %(application)s" +msgid "Product %(1)s not defined in application %(2)s" msgstr "" #, python-format @@ -192,8 +192,8 @@ msgstr "" msgid "" "WARNING: The product %(name)s is defined as having tests.\n" -" But it is compiled using a script and the key \"test_build\"\n" -" is not defined in the definition of %(name)" +" But it is compiled using a script and the key 'test_build'\n" +" is not defined in the definition of %(name)" msgstr "" msgid "" @@ -246,7 +246,11 @@ msgid "Optional: do not clean the products in development mode." msgstr "" #, python-format -msgid "Warning: the path %s does not exists (or is not a directory)\n" +msgid "Product %(product)s not defined in application %(application)s" +msgstr "" + +#, python-format +msgid "WARNING: the path %s does not exists (or is not a directory)\n" msgstr "" #, python-format @@ -646,7 +650,7 @@ msgid "No duplicate files found.\n" msgstr "" #, python-format -msgid "Warning : element %s has not more than two paths.\n" +msgid "WARNING : element %s has not more than two paths.\n" msgstr "" msgid "" @@ -845,7 +849,7 @@ msgstr "" #, python-format msgid "" -"Warning : trying to ask if the connection to \n" +"WARNING : trying to ask if the connection to \n" " (name: %(1)s host: %(2)s, port: %(3)s, user: %(4)s) is OK\n" " whereas there were no connection request" msgstr "" @@ -877,7 +881,7 @@ msgid "" "%s\n" msgstr "" -msgid "Warning: A job can only be launched one time" +msgid "WARNING: A job can only be launched one time" msgstr "" #, python-format @@ -886,16 +890,15 @@ msgstr "" #, python-format msgid "" -"WARNING: The job \"%s\" do not have the key \"machine\", this job is " -"ignored.\n" -"\n" +"WARNING: The job '%s' do not have the key 'machine'.\n" +" This job is ignored.\n" msgstr "" #, python-format msgid "" -"WARNING: The job \"%(job_name)s\" requires the machine \"%(machine_name)s\" " -"but this machine is not defined in the configuration file.\n" -"The job will not be launched\n" +"WARNING: The job '%(job)s' requires the machine '%(machine)s'.\n" +" This machine is not defined in the configuration file.\n" +" The job will not be launched.\n" msgstr "" #, python-format @@ -920,8 +923,7 @@ msgstr "" #, python-format msgid "" -"\n" -"Warning: the file '%(1)s' can not be read, it will be ignored\n" +"WARNING: the file '%(1)s' can not be read, it will be ignored\n" "%(2)s" msgstr "" @@ -1858,7 +1860,7 @@ msgid "Test base" msgstr "" #, python-format -msgid "########## ERROR: test base '%s' not found\n" +msgid "ERROR: test base '%s' not found\n" msgstr "" #, python-format diff --git a/src/product.py b/src/product.py index 41fa99b..e261c5d 100644 --- a/src/product.py +++ b/src/product.py @@ -119,8 +119,8 @@ def get_product_config(config, product_name, with_install_dir=True): prod_info.get_source = "native" elif prod_info.get_source == "native": msg = _("The product %(prod)s has version %(ver)s but is " - "declared as native in its definition" % - { 'prod': prod_info.name, 'ver': version}) + "declared as native in its definition") % + {'prod': prod_info.name, 'ver': version} raise src.SatException(msg) # If there is no definition but the product is declared as native, @@ -147,12 +147,12 @@ def get_product_config(config, product_name, with_install_dir=True): if not prod_pyconf_path: msg = _("""\ No definition found for the product %(1)s. -Please create a %(2)s.pyconf file.""" % {"1": product_name, "2": product_name}) +Please create a %(2)s.pyconf file.""") % {"1": product_name, "2": product_name} else: msg = _("""\ No definition corresponding to the version %(1)s was found in the file %(2)s. -Please add a section in it.""" % {"1" : vv, "2" : prod_pyconf_path} ) +Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path} raise src.SatException(msg) # Set the debug, dev and version keys @@ -171,8 +171,8 @@ Please add a section in it.""" % {"1" : vv, "2" : prod_pyconf_path} ) arch_path = src.find_file_in_lpath(arch_name, config.PATHS.ARCHIVEPATH) if not arch_path: - msg = _("Archive %(1)s for %(2)s not found.\n" % - {"1" : arch_name, "2" : prod_info.name}) + msg = _("Archive %(1)s for %(2)s not found.\n") % + {"1" : arch_name, "2" : prod_info.name} raise src.SatException(msg) prod_info.archive_info.archive_name = arch_path else: @@ -183,8 +183,8 @@ Please add a section in it.""" % {"1" : vv, "2" : prod_pyconf_path} ) arch_name, config.PATHS.ARCHIVEPATH) if not arch_path: - msg = _("Archive %(1)s for %(2)s not found:\n" % - {"1" : arch_name, "2" : prod_info.name}) + msg = _("Archive %(1)s for %(2)s not found:\n") % + {"1" : arch_name, "2" : prod_info.name} raise src.SatException(msg) prod_info.archive_info.archive_name = arch_path @@ -195,7 +195,7 @@ Please add a section in it.""" % {"1" : vv, "2" : prod_pyconf_path} ) if "compil_script" not in prod_info: msg = _("""\ No compilation script found for the product %s. -Please provide a 'compil_script' key in its definition.""" % (product_name)) +Please provide a 'compil_script' key in its definition.""") % product_name raise src.SatException(msg) # Get the path of the script @@ -233,8 +233,8 @@ Please provide a 'compil_script' key in its definition.""" % (product_name)) config.PATHS.PRODUCTPATH, "patches") if not patch_path: - msg = _("Patch %(1)s for %(2)s not found:\n" % - {"1" : patch, "2" : prod_info.name}) + msg = _("Patch %(1)s for %(2)s not found:\n") % + {"1" : patch, "2" : prod_info.name} raise src.SatException(msg) patches.append(patch_path) prod_info.patches = patches @@ -251,8 +251,8 @@ Please provide a 'compil_script' key in its definition.""" % (product_name)) config.PATHS.PRODUCTPATH, "env_scripts") if not env_script_path: - msg = _("Environment script %(1)s for %(2)s not found.\n" % - {"1" : env_script_path, "2" : prod_info.name}) + msg = _("Environment script %(1)s for %(2)s not found.\n") % + {"1" : env_script_path, "2" : prod_info.name} raise src.SatException(msg) prod_info.environ.env_script = env_script_path diff --git a/src/test_module.py b/src/test_module.py index 99d6315..d1a200b 100644 --- a/src/test_module.py +++ b/src/test_module.py @@ -98,12 +98,12 @@ class Test: symlinks=True) def prepare_testbase_from_dir(self, testbase_name, testbase_dir): - self.logger.write(_("get test base from dir: %s\n") % \ + self.logger.write(_("get test base from dir: %s\n") % src.printcolors.printcLabel(testbase_dir), 3) if not os.access(testbase_dir, os.X_OK): - raise src.SatException(_("testbase %(name)s (%(dir)s) does not " - "exist ...\n") % { 'name': testbase_name, - 'dir': testbase_dir }) + raise src.SatException( + _("testbase %(name)s (%(dir)s) does not exist ...\n") % + { 'name': testbase_name, 'dir': testbase_dir } ) self._copy_dir(testbase_dir, os.path.join(self.tmp_working_dir, 'BASES', testbase_name)) @@ -113,10 +113,10 @@ class Test: testbase_base, testbase_tag): self.logger.write( - _("get test base '%(testbase)s' with '%(tag)s' tag from git\n") % { - "testbase" : src.printcolors.printcLabel(testbase_name), - "tag" : src.printcolors.printcLabel(testbase_tag)}, - 3) + _("get test base '%(testbase)s' with '%(tag)s' tag from git\n") % + { "testbase" : src.printcolors.printcLabel(testbase_name), + "tag" : src.printcolors.printcLabel(testbase_tag) }, + 3) try: def set_signal(): # pragma: no cover """see http://bugs.python.org/issue1652""" @@ -160,7 +160,7 @@ class Test: sys.exit(0) def prepare_testbase_from_svn(self, user, testbase_name, testbase_base): - self.logger.write(_("get test base '%s' from svn\n") % \ + self.logger.write(_("get test base '%s' from svn\n") % src.printcolors.printcLabel(testbase_name), 3) try: def set_signal(): # pragma: no cover @@ -197,10 +197,9 @@ class Test: env=env_appli.environ.environ,) if res != 0: - raise src.SatException(_("Error: unable to get test base '%(nam" - "e)s' from svn '%(repo)s'.") % \ - { 'name': testbase_name, - 'repo': testbase_base }) + raise src.SatException( + _("Error: unable to get test base '%(name)s' from svn '%(repo)s'.") % + { 'name': testbase_name, 'repo': testbase_base } ) except OSError: self.logger.error(_("svn is not installed. exiting...\n")) @@ -232,8 +231,7 @@ class Test: return 0 if not test_base_info: - message = (_("########## ERROR: test base '%s' not found\n") % - test_base_name) + message = (_("ERROR: test base '%s' not found\n") % test_base_name) self.logger.write("%s\n" % src.printcolors.printcError(message)) return 1 @@ -252,10 +250,9 @@ class Test: test_base_name, test_base_info.info.base) else: - raise src.SatException(_("unknown source type '%(type)s' for test b" - "ase '%(base)s' ...\n") % { - 'type': test_base_info.get_sources, - 'base': test_base_name }) + raise src.SatException( + _("unknown source type '%(type)s' for test base '%(base)s' ...\n") % + {'type': test_base_info.get_sources, 'base': test_base_name } ) self.currentTestBase = test_base_name @@ -867,8 +864,8 @@ class Test: res_count = "%d / %d" % (self.nb_succeed, self.nb_run - self.nb_acknoledge) - res_out = _("Tests Results: %(succeed)d / %(total)d\n") % \ - { 'succeed': self.nb_succeed, 'total': self.nb_run } + res_out = _("Tests Results: %(succeed)d / %(total)d\n") % + { 'succeed': self.nb_succeed, 'total': self.nb_run } if self.nb_succeed == self.nb_run: res_out = src.printcolors.printcSuccess(res_out) else: -- 2.39.2