>From b5850cf209fc597150fb196067674c8c41857316 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 6 Aug 2022 03:06:51 +0200 Subject: [PATCH 11/12] gnulib-tool.py: Finish implementing option --po-domain. * gnulib-tool.py (main): Accept option --po-domain. * pygnulib/GLEmiter.py (GLEmiter.po_POTFILES_in): Fix variable reference. * pygnulib/GLImport.py (GLImport.execute): Don't delete Makefile.in.in from the gnulib directory. Don't require a shell when invoking wget. After invoking wget, restore the current directory. --- ChangeLog | 8 ++++++++ gnulib-tool.py | 20 +++++++++++++++++++- gnulib-tool.py.TODO | 1 - pygnulib/GLEmiter.py | 3 +-- pygnulib/GLImport.py | 11 +++++++---- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16d17a6232..fde81debea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2022-08-05 Bruno Haible + gnulib-tool.py: Finish implementing option --po-domain. + * gnulib-tool.py (main): Accept option --po-domain. + * pygnulib/GLEmiter.py (GLEmiter.po_POTFILES_in): Fix variable + reference. + * pygnulib/GLImport.py (GLImport.execute): Don't delete Makefile.in.in + from the gnulib directory. Don't require a shell when invoking wget. + After invoking wget, restore the current directory. + gnulib-tool.py: Finish implementing option --macro-prefix. * gnulib-tool.py (main): Accept option --macro-prefix. diff --git a/gnulib-tool.py b/gnulib-tool.py index 030e3caf73..8dbf2d06a8 100755 --- a/gnulib-tool.py +++ b/gnulib-tool.py @@ -379,6 +379,11 @@ def main(): dest='macro_prefix', default=None, nargs=1) + # po-domain + parser.add_argument('--po-domain', + dest='podomain', + default=None, + nargs=1) # single-configure parser.add_argument('--single-configure', dest='single_configure', @@ -565,13 +570,23 @@ def main(): or cmdargs.excl_unportable_tests != None or cmdargs.avoids != None or cmdargs.lgpl != None or cmdargs.makefile_name != None - or cmdargs.macro_prefix != None))): + or cmdargs.macro_prefix != None or cmdargs.podomain != None))): message = '%s: *** ' % constants.APP['name'] message += 'invalid options for --%s mode\n' % mode message += 'Try \'gnulib-tool --help\' for more information.\n' message += '%s: *** Stop.\n' % constants.APP['name'] sys.stderr.write(message) sys.exit(1) + if cmdargs.pobase != None and cmdargs.podomain == None: + message = '%s: *** ' % constants.APP['name'] + message += 'together with --po-base, you need to specify --po-domain\n' + message += 'Try \'gnulib-tool --help\' for more information.\n' + message += '%s: *** Stop.\n' % constants.APP['name'] + sys.stderr.write(message) + sys.exit(1) + if cmdargs.pobase == None and cmdargs.podomain != None: + message = '%s: warning: --po-domain has no effect without a --po-base option\n' % constants.APP['name'] + sys.stderr.write(message) # Determine specific settings. destdir = cmdargs.destdir @@ -645,6 +660,9 @@ def main(): macro_prefix = cmdargs.macro_prefix if macro_prefix != None: macro_prefix = macro_prefix[0] + podomain = cmdargs.podomain + if podomain != None: + podomain = podomain[0] avoids = cmdargs.avoids if avoids != None: avoids = [ module diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index 87438c5a16..b59e89cc59 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -29,7 +29,6 @@ Implement the options: --gnu-make --tests-makefile-name --automake-subdir - --po-domain --witness-c-macro --vc-files --no-vc-files diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 9d9ca458ee..b6c31fa603 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -444,8 +444,7 @@ USE_MSGCTXT = no\n""" Emit the file list to be passed to xgettext. GLConfig: sourcebase.''' emit = '' - sourcebase = self.config['sourcebase'] - sourcebase = '%s%s' % (self.sourcebase, os.path.sep) + sourcebase = self.config['sourcebase'] + os.path.sep files = [ constants.substart('lib/', sourcebase, file) for file in files ] files = [ file diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index dda10c1b76..9de4b3b93c 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -42,10 +42,12 @@ __copyright__ = constants.__copyright__ #=============================================================================== # Define global constants #=============================================================================== +DIRS = constants.DIRS MODES = constants.MODES TESTS = constants.TESTS joinpath = constants.joinpath cleaner = constants.cleaner +copyfile = constants.copyfile copyfile2 = constants.copyfile2 movefile = constants.movefile isabs = os.path.isabs @@ -1161,7 +1163,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix tmpfile = self.assistant.tmpfilename(joinpath(pobase, file)) path = joinpath('build-aux', 'po', file) lookedup, flag = filesystem.lookup(path) - movefile(lookedup, tmpfile) + copyfile(lookedup, tmpfile) basename = joinpath(pobase, file) filename, backup, flag = self.assistant.super_update(basename, tmpfile) if flag == 1: @@ -1227,7 +1229,8 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix os.chdir(joinpath(destdir, pobase)) args = ['wget', '--no-verbose', '--mirror', '--level=1', '-nd', '-A.po', '-P', '.', '%sgnulib/' % TP_URL] - sp.call(args, shell=True) + sp.call(args) + os.chdir(DIRS['cwd']) else: # if self.config['dryrun'] print('Fetch gnulib PO files from %s' % TP_URL) @@ -1236,8 +1239,8 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix if not self.config['dryrun']: tmpfile = self.assistant.tmpfilename(basename) data = '# Set of available languages.\n' - files = [constants.subend('.po', '', file) - for file in os.listdir(joinpath(destdir, pobase))] + files = [ constants.subend('.po', '', file) + for file in os.listdir(joinpath(destdir, pobase)) ] data += '\n'.join(files) with codecs.open(tmpfile, 'wb', 'UTF-8') as file: file.write(data) -- 2.34.1