summaryrefslogtreecommitdiffstats
path: root/solenv/clang-format/remove_not_existent_files_from_clang_excludelist
diff options
context:
space:
mode:
Diffstat (limited to 'solenv/clang-format/remove_not_existent_files_from_clang_excludelist')
-rwxr-xr-xsolenv/clang-format/remove_not_existent_files_from_clang_excludelist37
1 files changed, 37 insertions, 0 deletions
diff --git a/solenv/clang-format/remove_not_existent_files_from_clang_excludelist b/solenv/clang-format/remove_not_existent_files_from_clang_excludelist
new file mode 100755
index 000000000..89380381c
--- /dev/null
+++ b/solenv/clang-format/remove_not_existent_files_from_clang_excludelist
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+# Reformat files which are not excluded. This is interesting if the
+# clang-format version or config changes.
+# -n allows just listing the formatted files.
+
+import os
+
+base_path_to_core = os.path.abspath("../../")
+excludelist = "solenv/clang-format/excludelist"
+
+def delete_line_in_excludelist(line_to_be_removed):
+ with open(os.path.join(base_path_to_core, excludelist), "r") as f:
+ lines = f.readlines()
+ with open(os.path.join(base_path_to_core, excludelist), "w") as f:
+ for line in lines:
+ if line.strip("\n") != line_to_be_removed:
+ f.write(line)
+
+f = open(os.path.join(base_path_to_core, excludelist), "r")
+lines = f.read().split("\n")
+f.close()
+del lines[len(lines)-1] # remove empty, last line
+
+amount_lines_deleted = 0
+
+for line in lines:
+ if not os.path.isfile(os.path.join(base_path_to_core, line)):
+ print("Deleting file {} in excludelist".format(line))
+ delete_line_in_excludelist(line)
+ amount_lines_deleted += 1
+
+print("Removed {} lines in {}".format(amount_lines_deleted, os.path.join(base_path_to_core, excludelist)))