diff mbox

[3/4] tools: moveconfig: show result of header cleaning in color mode

Message ID 1469369859-14277-4-git-send-email-yamada.masahiro@socionext.com
State New
Headers show

Commit Message

Masahiro Yamada July 24, 2016, 2:17 p.m. UTC
This commit makes the tool show the cleaned lines in red if the
--color option is given.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 tools/moveconfig.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 27bd958..69701d4 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -356,7 +356,7 @@  def extend_matched_lines(lines, matched, pre_pattern, post_pattern, extend_pre,
     matched += extended_matched
     matched.sort()
 
-def cleanup_one_header(header_path, patterns, dry_run):
+def cleanup_one_header(header_path, patterns, options):
     """Clean regex-matched lines away from a file.
 
     Arguments:
@@ -406,16 +406,17 @@  def cleanup_one_header(header_path, patterns, dry_run):
                                 tofile=os.path.join('b', header_path))
 
     for line in diff:
-        print line,
+        print color_text(options.color and line[0] == '-' and line[1] != '-',
+                         COLOR_LIGHT_RED, line),
 
-    if dry_run:
+    if options.dry_run:
         return
 
     with open(header_path, 'w') as f:
         for line in tolines:
             f.write(line)
 
-def cleanup_headers(configs, dry_run):
+def cleanup_headers(configs, options):
     """Delete config defines from board headers.
 
     Arguments:
@@ -441,7 +442,7 @@  def cleanup_headers(configs, dry_run):
             for filename in filenames:
                 if not fnmatch.fnmatch(filename, '*~'):
                     cleanup_one_header(os.path.join(dirpath, filename),
-                                       patterns, dry_run)
+                                       patterns, options)
 
 ### classes ###
 class Progress:
@@ -1115,7 +1116,7 @@  def main():
         move_config(configs, options)
 
     if configs:
-        cleanup_headers(configs, options.dry_run)
+        cleanup_headers(configs, options)
 
 if __name__ == '__main__':
     main()