summaryrefslogtreecommitdiff
path: root/pygnulib/GLEmiter.py
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-08-13 13:18:06 +0200
committerBruno Haible <bruno@clisp.org>2022-08-13 13:18:06 +0200
commit01cd78f9d682ff75cc5ab1c2d21b911bdd9215b8 (patch)
treee408b1a934167dd5cdcdad75713a263e41e51858 /pygnulib/GLEmiter.py
parent2c984879f02633334ccf80512ad1034dcc9cb922 (diff)
downloadgnulib-01cd78f9d682ff75cc5ab1c2d21b911bdd9215b8.tar.gz
gnulib-tool.py: Reduce code duplication.
* pygnulib/constants.py (relinverse): New function. * pygnulib/GLEmiter.py (GLEmiter.po_Makevars, GLEmiter.tests_Makefile_am): Use it. * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
Diffstat (limited to 'pygnulib/GLEmiter.py')
-rw-r--r--pygnulib/GLEmiter.py18
1 files changed, 4 insertions, 14 deletions
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index c0fd053077..4c8f0d90f2 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -42,6 +42,7 @@ __copyright__ = constants.__copyright__
#===============================================================================
TESTS = constants.TESTS
joinpath = constants.joinpath
+relinverse = constants.relinverse
isfile = os.path.isfile
normpath = os.path.normpath
@@ -390,13 +391,7 @@ class GLEmiter(object):
emit = ''
pobase = self.config['pobase']
podomain = self.config['podomain']
- top_subdir = ''
- source = '%s/' % os.path.normpath(pobase)
- if os.path.sep in source:
- for directory in source.split(os.path.sep):
- if directory != '':
- top_subdir += '../'
- top_subdir = os.path.normpath(top_subdir)
+ top_subdir = relinverse(pobase)
emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"
emit += "%s\n" % self.copyright_notice()
emit += "# Usually the message domain is the same as the package name.\n"
@@ -941,13 +936,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
else: # if not for_test
edit_check_PROGRAMS = False
- # Calculate testsbase_inverse
- counter = int()
- testsbase_inverse = ''
- while counter < len(testsbase.split('/')):
- testsbase_inverse += '../'
- counter += 1
- testsbase_inverse = os.path.normpath(testsbase_inverse)
+ # Compute testsbase_inverse
+ testsbase_inverse = relinverse(testsbase)
# Begin the generation.
emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"