Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jangernert/FeedReader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Long <self@brendanlong.com>2019-02-20 21:05:41 +0300
committerBrendan Long <self@brendanlong.com>2019-02-20 21:12:04 +0300
commitd919c675a3fc221ca289a43476c92f338275c11c (patch)
treee04c1c055b02909e4e191a3945390a7247d7f71a
parent33e9ebee64be11fc7f9bbaecaa2ab661f01e0869 (diff)
Add script to cleanup Vala indentation
-rw-r--r--.gitignore1
-rwxr-xr-xscripts/fix-indent.py21
2 files changed, 22 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index eaa2570b..69df8d35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
build/
builddir/
_build/
+.mypy_cache
.vscode/
*.~
.DS_Store
diff --git a/scripts/fix-indent.py b/scripts/fix-indent.py
new file mode 100755
index 00000000..10198e57
--- /dev/null
+++ b/scripts/fix-indent.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+import os
+import sys
+
+
+for file_name in sys.argv[1:]:
+ out_name = os.path.dirname(file_name) + "/new." + \
+ os.path.basename(file_name)
+ with open(file_name, "r") as f, open(out_name, "w") as o:
+ indent = 0
+ for line in f:
+ line = line.strip()
+ if line.startswith("}") or line.count(")") > line.count("("):
+ indent -= 1
+ for _ in range(indent):
+ o.write("\t")
+ o.write(line)
+ o.write("\n")
+ if line.endswith("{") or line.count("(") > line.count(")"):
+ indent += 1
+ os.rename(out_name, file_name)