commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 03/06: modtool: Fix bug where gr_modtool rm


From: git
Subject: [Commit-gnuradio] [gnuradio] 03/06: modtool: Fix bug where gr_modtool rm messes up the C++ QA section
Date: Sun, 14 Jun 2015 15:08:46 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit f6bd3e6317bf6b142dc8aea89351468bb1cdecef
Author: Martin Braun <address@hidden>
Date:   Thu May 28 15:47:02 2015 -0400

    modtool: Fix bug where gr_modtool rm messes up the C++ QA section
    
    This bug was originally reported by chenzhubattg. Previously, C++
    QA files weren't properly removed from lib/CMakeLists.txt, such
    that the path to the file was left in the CMake file, making it
    invalid.
    This fixes a bug in the cmake_editor.py module, which previously
    had a too lenient regex.
---
 gr-utils/python/modtool/cmakefile_editor.py | 34 +++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/gr-utils/python/modtool/cmakefile_editor.py 
b/gr-utils/python/modtool/cmakefile_editor.py
index 3d90b8d..d57c650 100644
--- a/gr-utils/python/modtool/cmakefile_editor.py
+++ b/gr-utils/python/modtool/cmakefile_editor.py
@@ -39,8 +39,38 @@ class CMakeFileEditor(object):
         return nsubs
 
     def remove_value(self, entry, value, to_ignore_start='', to_ignore_end=''):
-        """Remove a value from an entry."""
-        regexp = '^\s*(%s\(\s*%s[^()]*?\s*)%s\s*([^()]*%s\s*\))' % (entry, 
to_ignore_start, value, to_ignore_end)
+        """
+        Remove a value from an entry.
+        Example: You want to remove file.cc from this list() entry:
+        list(SOURCES
+            file.cc
+            other_file.cc
+        )
+
+        Then run:
+        >>> C.remove_value('list', 'file.cc', 'SOURCES')
+
+        Returns the number of occurences of entry in the current file
+        that were removed.
+        """
+        # In the case of the example above, these are cases we need to catch:
+        # - list(file.cc ...
+        #   entry is right after the value parentheses, no whitespace. Can 
only happen
+        #   when to_ignore_start is empty.
+        # - list(... file.cc)
+        #   Other entries come first, then entry is preceded by whitespace.
+        # - list(SOURCES ... file.cc) # whitespace!
+        #   When to_ignore_start is not empty, entry must always be preceded 
by whitespace.
+        if len(to_ignore_start) == 0:
+            regexp = 
r'^\s*({entry}\((?:[^()]*?\s+|)){value}\s*([^()]*{to_ignore_end}\s*\)){to_ignore_start}'
+        else:
+            regexp = 
r'^\s*({entry}\(\s*{to_ignore_start}[^()]*?\s+){value}\s*([^()]*{to_ignore_end}\s*\))'
+        regexp = regexp.format(
+                entry=entry,
+                to_ignore_start=to_ignore_start,
+                value=value,
+                to_ignore_end=to_ignore_end,
+        )
         regexp = re.compile(regexp, re.MULTILINE)
         (self.cfile, nsubs) = re.subn(regexp, r'\1\2', self.cfile, count=1)
         return nsubs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]