From 7f5c1cd0aab24a587aa249e26b1f2ace4f2a78a3 Mon Sep 17 00:00:00 2001 From: yue <tkdxwb@gmail.com> Date: Thu, 1 Oct 2020 16:13:04 +0200 Subject: [PATCH] [cleanup] script to remove clutter after header guards --- bin/util/remove_clutter_after_last_endif.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 bin/util/remove_clutter_after_last_endif.py diff --git a/bin/util/remove_clutter_after_last_endif.py b/bin/util/remove_clutter_after_last_endif.py new file mode 100644 index 0000000000..8cbdd81e65 --- /dev/null +++ b/bin/util/remove_clutter_after_last_endif.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 +import os + +# replace everything after last #endif with new line +def clearAfterLastEndIf(filename): + with open(filename, 'r') as header: + split = header.read().split("#endif") + split[-1] = '\n' + with open(filename, 'w') as header: + header.write("#endif".join(split)) + +for root, _, files in os.walk(os.getcwd()): + for file in files: + if file.endswith(".hh"): + clearAfterLastEndIf(os.path.join(root, file)) -- GitLab