summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--pygnulib/GLConfig.py19
-rw-r--r--pygnulib/constants.py12
3 files changed, 33 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 87c134d03f..e827c496b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2022-07-31 Bruno Haible <bruno@clisp.org>
+ gnulib-tool.py: Follow gnulib-tool changes, part 18.
+ Follow gnulib-tool change
+ 2005-09-20 Bruno Haible <bruno@clisp.org>
+ gnulib-tool: Remove trailing slashes
+ * pygnulib/constants.py (remove_trailing_slashes): New function.
+ * pygnulib/GLConfig.py (GLConfig): Use it in the setters.
+
+2022-07-31 Bruno Haible <bruno@clisp.org>
+
avltree-omap, avltree-oset, avltreehash-list, rbtree-omap: Pacify GCC.
* lib/gl_avltree_omap.c (gl_avltree_omap_check_invariants): Add extern
decl.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 457dc2c1e3..d203820427 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -42,6 +42,7 @@ MODES = constants.MODES
TESTS = constants.TESTS
joinpath = constants.joinpath
relpath = constants.relativize
+remove_trailing_slashes = constants.remove_trailing_slashes
isfile = os.path.isfile
normpath = os.path.normpath
@@ -68,6 +69,10 @@ class GLConfig(object):
Create new GLConfig instance.'''
self.table = dict()
self.table['tempdir'] = tempfile.mkdtemp()
+ # Check and store the attributes.
+ # Remove trailing slashes from the directory names. This is necessary
+ # for m4base (to avoid an error in func_import) and optional for the
+ # others.
# destdir
self.resetDestDir()
if destdir != None:
@@ -408,7 +413,7 @@ class GLConfig(object):
in gnulib's directory.'''
if type(localdir) is str:
if localdir:
- self.table['localdir'] = localdir
+ self.table['localdir'] = remove_trailing_slashes(localdir)
else: # if localdir has not str type
raise TypeError('localdir must be a string, not %s' %
type(localdir).__name__)
@@ -431,7 +436,7 @@ class GLConfig(object):
placed. Default comes from configure.ac or configure.in.'''
if type(auxdir) is str:
if auxdir:
- self.table['auxdir'] = auxdir
+ self.table['auxdir'] = remove_trailing_slashes(auxdir)
else: # if type of auxdir is not str
raise TypeError('auxdir must be a string, not %s' %
type(auxdir).__name__)
@@ -450,7 +455,7 @@ class GLConfig(object):
'''Specify directory relative to destdir where source code is placed.'''
if type(sourcebase) is str:
if sourcebase:
- self.table['sourcebase'] = sourcebase
+ self.table['sourcebase'] = remove_trailing_slashes(sourcebase)
else: # if type of sourcebase is not str
raise TypeError('sourcebase must be a string, not %s' %
type(sourcebase).__name__)
@@ -468,7 +473,7 @@ class GLConfig(object):
'''Specify directory relative to destdir where *.m4 macros are placed.'''
if type(m4base) is str:
if m4base:
- self.table['m4base'] = m4base
+ self.table['m4base'] = remove_trailing_slashes(m4base)
else: # if type of m4base is not str
raise TypeError('m4base must be a string, not %s' %
type(m4base).__name__)
@@ -486,7 +491,7 @@ class GLConfig(object):
'''Specify directory relative to destdir where *.po files are placed.'''
if type(pobase) is str:
if pobase:
- self.table['pobase'] = pobase
+ self.table['pobase'] = remove_trailing_slashes(pobase)
else: # if type of pobase is not str
raise TypeError('pobase must be a string, not %s' %
type(pobase).__name__)
@@ -506,7 +511,7 @@ class GLConfig(object):
Default value for this variable is 'doc').'''
if type(docbase) is str:
if docbase:
- self.table['docbase'] = docbase
+ self.table['docbase'] = remove_trailing_slashes(docbase)
else: # if type of docbase is not str
raise TypeError('docbase must be a string, not %s' %
type(docbase).__name__)
@@ -527,7 +532,7 @@ class GLConfig(object):
Default value for this variable is 'tests').'''
if type(testsbase) is str:
if testsbase:
- self.table['testsbase'] = testsbase
+ self.table['testsbase'] = remove_trailing_slashes(testsbase)
else: # if type of testsbase is not str
raise TypeError('testsbase must be a string, not %s' %
type(testsbase).__name__)
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 8fd982f7a7..e951c906d0 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -394,6 +394,18 @@ def nlremove(text):
return text
+def remove_trailing_slashes(text):
+ '''Remove trailing slashes from a file name, except when the file name
+ consists only of slashes.'''
+ result = text
+ while result.endswith('/'):
+ result = result[:-1]
+ if result == '':
+ result = text
+ break
+ return result
+
+
def remove_backslash_newline(text):
'''Given a multiline string text, join lines:
When a line ends in a backslash, remove the backslash and join the next