Created
August 2, 2016 05:56
-
-
Save kuanyui/4ea9a95618175b067c0cc43b479a58f7 to your computer and use it in GitHub Desktop.
replace-tab-in-jade-file-to-spaces
This file contains hidden or 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 python3 | |
# -*- coding: utf-8 -*- | |
import os, subprocess, re | |
import fileinput | |
def replaceTabInFile(filePath): | |
print("Processing file {} ...".format(filePath)) | |
with fileinput.FileInput(filePath, inplace=True) as f: | |
for line in f: | |
newline = re.sub(" ", " ", line) | |
if newline.endswith("\n"): | |
print(newline[:-1]) | |
else: | |
print(newline) | |
for root, __dir, fileNames in os.walk("."): | |
for fileName in fileNames: | |
if (fileName.endswith(".jade")): | |
path = os.path.join(root, fileName) | |
replaceTabInFile(path) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment