]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Define and use two new global functions.
authorBruno Haible <bruno@clisp.org>
Sat, 9 Sep 2017 10:48:58 +0000 (12:48 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 9 Sep 2017 14:43:24 +0000 (16:43 +0200)
* pygnulib/constants.py (remove_backslash_newline, combine_lines): New
functions.

pygnulib/GLModuleSystem.py
pygnulib/GLTestDir.py
pygnulib/constants.py

index 6dab6dd56ebe3f494aed39f3adf17e24916eda63..59109cce7ed4fbbe03f1b05b9663a47f8d85ac04 100644 (file)
@@ -707,7 +707,7 @@ Include:|Link:|License:|Maintainer:)'
             else:  # if not tests module
                 # TODO: unconditional automake snippet for nontests modules
                 snippet = self.getAutomakeSnippet_Conditional()
-                snippet = snippet.replace('\\\n', ' ')
+                snippet = constants.combine_lines(snippet)
                 pattern = compiler(
                     '^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
                 mentioned_files = pattern.findall(snippet)
@@ -1149,7 +1149,7 @@ class GLModuleTable(object):
             if type(module) is not GLModule:
                 raise(TypeError('each module must be a GLModule instance'))
             snippet = module.getAutomakeSnippet()
-            snippet = snippet.replace('\\\n', '')
+            snippet = constants.remove_backslash_newline(snippet)
             pattern = compiler(
                 '^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
             files = pattern.findall(snippet)
index 61407502ab9e8e2b8465a29e5ddd398e27dd7605..fded6d765685a34a637c54903af8457e6662cebb 100644 (file)
@@ -727,6 +727,7 @@ class GLTestDir(object):
         path = joinpath(self.testdir, sourcebase, 'Makefile.am')
         with codecs.open(path, 'rb', 'UTF-8') as file:
             snippet = file.read()
+        snippet = constants.remove_backslash_newline(snippet)
         cleaned_files = list()
         tests_cleaned_files = list()
         built_sources = list()
@@ -736,7 +737,6 @@ class GLTestDir(object):
 
         # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
         regex_find = list()
-        snippet = snippet.replace('\\\n', '')
         pattern = compiler('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
         regex_find += pattern.findall(snippet)
         pattern = compiler('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
@@ -765,10 +765,10 @@ class GLTestDir(object):
             path = joinpath(self.testdir, testsbase, 'Makefile.am')
             with codecs.open(path, 'rb', 'UTF-8') as file:
                 snippet = file.read()
+            snippet = constants.remove_backslash_newline(snippet)
 
             # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
             regex_find = list()
-            snippet = snippet.replace('\\\n', '')
             pattern = compiler('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
             regex_find += pattern.findall(snippet)
             pattern = compiler(
index 61d86a219235c690cd6fe72066d53c508543b2ee..596d1481bb438ed0833f80cf39a474500b9b5d96 100644 (file)
@@ -437,4 +437,17 @@ def nlremove(text):
     return(text)
 
 
+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
+    line to it.'''
+    return text.replace('\\\n', '')
+
+def combine_lines(text):
+    '''Given a multiline string text, join lines by spaces:
+    When a line ends in a backslash, remove the backslash and join the next
+    line to it, inserting a space between them.'''
+    return text.replace('\\\n', ' ')
+
+
 __all__ += ['APP', 'DIRS', 'MODES', 'UTILS']