diff mbox

[U-Boot,v3,3/4] tools: moveconfig: cleanup README entires

Message ID 20170502093049.20915-3-judge.packham@gmail.com
State Accepted
Commit f90df596a87bcec97873c247f1948190355539a9
Delegated to: Tom Rini
Headers show

Commit Message

Chris Packham May 2, 2017, 9:30 a.m. UTC
The Kconfig description replaces the description in the README file so
as options are migrated they can be removed from the README.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

Changes in v3: None
Changes in v2: None

 tools/moveconfig.py | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Comments

Simon Glass May 4, 2017, 4:50 p.m. UTC | #1
On 2 May 2017 at 03:30, Chris Packham <judge.packham@gmail.com> wrote:
> The Kconfig description replaces the description in the README file so
> as options are migrated they can be removed from the README.
>
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  tools/moveconfig.py | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini May 8, 2017, 7:44 p.m. UTC | #2
On Tue, May 02, 2017 at 09:30:48PM +1200, Chris Packham wrote:

> The Kconfig description replaces the description in the README file so
> as options are migrated they can be removed from the README.
> 
> Signed-off-by: Chris Packham <judge.packham@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 2361a43..95ef352 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -618,6 +618,46 @@  def cleanup_whitelist(configs, options):
     with open(os.path.join('scripts', 'config_whitelist.txt'), 'w') as f:
         f.write(''.join(lines))
 
+def find_matching(patterns, line):
+    for pat in patterns:
+        if pat.search(line):
+            return True
+    return False
+
+def cleanup_readme(configs, options):
+    """Delete config description in README
+
+    Arguments:
+      configs: A list of CONFIGs to remove.
+      options: option flags.
+    """
+    if not confirm(options, 'Clean up README?'):
+        return
+
+    patterns = []
+    for config in configs:
+        patterns.append(re.compile(r'^\s+%s' % config))
+
+    with open('README') as f:
+        lines = f.readlines()
+
+    found = False
+    newlines = []
+    for line in lines:
+        if not found:
+            found = find_matching(patterns, line)
+            if found:
+                continue
+
+        if found and re.search(r'^\s+CONFIG', line):
+            found = False
+
+        if not found:
+            newlines.append(line)
+
+    with open('README', 'w') as f:
+        f.write(''.join(newlines))
+
 
 ### classes ###
 class Progress:
@@ -1316,6 +1356,7 @@  def main():
         cleanup_headers(configs, options)
         cleanup_extra_options(configs, options)
         cleanup_whitelist(configs, options)
+        cleanup_readme(configs, options)
 
     if options.commit:
         subprocess.call(['git', 'add', '-u'])