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

Masahiro Yamada yamada.masahiro at socionext.com
Sun Jul 24 16:17:38 CEST 2016


This commit makes the tool show the cleaned lines in red if the
--color option is given.

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

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

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()
-- 
1.9.1



More information about the U-Boot mailing list