Created
March 6, 2015 14:37
-
-
Save ag7/020b50bc4dbc47eca6b9 to your computer and use it in GitHub Desktop.
convert tabs to spaces inside source files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os, subprocess | |
# specify the source file extension here | |
sources = [".cpp", ".h"] | |
if __name__ == "__main__": | |
for root, _, files in os.walk(os.path.dirname(os.path.realpath(__file__))): | |
for fname, fext in [os.path.splitext(f) for f in files]: | |
if fext.lower() in sources: | |
src = os.path.join(root, fname + fext) | |
with open(src + ".out", "w") as fout: | |
subprocess.call(["expand", "-t", "4", "-i", src], stdout=fout) | |
os.rename(src + ".out", src) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment