Skip to content

Instantly share code, notes, and snippets.

@kuanyui
Created August 2, 2016 05:56
Show Gist options
  • Save kuanyui/4ea9a95618175b067c0cc43b479a58f7 to your computer and use it in GitHub Desktop.
Save kuanyui/4ea9a95618175b067c0cc43b479a58f7 to your computer and use it in GitHub Desktop.
replace-tab-in-jade-file-to-spaces
#! /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